pb

API Endpoint
https://fars.ee/

pb is a lightweight pastebin (and url shortener) built using flask.

API Media Types

Most routes support multiple mixed request and response types, using the Content-Type and Accept headers, respectively.

The primary use-cases are:

Content-Type Accept
multipart/form-data text/x-yaml,*/*
multipart/mixed application/json
application/json application/json

All text/* responses from pb may also use charset=utf-8. All text/plain responses are valid yaml, and should be parsed as such.

Paste Media Types

Pastes can have custom media types as well. For methods that support it, the filename request attribute is parsed, and converted to a mimetype (e.g: foo.jpg is parsed into image/jpeg). This mimetype, if successfully parsed, is returned in the Content-Type header for subsequent get requests for that paste.

This behavior can also be controlled per-request by appending a mimetype extension to the paste ID (e.g: a paste with short Z7_u can be referenced as Z7_u.png and have the image/png mimetype for that request only).

paste crud

create paste

POST https://fars.ee//label
Requestsmultipartjson
Headers
Content-Type: multipart/form-data; boundary=------------------------7742583d48a00ce6
Accept: */*
Body
--------------------------7742583d48a00ce6
Content-Disposition: form-data; name="c"; filename="-"
Content-Type: application/octet-stream

test1234ba

--------------------------7742583d48a00ce6--
Responses200
Headers
Content-Type: text/plain; charset=utf-8
Vary: Accept
Location: https://ptpb.pw/7Z_u
Body
date: 2017-03-07T21:21:39.919155+00:00
digest: 5ca6c440b6e52fcd0a47dae3879b8ef99ded9fee
long: AFymxEC25S_NCkfa44ebjvmd7Z_u
short: 7Z_u
size: 10
status: created
url: https://ptpb.pw/7Z_u
uuid: 5dbe3f5b-78f3-4c2b-9965-58f88a0a5da5
Headers
Content-Type: application/json
Accept: application/json
Body
{
  "content": "Hello World!!",
  "filename": "kittens.jpg",
  "private": 1,
  "sunset": "2017-03-07T21:49:37.654602+00:00"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "content": {
      "type": "string"
    },
    "filename": {
      "type": "string",
      "description": "the extension of the provided filename is parsed into a mimetype, and stored internally."
    },
    "private": {
      "type": "number",
      "description": "when specified, the paste will not be accessible via `short` id."
    },
    "sunset": {
      "type": "string",
      "description": "when specified, the paste will become unavailable after the provided datetime."
    }
  },
  "required": [
    "content"
  ]
}
Responses200400
Headers
Content-Type: application/json
Vary: Accept
Location: https://ptpb.pw/ABgOBB3kOB-3GPA8RA5pfgyn-ooL.jpg
Body
{
  "url": "https://ptpb.pw/rHd5",
  "long": "AJJ1vikJUiGkSLlni-aYVR8UrHd5",
  "short": "rHd5",
  "digest": "9275be29095221a448b9678be698551f14ac7779",
  "date": "2017-03-08T01:02:45.621000+00:00",
  "size": 11,
  "uuid": "5dbe3f5b-78f3-4c2b-9965-58f88a0a5da5",
  "label": "f",
  "sunset": "2017-03-08T01:02:45.621000+00:00",
  "status": "created",
  "namespace": "",
  "redirect": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    },
    "long": {
      "type": "string"
    },
    "short": {
      "type": "string"
    },
    "digest": {
      "type": "string"
    },
    "date": {
      "type": "string"
    },
    "size": {
      "type": "number"
    },
    "uuid": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "sunset": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "created",
        "deleted",
        "expired",
        "already exists",
        "found",
        "updated"
      ]
    },
    "namespace": {
      "type": "string",
      "description": "undocumented"
    },
    "redirect": {
      "type": "number"
    }
  },
  "required": [
    "url",
    "long",
    "digest",
    "date",
    "size",
    "status"
  ]
}
Headers
Content-Type: application/json
Vary: Accept
Body
{
  "status": "no post content"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ]
}

create paste
POST/{label}

All request attributes (disposition names, json object fields) can be referenced by their full name or first letter.

A compliant client must be prepared to accept responses that do not match the requested response content type. A minimal client would present such a response as a “generic server-side error” to the user.

URI Parameters
HideShow
label
string (optional) 

create a paste with a vanity label. A label currently must be at least two characters, and the first character must be ~.


read paste

GET https://fars.ee//id
Responses200
Body
<!-- paste content -->

read paste
GET/{id}

Returns paste content for a given paste id.

URI Parameters
HideShow
id
string (required) 

paste id, any of the long, short, label, or digest attributes


update paste

