Using the Pastebucket REST APIs

Introduction

The PasteBucket REST API allows third-party application developers the means for writing applications for the PasteBucket service. Our REST API is based on open standards, you can use any web development language to access the API. Using the API, users can sign in and grant your application the right to make calls on their behalf. Then, through the API, your application can access PasteBucket resources such as an individual (or team) account, repositories, and aspects of these resources such as changesets or comments.

You should be familiar with REST architecture before writing an integration. Good REST resources abound on the internet. Read this overview page to gain a good understanding of PasteBucket's REST implementation. When you are ready to begin, obtain a API key for your application.

Submit a Post

Creating a post can be done by calling the following URL with the appropriate parameters.

http://www.pastebucket.com/api/CreatePost

Both POST and GET can be used. POST is however preferred as GET is inherently limited to 2048 characters in Internet Explorer.

Below is an example of how to post using GET:
http://www.pastebucket.com/api/CreatePost?ApiKey=0000-0000-0000-0000-0000&Title=hello&Post=hello%20world&LanguageID=1&PasteAccessID=1&ExpirationDate=&ExpirationMinutes=60

Here is an example of using HTML POST to send data, this method is however not recommended for public websites as it would expose your API key.

            <form action="http://www.pastebucket.com/api/CreatePost" method="post"> 
                <input type="text" name="ApiKey" value="0000-0000-0000-0000-0000" /> 
                <input type="text" name="ExpirationDate" value="" /> 
                <input type="text" name="ExpirationMinutes" value="60" /> 
                <input type="text" name="LanguageID" value="1" /> 
                <input type="text" name="PasteAccessID" value="1" /> 
                <input type="text" name="Title" value="Hello" /> 
                <input type="text" name="Post" value="world" /> 
                <input type="submit" value="Send" /> 
            </form>
        

URL Parameters

The different parameters are explained below.

APIKey

This is a your personal key which allows you to post to PasteBucket. Keys can be requested at your "Manage Profile" page.

All posts will be traceable to your APIKey, abuse will not be tolerated.

ExpirationDate (Optional)

This sets the Expiration date of the post. If both ExpirationDate and ExpirationMinutes is set the API will use ExpirationDate and if none of them is set then the post will not expire.
The Expiration date should be UTC TimeZone (TimeZone ±0).

Example: ExpirationDate=1994-11-05T08:15:30

ExpirationMinutes (Optional)

This sets in how many minutes the post will expire. If both ExpirationDate and ExpirationMinutes is set the API will use ExpirationDate and if none of them is set then the post will not expire.

Example: ExpirationMinutes=60

Language

This sets the code language that the code will be parsed and displayed as. The language options can be retrieved from: http://www.pastebucket.com/API/GetLanguageTypeOptions?ApiKey=0000-0000-0000-0000 One of the available options is:

{ 
    "languageid" : 4,
    "languagename" : "Javascript"
}
        

Using this option would set the code rendering mode to Javascript:

languageid=4

Post Access

This parameter sets who is able to view the post. The different options can be retrieved from: http://www.pastebucket.com/API/GetPostAccessOptions?ApiKey=0000-0000-0000-0000

One of the available options is:

{ 
    "Description" : "Public",
    "Key" : 1
}
        

This would set the post to public so that it shows up in the archive list and anyone who has the url can view the post.

PasteAccessID=1

Title

This is the title that will be displayed on the post. The parameter can be empty but we would prefer if a relevant title is posted with the code.

Data

This is the actual code or text you want to post. Currently the API limits a post to 500Kb of data which is around 512000 characters.