Hastebin API Documentation

Hastebin has a free public API to be used programmatically in any application.

Authentication

To be able to send Hastebin API requests, you need to create an API TOKEN.

How to create a token

Sign in with your Github account, generate a token and start using the Hastebin API.

How to use a token

To use the token, add the token to the Authorization header of your request. You can refer to code snippets from the endpoints section.

{
  'Authorization': 'Bearer YOURTOKEN'
}

Token validation

Once you have your token, you can keep using it unless you decide to invalidate it. To invalidate or generate a new token, sign in with your Github account and generate a new token.

API Limits

Pasted content will be available for 30 days for authorized users and 7 days otherwise.

Important: you can have just one active token at a time, and there is a strict limit of 100 requests per minute.

API Endpoints

Deprecation Notice: Our new website URL is https://www.toptal.com/developers/hastebin, and the the API endpoints have changed.

API https://hastebin.com
POST

/documents

Add new document

Parameters

Name

Description

Route

/documents

Method

POST

Body

Content of the document (string)

Header

  • content-type : text/plain

  • Authorization: Bearer TOKEN

Accepted content types

  • application/x-www-form-urlencoded

  • application/json

  • text/plain

  • multipart/form-data

Example request

CURL
curl --request POST --url https://hastebin.com/documents --header "Authorization: Bearer TOKEN" --header "content-type: text/plain" --data "Hello World"

Response types

200
401
401
403
403
405
413
500
500
500
{
    "key": "aeiou"
}
GET

/documents/:id

Get document by id

Parameters

Name

Description

Route

/documents/:id

Method

GET

Header

Authorization: Bearer TOKEN

Example request

CURL
curl --request GET --url https://hastebin.com/documents/aeiou --header "Authorization: Bearer TOKEN"

Response types

200
401
401
403
403
403
404
404
405
500
500
500
{
    "key": "aeiou",
    "data": "Hello World"
}
GET

/raw/:id

Get raw document by id

Parameters

Name

Description

Route

/raw/:id

Method

GET

Header

Authorization: Bearer TOKEN

Example request

CURL
curl --request GET --url https://hastebin.com/raw/aeiou --header "Authorization: Bearer TOKEN"

Response types

200
401
401
403
403
403
404
404
405
500
500
500
Hello World

Error Status Codes

These are the status codes used when something goes wrong:

  • 401

    The user is not authorized.

  • 401

    Unauthorized request: missing access token. To generate a token, go to https://www.toptal.com/developers/hastebin and follow the instructions.

  • 403

    Your account is blocked, and you are not allowed to create or read bins. If you have any questions, please contact $email.

  • 403

    You are not allowed to see that page.

  • 403

    The author of this bin was blocked, and all bins created by them were removed for not following the terms and conditions of this website.

  • 403

    Terms & Conditions were not accepted.

  • 404

    The document was not found.

  • 404

    The user document was not found.

  • 404

    The user id was not found.

  • 405

    Method Not Allowed

  • 413

    Payload too large - maximum length of a document is 400 000 characters or less than 1mb in size.

  • 500

    Something went wrong.

  • 500

    An error occurred while getting the document.

  • 500

    Can't connect to the database.

  • 500

    An error occurred while adding the document.

Terms & Conditions