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 ¶
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--Headers
Content-Type: text/plain; charset=utf-8
Vary: Accept
Location: https://ptpb.pw/7Z_uBody
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-58f88a0a5da5Headers
Content-Type: application/json
Accept: application/jsonBody
{
"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"
]
}Headers
Content-Type: application/json
Vary: Accept
Location: https://ptpb.pw/ABgOBB3kOB-3GPA8RA5pfgyn-ooL.jpgBody
{
"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: AcceptBody
{
"status": "no post content"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"status": {
"type": "string"
}
},
"required": [
"status"
]
}create pastePOST/{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.
- 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 ¶
Body
<!-- paste content -->read pasteGET/{id}
Returns paste content for a given paste id.
- id
string(required)paste id, any of the
long,short,label, ordigestattributes
update paste ¶
Headers
Content-Type: application/jsonBody
{
"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"
]
}Headers
Content-Type: application/jsonBody
{
"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/jsonBody
{
"status": "no post content"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"status": {
"type": "string"
}
},
"required": [
"status"
]
}update pastePUT/{id}
Replace paste attributes.
- id
string(required)paste id, the
uuidattribute
delete paste ¶
Headers
Content-Type: application/json
Accept: application/jsonHeaders
Content-Type: application/json
Vary: Accept
Location: https://ptpb.pw/rHd5Body
{
"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: AcceptBody
{
"status": "not found"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"status": {
"type": "string"
}
},
"required": [
"status"
]
}delete pasteDELETE/{id}
This type of deletion will make the paste no longer exist.
- id
string(required)paste id, the
uuidattribute
short url ¶
create short url ¶
Headers
Content-Type: application/jsonBody
{
"content": "https://apiblueprint.org/documentation/mson/specification.html"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"content": {
"type": "string"
}
}
}Headers
Content-Type: application/jsonBody
{
"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 urlPOST/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 ¶
Headers
Content-Type: text/htmlhighlight pasteGET/{id}/{lexer}/{formatter}{?style}
This applys syntax highlighting to the paste content.
- id
string(required)paste id, any of the
long,short,label, ordigestattributes- lexer
string(required)an alias of a pygments lexer; see
list lexers- formatter
string(optional) Default: htmlan alias of a pygments formatter; see
list formatters- style
string(optional) Default: defaultan alias of a pygments style; see
list styles
list lexers ¶
Headers
Content-Type: response/jsonBody
[
[
"python3",
"py3"
],
[
"bash",
"sh",
"shell"
]
]Schema
{
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}list lexersGET/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 ¶
Headers
Content-Type: response/jsonBody
[
[
"html"
],
[
"jpg",
"jpeg"
]
]Schema
{
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}list formattersGET/lf
List all available formatter aliases.
These aliases represent different output formats. This value should match the desired presentation format.
list styles ¶
Headers
Content-Type: response/jsonBody
[
"default",
"pastie"
]Schema
{
"type": "array",
"items": {
"type": "string"
},
"$schema": "http://json-schema.org/draft-04/schema#"
}list stylesGET/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 ¶
Headers
Content-Type: text/htmlBody
<!-- rendered markup -->render paste markupGET/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.
- id
string(required)paste id, any of the
long,short,label, ordigestattributes
render markup ¶
Headers
Content-Type: application/jsonBody
{
"content": "An h1 header\n============\n\nParagraphs are separated by a blank line.\n"
}Headers
Content-Type: text/htmlBody
<!-- rendered markup -->render markupPOST/r
This is identical to render paste markup, except the request content
is transformed instead of paste content.
render paste terminal session ¶
Headers
Content-Type: text/htmlBody
<!-- asciinema-player -->render paste terminal sessionGET/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.
- id
string(required)paste id, any of the
long,short,label, ordigestattributes
render terminal session ¶
Headers
Content-Type: application/jsonBody
{
"content": "{\"version\": 1, \"width\": 90, \"height\": 57, \"duration\": 2.26401, \"command\": \"/bin/zsh\", \"title\": \"\", \"env\": {\"TERM\": \"rxvt-unicode-256color\", \"SHELL\": \"/bin/zsh\"}, \"stdout\": []}"
}Headers
Content-Type: text/htmlBody
<!-- asciinema-player -->render terminal sessionPOST/t
This is identical to render paste terminal session, except the
request content is transformed instead of paste content.
server metadata ¶
paste statistics ¶
Headers
Content-Type: application/jsonBody
{
"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 statisticsGET/s
Provides arbitrary interesting paste metadata.
Generated by aglio on 29 Mar 2019