Pastery

API documentation +

Pastery includes a very simple API that you can use for integration with editors and other programs.

Creating a paste

API Description

POST https://www.pastery.net/api/paste/
    ?api_key=<api_key>
    &duration=<duration>
    &title=<title>
    &language=<language>
    &max_views=<max_views>

The text to be pasted should be included in the raw POST body, and encoded as UTF-8. The trailing slash in the URL is important!

Parameters:

Command-line example

Here's how you can upload a paste from a file called data.txt using curl:

$ curl -X POST https://www.pastery.net/api/paste/?title=Sample+data&api_key=mykey --data-binary @data.txt
{"url": "https://www.pastery.net/yfbfgg/", "duration": 1440, "title": "Sample data", "language": "python"}

or:

$ curl https://www.pastery.net/api/paste/ -F [email protected]
{"url": "https://www.pastery.net/yfbfgg/", "duration": 1440, "title": "Sample data", "language": "python"}

Retrieving your pastes

API Description

GET https://www.pastery.net/api/paste/
    ?api_key=<api_key>

Parameters:

Command-line example

Here's how you can get a list of all your pastes using curl:

$ curl https://www.pastery.net/api/paste/?api_key=mykey
{
    "pastes": [
        {
            "duration": 800, 
            "id": "api", 
            "language": "markdown", 
            "title": "API documentation", 
            "url": "https://www.pastery.net/api/"
        },
        {
            "duration": 800, 
            "id": "about", 
            "language": "markdown", 
            "title": "About", 
            "url": "https://www.pastery.net/about/"
        }
    ]
}

Retrieving a single paste

API Description

GET https://www.pastery.net/api/paste/<id>/
    ?api_key=<api_key>

Parameters:

Command-line example

Here's how you can get a single paste using curl:

$ curl https://www.pastery.net/api/paste/about/?api_key=mykey
{
    "pastes": [
        {
            "duration": 800, 
            "id": "about", 
            "language": "markdown", 
            "title": "About", 
            "url": "https://www.pastery.net/about/"
        }
    ]
}

Deleting a paste

API Description

DELETE https://www.pastery.net/api/paste/<id>/
    ?api_key=<api_key>

Parameters:

Command-line example

Here's how you can delete a paste using curl:

$ curl -X DELETE https://www.pastery.net/api/paste/sanwhh/?api_key=mykey
{"result": "success"}

Language list

New paste