API documentation

Formatting

- POST /api/fake/{fakeID}/info
    ^ This is the method and endpoint. Anything in curly braces { } should be substituted for a value.
      Values should not include the curly braces.
      Example: /api/fake/ab472c/info

    ? something : integer
    ? somethingElse : integer?
    ^ These are query string parameters, indicated by a ? character.
      The first word is the parameter name and the second word is the data type.
      If the data type ends with a ?, that parameter is optional.

    B something : JSON
        B content : string
    ^ This is the POST body, indicated by a B character.
      Often the body will be a JSON object. This object should be converted to a string for sending.
      The second line shows the contents of the JSON object.

    R Array/JSON
        R fakeID : integer
    ^ This is the return value, indicated by a R character.
      The notation "Array/JSON" indicates an array containing JSON objects.
      Similarly, "Array/integer" would indicate an array of integers.
      "204" indicates HTTP 204 No Response, and a successful operation.

Pastes

- GET /api/pastes/{pasteID}
    R JSON
        R pasteID : integer
        R author : string
        R content : string
        R creationTime : integer
        R expiryTime : integer/null

    Get paste details and content from a pasteID.

- GET /api/pastes/{pasteID}/raw
    R content : string

    Get raw paste content as plaintext from a pasteID.

- POST /api/pastes
    B JSON
        B username : string?
        B token : string?
        B content : string

    R JSON
        R pasteID : integer

    Upload a new paste.
    Specify a token to associate this paste with an account and make it editable by that account.
    If no token is provided, you can use any username, provided it is not already registered to an account.
    If neither token nor username is provided, the username will be set to "(anonymous)".

- PATCH /api/pastes/{pasteID}
    B JSON
        B content : string
        B token : string

    R 204

    Edit an existing paste. An account token is required.
    Set content to an empty string to delete the paste.

- GET /api/pastes
    ? start : integer?
    ? end : integer?
    ? limit : integer?
    ? preview : integer?

    R Array/JSON
        R pasteID : integer
        R author : string
        R content : string?
        R creationTime : integer
        R expiryTime : integer/null

    Get a list of existing pastes.
    If neither start nor end are provided:
        Return as many pastes as possible, sorted by newest to oldest.
    Otherwise:
        Return as many pastes as possible whose IDs are >= start and <= end.
        If one of start or end is missing, the maximum bound is assumed.
    If limit is provided and is less than the API's internal max, do not return more than that many results.
    Otherwise, return up to the API's internal max.
    If preview is provided and is less than 0, do not return the content of any pastes.
    Otherwise, if preview is less than 1000, return up to that many characters of content from every paste.
    Otherwise, return up to 1000 characters of content from every paste.

Images

- GET /api/images/{imageID}
    R image : binary

    Get an image. Content-Type header will be set.

- GET /api/images/{imageID}/details
    R JSON
        R imageID : string
        R extension : string
        R author : string
        R creationTime : integer
        R expiryTime : integer?

    Get information about an image.

- POST /api/images
    ? author : string?
    B content : binary

    R JSON
        R imageID : string

    Upload an image.

- GET /api/images
    ? limit : integer?

    R Array/JSON
        R imageID : string
        R extension : string
        R author : string
        R creationTime : integer
        R expiryTime : integer?

    Get a list of details of existing images.
    If limit is provided, do not return more than that many results.

URLs/Links

- GET /api/urls/{hash}
    R 303 redirect

    Go to a shortened URL.
    Browsers will be redirected automatically.
    For non-browsers, examine the "Location" header to find the destination.

- GET /api/urls/{hash}/details
    R JSON
        R hash : string
        R author : string?
        R target : string
        R creationTime : integer
        R expiryTime : integer?

    Get information about an existing shortened URL.

- POST /api/urls
    B JSON
        B username : string?
        B token : string?
        B target : string

    R JSON
        R hash : string

    Shorten a URL.
    Specify a token to associate this link with an account.
    If no token is provided, you can use any username, provided it is not already registered to an account.
    If neither token nor username is provided, the username will be set to "(anonymous)".

- GET /api/urls
    ? limit : integer?

    R Array/JSON
        R hash : string
        R author : string?
        R target : string
        R creationTime : integer
        R expiryTime : integer?

    Return a list of existing shortened URLs and their details.
    If limit is provided and is less than the API's internal max, do not return more than that many results.
    Otherwise, return up to the API's internal max.

Accounts

- POST /api/accounts
    B JSON
        B username : string
        B password : string

    R 204

    Create a new account with that username and password.

- PATCH /api/accounts
    B JSON
        B username : string
        B password : string
        B newPassword : string

    R 204

    Edit an account's password.
    The password property should contain the account's previous password.

- POST /api/accounts/tokens
    B JSON
        B username : string
        B password : string

    R JSON
        R token : string
        R expires : integer

    Create a new account access token. This token is used to create pastes or links from that account.
    The token will expire and be unusable on the date specified in the expires property.
    You can create as many tokens as you like for a single account.

- GET /api/accounts/tokens/{token}
    R JSON
        R username : string
        R expires : integer

    Get the username and expiry date of an existing account access token.

- DELETE /api/accounts/tokens/{token}
    R 204

    Delete an existing account access token.

Error codes

- 1
    Missing content ID
- 2
    Bad content ID
- 3
    Malformed JSON
- 4
    Missing content
- 5
    Bad content
- 6
    Content too large (HTTP 413)
- 7
    Duplicate action cannot be performed (HTTP 409)
- 8
    Invalid authentication details (HTTP 401)
- 9
    Username in use