bin

A light web service to host code snippet and share them via URLs.

HTTP API

GET /health

Get a dummy string ‘alive’ to ensure the server is responding

GET /

Get the browser-friendly html form to easily post a new snippet

Parameters
  • lang – (query) optional lang that is selected in the lang selection instead of the configured default

  • parentid – (query) optional ‘parent’ snippet to duplicate the code from

Raises HTTPError

code 404 when the ‘parent’ snippet is not found

GET /assets/(filepath: path)

Get a static css/js/media file that is stored in the filesystem.

This route exists for developers of bin who wish to run the service with minimum system requirements. In production, we suggest you use a web server to deliver the static content.

POST /new

Post a new snippet and redirect the user to the generated unique URL for the snippet.

Parameters
  • code – (form) required snippet text, can alternativaly be sent as a Multi-Part utf-8 file

  • lang – (form) optional language

  • maxusage – (form) optional maximum download of the snippet before it is deleted

  • lifetime – (form) optional time (defined in seconds) the snippet is keep in the database before it is deleted

  • parentid – (form) optional snippet id this new snippet is a duplicate of

  • token – (form) optional the “admin” token allows you to delete your snippet

Raises HTTPError

code 411 when the Content-Length http header is missing

Raises HTTPError

code 413 when the http request is too large (mostly because the snippet is too long)

Raises HTTPError

code 400 with a sensible status when the form processing fails

GET /(snippetid).(ext)

Get a snippet in a beautiful html page

Parameters
  • snippetid – (path) required snippet id

  • ext – (path) optional language file extension, used to determine the highlight backend

  • token – (query) optional the “admin” token

Raises HTTPError

code 404 when the snippet is not found

GET /(snippetid)

Get a snippet in a beautiful html page

Parameters
  • snippetid – (path) required snippet id

  • ext – (path) optional language file extension, used to determine the highlight backend

  • token – (query) optional the “admin” token

Raises HTTPError

code 404 when the snippet is not found

DELETE /(snippetid).(ext)

Delete a snippet

Parameters
  • Authorization – (header) required “Authorization: Token <ADMIN_TOKEN>” the “admin” token

Raises HTTPError

code 400 when the Authorization (token) is missing

Raises HTTPError

code 404 when the snippet is not found

Raises HTTPError

code 401 when the token is incorrect

DELETE /(snippetid)

Delete a snippet

Parameters
  • Authorization – (header) required “Authorization: Token <ADMIN_TOKEN>” the “admin” token

Raises HTTPError

code 400 when the Authorization (token) is missing

Raises HTTPError

code 404 when the snippet is not found

Raises HTTPError

code 401 when the token is incorrect

GET /raw/(snippetid).(ext)

Get a snippet in plain text without code hightlight

Parameters
  • snippetid – (path) required snippet id

  • ext – (path) ignored parameter

GET /raw/(snippetid)

Get a snippet in plain text without code hightlight

Parameters
  • snippetid – (path) required snippet id

  • ext – (path) ignored parameter

POST /report

Report a problematic snippet to the system administrator.

Parameters
  • snippetid – (form) the reported snippet

  • name – (form) the name of the user reporting the problem

Raises HTTPError

code 400 when any of the snippetid or the name is missing

Raises HTTPError

code 404 when the reported snippet is not found