PUT https://fars.ee//id
Requestsjson
Headers
Content-Type: application/json
Body
{
  "content": "Hello World!!",
  "filename": "kittens.jpg",
  "private": 1,
  "sunset": "2017-03-07T21:49:37.654602+00:00"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "content": {
      "type": "string"
    },
    "filename": {
      "type": "string",
      "description": "the extension of the provided filename is parsed into a mimetype, and stored internally."
    },
    "private": {
      "type": "number",
      "description": "when specified, the paste will not be accessible via `short` id."
    },
    "sunset": {
      "type": "string",
      "description": "when specified, the paste will become unavailable after the provided datetime."
    }
  },
  "required": [
    "content"
  ]
}
Responses200400
Headers
Content-Type: application/json
Body
{
  "url": "https://ptpb.pw/rHd5",
  "long": "AJJ1vikJUiGkSLlni-aYVR8UrHd5",
  "short": "rHd5",
  "digest": "9275be29095221a448b9678be698551f14ac7779",
  "date": "2017-03-08T01:02:45.621000+00:00",
  "size": 11,
  "uuid": "5dbe3f5b-78f3-4c2b-9965-58f88a0a5da5",
  "label": "f",
  "sunset": "2017-03-08T01:02:45.621000+00:00",
  "status": "created",
  "namespace": "",
  "redirect": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    },
    "long": {
      "type": "string"
    },
    "short": {
      "type": "string"
    },
    "digest": {
      "type": "string"
    },
    "date": {
      "type": "string"
    },
    "size": {
      "type": "number"
    },
    "uuid": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "sunset": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "created",
        "deleted",
        "expired",
        "already exists",
        "found",
        "updated"
      ]
    },
    "namespace": {
      "type": "string",
      "description": "undocumented"
    },
    "redirect": {
      "type": "number"
    }
  },
  "required": [
    "url",
    "long",
    "digest",
    "date",
    "size",
    "status"
  ]
}
Headers
Content-Type: application/json
Body
{
  "status": "no post content"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ]
}

update paste
PUT/{id}

Replace paste attributes.

URI Parameters
HideShow
id
string (required) 

paste id, the uuid attribute


delete paste

DELETE https://fars.ee//id
Requestsjson
Headers
Content-Type: application/json
Accept: application/json
Responses200404
Headers
Content-Type: application/json
Vary: Accept
Location: https://ptpb.pw/rHd5
Body
{
  "url": "https://ptpb.pw/rHd5",
  "long": "AJJ1vikJUiGkSLlni-aYVR8UrHd5",
  "short": "rHd5",
  "digest": "9275be29095221a448b9678be698551f14ac7779",
  "date": "2017-03-08T01:02:45.621000+00:00",
  "size": 11,
  "uuid": "5dbe3f5b-78f3-4c2b-9965-58f88a0a5da5",
  "label": "f",
  "sunset": "2017-03-08T01:02:45.621000+00:00",
  "status": "created",
  "namespace": "",
  "redirect": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    },
    "long": {
      "type": "string"
    },
    "short": {
      "type": "string"
    },
    "digest": {
      "type": "string"
    },
    "date": {
      "type": "string"
    },
    "size": {
      "type": "number"
    },
    "uuid": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "sunset": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "created",
        "deleted",
        "expired",
        "already exists",
        "found",
        "updated"
      ]
    },
    "namespace": {
      "type": "string",
      "description": "undocumented"
    },
    "redirect": {
      "type": "number"
    }
  },
  "required": [
    "url",
    "long",
    "digest",
    "date",
    "size",
    "status"
  ]
}
Headers
Content-Type: application/json
Vary: Accept
Body
{
  "status": "not found"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "status": {
      "type": "string"
    }
  },
  "required": [
    "status"
  ]
}

delete paste
DELETE/{id}

This type of deletion will make the paste no longer exist.

URI Parameters
HideShow
id
string (required) 

paste id, the uuid attribute


short url

create short url

POST https://fars.ee//u
Requestsjson
Headers
Content-Type: application/json
Body
{
  "content": "https://apiblueprint.org/documentation/mson/specification.html"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "content": {
      "type": "string"
    }
  }
}
Responses200
Headers
Content-Type: application/json
Body
{
  "url": "https://ptpb.pw/rHd5",
  "long": "AJJ1vikJUiGkSLlni-aYVR8UrHd5",
  "short": "rHd5",
  "digest": "9275be29095221a448b9678be698551f14ac7779",
  "date": "2017-03-08T01:02:45.621000+00:00",
  "size": 11,
  "uuid": "5dbe3f5b-78f3-4c2b-9965-58f88a0a5da5",
  "label": "f",
  "sunset": "2017-03-08T01:02:45.621000+00:00",
  "status": "created",
  "namespace": "",
  "redirect": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    },
    "long": {
      "type": "string"
    },
    "short": {
      "type": "string"
    },
    "digest": {
      "type": "string"
    },
    "date": {
      "type": "string"
    },
    "size": {
      "type": "number"
    },
    "uuid": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "sunset": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "created",
        "deleted",
        "expired",
        "already exists",
        "found",
        "updated"
      ]
    },
    "namespace": {
      "type": "string",
      "description": "undocumented"
    },
    "redirect": {
      "type": "number"
    }
  },
  "required": [
    "url",
    "long",
    "digest",
    "date",
    "size",
    "status"
  ]
}

