This document assumes a base URL of /api/<version>
.
Version | Status |
---|---|
v1 |
Current, stable |
v0 |
Deprecated |
Note that on paste.gg, the base URL is https://api.paste.gg/<version>
.
Get the most recent public pastes.
limit
(u8
): number of pastes to fetch (default:5
)
{
"status": "success",
"result": [
{
"id": "abc123",
// (optional)
"name": "paste name!",
// (optional)
"description": "my paste has all the cool stuff",
"visibility": "public"
}
// and so on
]
}
Standard error. See POST /pastes
.
Create a new paste.
-
Content-Type
(required):application/json
-
Authorization
(optional):Key <api_key>
Providing the Authorization header will create a paste using your account. To make an anonymous paste, do not include this header.
If this header is not included, a deletion key will be generated and returned in order to delete anonymous pastes. Provide this key instead of an API key to the delete method.
{
// (optional) name of the paste
"name": "my files",
// (optional) description (tagline) of the paste
// this must be less than or equal to 255 extended grapheme clusters and less than 25 KiB
"description": "these are my files!",
// (optional) the visibility of the paste
// can be any one of the following (* is default)
// public - publicly available and not hidden from crawlers
// *unlisted - publicly available to anyone with the link, hidden from crawlers
// private - only visible to the authed user creating the paste
"visibility": "public",
// (optional) the expiration date of the paste
// must be a UTC ISO 8601 string
// pastes do not expire by default
"expires": "2018-07-14T14:07:00Z",
// (required – at least one file) array of files to add to the paste
"files": [
{
// (optional) name of the file
// if not specified, pastefile1, pastefile2, etc.
"name": "file_1.txt",
// (required) the content of the file
// all files must have content in a given format
"content": {
// formats are listed below
// text - valid utf-8 text
// base64 - base64 of the uncompressed content
// gzip - base64 of the gzip-compressed content
// xz - base64 of the xz-compressed content
// (required) the format of the file
// specify that the content field is valid utf-8 text
"format": "text",
// (optional) the syntax highlighting language to use
// if not specified or null, the web UI will autodetect which language to use based on
// extension
"highlight_language": null,
// (required) the value of the file contents
// content of the file as valid utf-8 text
"value": "Hello!"
}
},
{
"name": "file_2.jpg",
"content": {
// specify that the content field is base64-encoded data
"format": "base64",
// content of the jpg in base64 (truncated here)
"content": "/9j/4AAQSkZJRgABAQAAAQABAAD//gA7..."
}
}
]
}
{
// status of creating the paste
// always one of success or error (tagged enum)
"status": "success",
"result": {
// id of the created paste
"id": "abcdef1234",
"name": "my files",
"description": "these are my files!",
"visibility": "public",
"created_at": "2018-10-15T16:02:47.114287Z",
"updated_at": "2018-10-15T16:02:47Z",
// only present if the paste expires
"expires": "2018-07-14T14:07:00Z",
"files": [
{
"highlight_language": null,
"id": "ghijkl5678",
"name": "file_1.txt"
},
{
"highlight_language": null,
"id": "mnopqr9012",
"name": "file_2.jpg"
}
],
// (optional) key to use when deleting this paste, if this paste was made anonymously
"deletion_key": "ghijkl5678"
}
}
{
// status of creating the paste
// always one of success or error (tagged enum)
"status": "error",
// error key
"error": "invalid_json",
// (optional) error message
"message": "oh noes"
}
Deletes an existing paste.
-
Authorization
(required):Key <api_key/deletion_key>
The key used must be linked to the account that owns the paste.
If the paste was anonymous, use its deletion key (returned when creating the paste) instead of an API key.
No content
Standard error (see POST /pastes
)
Update an existing paste.
-
Content-Type
(required):application/json
-
Authorization
(required):Key <api_key>
The API key must be linked to the user that created the paste.
Anonymous pastes cannot be update.
A metadata object with all fields optional.
Omit a field to leave it untouched, set a field to null to unset it, and set a field to any other value to update it.
Fields that can be unset:
- name
- description
Fields that cannot be unset:
- visibility
{
// remove the name
"name": null,
// set or update the description
"description": "henlo"
// visibility is not specified and therefore not modified
}
No content
Standard error (see POST /pastes
)
Get an existing paste.
-
full
(bool
):true
orfalse
(default:false
)Includes the contents of files if
true
.
-
Authorization
(optional):Key <api_key>
An API key is only necessary when viewing a private paste. The key must be linked to the account that created the private paste.
{
"status": "success",
"result": {
"id": "abc123",
"name": "my files",
"description": "these are my files!",
"visibility": "public",
"created_at": "2018-10-15T16:05:15.784217Z",
"updated_at": "2018-10-15T16:05:15Z",
// only present if the paste expires
"expires": "2018-07-14T14:07:00Z",
"files": [
{
"id": "def456",
"name": "file_1.txt",
"highlight_language": null,
// only included if the query param `full` is `true`
"content": {
"format": "text",
"value": "Hello!"
}
},
{
"id": "ghi789",
"name": "file_2.jpg",
"highlight_language": null,
// only included if the query param `full` is `true`
"content": {
"format": "base64",
"content": "/9j/4AAQSkZJRgABAQAAAQABAAD//gA7..."
}
}
]
}
}
Standard error (see POST /pastes
)
Get an existing paste's files.
-
Authorization
(optional):Key <api_key>
An API key is only necessary when viewing a private paste. The key must be linked to the account that created the private paste.
{
"status": "success",
"result": [
{
"id": "def456",
"name": "file_1.txt"
},
{
"id": "ghi789",
"name": "file_2.jpg"
}
]
}
Standard error (see POST /pastes
)
Get one file from an existing paste.
-
Authorization
(optional):Key <api_key>
An API key is only necessary when viewing a private paste. The key must be linked to the account that created the private paste.
{
"status": "success",
"result": {
"id": "def456",
"name": "file_1.txt",
"highlight_language": null,
"content": {
"format": "text",
"value": "Hello!"
}
}
}
Standard error (see POST /pastes
)
Update files on an existing paste.
-
Authorization
(required):Key <api_key>
The API key provided must be linked to the account that created the paste being modified.
An array of file objects.
If a file object has an ID field, it will update that file. If no ID field is present, a new file will be added.
When updating a file, all fields are optional, and the name can be unset.
When creating a new file, the content
field is required.
[
{
// update a file by specifying its ID
"id": "abcdef1234",
// remove the file's name (will turn into "pastefile#")
"name": null
// set the highlight language to rust
"highlight_language": "rust"
// content is not modified, since no content field was included
},
{
// create a new file by omitting an ID
"content": {
"format": "text",
"value": "hello!"
}
}
]
No content.
Standard error (see POST /pastes
)
Create a new file in an existing paste.
-
Authorization
(required):Key <api_key>
The API key provided must be linked to the account that created the paste being modified.
A new file object, as specified in POST /pastes
.
The file created with no content field.
{
"status": "success",
"result": {
"id": "abc123",
"name": "henlo birb"
}
}
Standard error (see POST /pastes
)
Update an existing file in an existing paste.
-
Authorization
(required):Key <api_key>
The API key provided must be linked to the account that created the paste being modified.
One file object with all fields optional. This takes exactly the same object for updating a file as specified in PATCH /pastes/<id>/files
.
No content.
Standard error (see POST /pastes
)
Get one file from an existing paste.
-
Authorization
(optional):Key <api_key>
An API key is only necessary when viewing a private paste. The key must be linked to the account that created the private paste.
{
"status": "success",
"result": {
"id": "def456",
"name": "file_1.txt",
"highlight_language": null,
"content": {
"format": "text",
"value": "Hello!"
}
}
}
Standard error (see POST /pastes
)
Delete an existing file in an existing paste.
-
Authorization
(required):Key <api_key>
The API key provided must be linked to the account that created the paste being modified.
No content.
Standard error (see POST /pastes
)
Get the raw content of an existing file in an existing paste.
-
Authorization
(required):Key <api_key>
The API key provided must be linked to the account that created the paste being modified.
The raw content of the file.
Standard error (see POST /pastes
)