[GET] /api/user

Gets statistics for currently logged in user.

Example request

request

curl -u username:password http://127.0.0.1:8000/api/user

successful response

{  
    "username":"username",  
    "pastes":2,  
    "public_pastes":1,  
    "views":5,  
    "joined":"2018-11-10T11:41:58.137509Z",  
    "email":"[email protected]"  
}

possible errors

  • 403 - Invalid username/password

[GET] /api/user/<username>

Gets statistics for a given user.

Example request

request

curl http://127.0.0.1:8000/api/user/username

successful response

{  
    "username":"username",  
    "pastes":2,
    "public_pastes":1,  
    "views":5,  
    "joined":"2018-11-10T11:41:58.137509Z"  
}

possible errors

  • 404 - User is not found

[GET] /api/pastes

Lists all public pastes.

parameter required type default description
page no integer 1 page number
limit no integer (1-50) 20 number of results returned per page
owner no string list all public pastes owned by <owner>. If you are the owner, pastes owned by you will be listed including private and unlisted

Example request

request

curl "http://127.0.0.1:8000/api/pastes?limit=3"

successful response

{  
    "count":3,  
    "results":[
    {  
        "id":"2WoEJoPa",  
        "created":"2018-11-12T15:31:58.093811Z",  
        "views":3,  
        "title":"test",  
        "highlight":"nohighlight",  
        "expiration":"0.0",  
        "visibility":1,  
        "content":"123"  
    }
    ...
    ]  
}

possible errors

[POST] /api/pastes

Creates a new paste, this action requires an authenticated request.

parameter required type default description
title no string (128 characters max) “untitled paste” title of your paste
highlight no string* “nohighlight” Syntax highlighting
expiration no string “never” paste expiration ("10m", "1h", "1d", "1w", "1M", "1y", "never")
visibility no integer 1 paste visibility - 1 for public, 2 for unlisted, 3 for private
content yes string (50000 characters max) your text to store

Example request

request

curl -u username:password http://127.0.0.1:8000/api/pastes -d $'content=123\n456'

successful response

{  
    "id":"wuLnv3fp",  
    "owner":"username",  
    "created":"2018-11-13T06:29:34.658655Z",  
    "views":1,  
    "title":"untitled paste",  
    "highlight":"nohighlight",  
    "expiration":"0.0",  
    "visibility":1,  
    "content":"123\n456"  
}

possible errors

  • 400 - Missing required field
  • 403 - Unauthorized user

[GET] /api/paste/<id>

Gets details for a given paste

Example request

request

 curl http://127.0.0.1:8000/api/paste/wuLnv3fp

successful response

{  
    "id":"wuLnv3fp",  
    "owner":"username",  
    "created":"2018-11-13T06:29:34.658655Z",  
    "views":2,  
    "title":"untitled paste",  
    "highlight":"nohighlight",  
    "expiration":"0.0",  
    "visibility":1,  
    "content":"123\n456"  
}

possible errors

  • 404 - Paste is not found
  • 403 - Permission denied

[PUT] /api/paste/<id>

Updates a given paste, this action requires an authorized request.

parameter required type default description
title no string (128 characters max) “untitled paste” title of your paste
highlight no string* “nohighlight” Syntax highlighting
expiration no string** “0.0” paste expiration
visibility no integer 1 paste visibility - 1 for public, 2 for unlisted, 3 for private
content yes string (50000 characters max) your text to store

Example request

request

 curl -u username:password -X 'PUT' http://127.0.0.1:8000/api/paste/wuLnv3fp -d $'content=123\n456\n789&visibility=2'

successful response

{  
    "id":"wuLnv3fp",  
    "owner":"username",  
    "created":"2018-11-13T06:29:34.658655Z",  
    "views":2,  
    "title":"untitled paste",  
    "highlight":"nohighlight",  
    "expiration":"0.0",  
    "visibility":2,  
    "content":"123\n456\n789"  
}

possible errors

  • 404 - Paste is not found
  • 403 - Permission denied

[DELETE] /api/paste/<id>

Deletes a given paste, this action requires an authorized request.

Example request

request

curl -u username:password -X 'DELETE' http://127.0.0.1:8000/api/paste/wuLnv3fp

successful response
Returned empty response with status code of 204 No Content

possible errors

  • 404 - Paste is not found
  • 403 - Permission denied