create short url
POST/u

This creates a new short url. This creates a special type of paste where the paste content is interpreted as a redirect destination. A GET request for this paste, instead of returning the paste body, will instead return a 301 Moved Permanently response.


syntax highlighting

highlight paste

GET https://fars.ee//id/lexer/formatter?style=
Responses200
Headers
Content-Type: text/html

highlight paste
GET/{id}/{lexer}/{formatter}{?style}

This applys syntax highlighting to the paste content.

URI Parameters
HideShow
id
string (required) 

paste id, any of the long, short, label, or digest attributes

lexer
string (required) 

an alias of a pygments lexer; see list lexers

formatter
string (optional) Default: html 

an alias of a pygments formatter; see list formatters

style
string (optional) Default: default 

an alias of a pygments style; see list styles


list lexers

GET https://fars.ee//l
Responses200
Headers
Content-Type: response/json
Body
[
  [
    "python3",
    "py3"
  ],
  [
    "bash",
    "sh",
    "shell"
  ]
]
Schema
{
  "type": "array",
  "items": {
    "type": "array",
    "items": {
      "type": "string"
    }
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}

list lexers
GET/l

List all available lexer aliases.

These aliases represent a language or type of syntax. This value should match the input paste content.


list formatters

GET https://fars.ee//lf
Responses200
Headers
Content-Type: response/json
Body
[
  [
    "html"
  ],
  [
    "jpg",
    "jpeg"
  ]
]
Schema
{
  "type": "array",
  "items": {
    "type": "array",
    "items": {
      "type": "string"
    }
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}

list formatters
GET/lf

List all available formatter aliases.

These aliases represent different output formats. This value should match the desired presentation format.


list styles

GET https://fars.ee//ls
Responses200
Headers
Content-Type: response/json
Body
[
  "default",
  "pastie"
]
Schema
{
  "type": "array",
  "items": {
    "type": "string"
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}

list styles
GET/ls

List all available style aliases.

These aliases represent different styles. These change the styles and colors applied to each type of syntax element.


paste transforms

render paste markup

GET https://fars.ee//r/id
Responses200
Headers
Content-Type: text/html
Body
<!-- rendered markup -->

render paste markup
GET/r/{id}

The paste or request mimetype is used to determine if the paste content is intended to be interpreted as reStructuredText or Markdown, falling back to reStructuredText if no such data is available, or does not match known mimetypes.

The paste content is then transformed by a reStructuredText or Markdown renderer, accordingly.

URI Parameters
HideShow
id
string (required) 

paste id, any of the long, short, label, or digest attributes


render markup

POST https://fars.ee//r
Requestsjson
Headers
Content-Type: application/json
Body
{
  "content": "An h1 header\n============\n\nParagraphs are separated by a blank line.\n"
}
Responses200
Headers
Content-Type: text/html
Body
<!-- rendered markup -->

render markup
POST/r

This is identical to render paste markup, except the request content is transformed instead of paste content.


render paste terminal session

GET https://fars.ee//t/id
Responses200
Headers
Content-Type: text/html
Body
<!-- asciinema-player -->

render paste terminal session
GET/t/{id}

The paste content is expected to be asciicast json v1. The output is an asciinema-player that is fed the paste content. This is used for playback of terminal recordings.

URI Parameters
HideShow
id
string (required) 

paste id, any of the long, short, label, or digest attributes


render terminal session

POST https://fars.ee//t
Requestsjson
Headers
Content-Type: application/json
Body
{
  "content": "{\"version\": 1, \"width\": 90, \"height\": 57, \"duration\": 2.26401, \"command\": \"/bin/zsh\", \"title\": \"\", \"env\": {\"TERM\": \"rxvt-unicode-256color\", \"SHELL\": \"/bin/zsh\"}, \"stdout\": []}"
}
Responses200
Headers
Content-Type: text/html
Body
<!-- asciinema-player -->

render terminal session
POST/t

This is identical to render paste terminal session, except the request content is transformed instead of paste content.


server metadata

paste statistics

GET https://fars.ee//s
Responses200
Headers
Content-Type: application/json
Body
{
  "pastes": 59226
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "pastes": {
      "type": "number",
      "description": "the number of pastes in the database"
    }
  },
  "required": [
    "pastes"
  ]
}

paste statistics
GET/s

Provides arbitrary interesting paste metadata.


Generated by aglio on 29 Mar 2019