Documentation / API v1
The CasPaste API does not require registration to use it.
Any POST request to the API is sent in application/x-www-form-urlencoded format. Similarly, the API always returns a response to any request in the format application/json and UTF8 encoding.
Table of content
POST /api/v1/new
If you are using a private server, authenticate using "HTTP Basic Authentication". Otherwise you will get a 401 error.
Request parameters:
| Field | Required? | Default | Description |
|---|---|---|---|
title |
Paste title. | ||
body |
Yes | Paste text. | |
lineEnd |
LF |
Line end in the text of the excerpt will automatically be replaced by the one specified by this parameter. Can be LF, CRLF or CR. |
|
syntax |
plaintext |
Syntax highlighting in paste. A list of available syntaxes can be obtained using the getServerInfo method. |
|
oneUse |
false |
If it is true, the paste can be opened only once and then it will be deleted. |
|
expiration |
0 |
Indicates expiration of paste in seconds. If this parameter is 0, the storage time will be unlimited. |
|
author |
Author name. Must not be more than 100 characters. | ||
authorEmail |
Author email. Must not be more than 100 characters. | ||
authorURL |
Author URL. Must not be more than 100 characters. |
Response example:
1{
2 "id": "XcmX9ON1",
3 "url": "https://paste.example.com/XcmX9ON1",
4 "createTime": 1653387358,
5 "deleteTime": 0
6}
Code Examples
cURL
1curl -X POST https://paste.example.com/api/v1/new \
2 -d "title=My Paste" \
3 -d "body=Hello World" \
4 -d "syntax=autodetect" \
5 -d "expiration=3600"
Node.js
1const response = await fetch('https://paste.example.com/api/v1/new', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
4 body: new URLSearchParams({
5 title: 'My Paste',
6 body: 'Hello World',
7 syntax: 'autodetect',
8 expiration: '3600'
9 })
10});
11const data = await response.json();
12console.log('Paste URL:', data.url);
Python
1import requests
2
3response = requests.post('https://paste.example.com/api/v1/new', data={
4 'title': 'My Paste',
5 'body': 'Hello World',
6 'syntax': 'autodetect',
7 'expiration': '3600'
8})
9data = response.json()
10print('Paste URL:', data['url'])
GET /api/v1/get
Request parameters:
| Field | Required? | Default | Description |
|---|---|---|---|
id |
Yes | Paste ID. |
Note: Burn-after-reading pastes (oneUse: true) are automatically deleted after retrieval. The full content is returned and the paste is immediately removed.
Response example:
1{
2 "id": "XcmX9ON1",
3 "title": "Paste title.",
4 "body": "Line 1.\nLine 2.\nLine 3.\n\nLine 5.",
5 "createTime": 1653387358,
6 "deleteTime": 0,
7 "oneUse": false,
8 "syntax": "plaintext",
9 "author": "Anon",
10 "authorEmail": "me@example.org",
11 "authorURL": "https://example.org"
12}
Code Examples
cURL
1curl https://paste.example.com/api/v1/get?id=XcmX9ON1
Node.js
1const response = await fetch('https://paste.example.com/api/v1/get?id=XcmX9ON1');
2const data = await response.json();
3console.log('Body:', data.body);
Python
1import requests
2
3response = requests.get('https://paste.example.com/api/v1/get', params={'id': 'XcmX9ON1'})
4data = response.json()
5print('Body:', data['body'])
GET /api/v1/getServerInfo
Response example:
1{
2 "software": "CasPaste",
3 "version": "1.2",
4 "titleMaxlength": 100,
5 "bodyMaxlength": 20000,
6 "maxLifeTime": -1,
7 "serverAbout": "",
8 "serverRules": "",
9 "serverTermsOfUse": "",
10 "adminName": "Vasya Pupkin",
11 "adminMail": "me@example.org",
12 "syntaxes": [
13 "ABAP",
14 "ABNF",
15 "AL",
16 "ANTLR",
17 "APL",
18 "ActionScript",
19 "ActionScript 3",
20 "Ada",
21 "Angular2",
22 "ApacheConf",
23 "AppleScript",
24 "Arduino",
25 "ArmAsm",
26 "Awk"
27 ],
28 "uiDefaultLifeTime": "1y",
29 "authRequired": false
30}
Code Examples
cURL
1curl https://paste.example.com/api/v1/getServerInfo
Node.js
1const response = await fetch('https://paste.example.com/api/v1/getServerInfo');
2const info = await response.json();
3console.log('Server:', info.software, info.version);
4console.log('Max paste lifetime:', info.maxLifeTime);
Python
1import requests
2
3response = requests.get('https://paste.example.com/api/v1/getServerInfo')
4info = response.json()
5print(f"Server: {info['software']} {info['version']}")
6print(f"Available syntaxes: {len(info['syntaxes'])}")
Possible API errors
This API method exists on the server, but you passed the wrong arguments for it.
1{
2 "code": 400,
3 "error": "Bad Request"
4}
This server requires "HTTP Basic Authentication" authorization.
1{
2 "code": 401,
3 "error": "Unauthorized"
4}
There is no paste with this ID.
1{
2 "code": 404,
3 "error": "Could not find ID"
4}
There is no such API method.
1{
2 "code": 404,
3 "error": "Not Found"
4}
You made a mistake with HTTP request (example: you made POST instead of GET).
1{
2 "code": 405,
3 "error": "Method Not Allowed"
4}
You have exceeded the maximum size of one or more fields (title, body, author, authorEmail, authorURL).
1{
2 "code": 413,
3 "error": "Payload Too Large"
4}
You have made too many requests, try again after some time. The Retry-After HTTP header will also be returned along with this error.
1{
2 "code": 429,
3 "error": "Too Many Requests"
4}
There was a failure on the server. Contact your server administrator to find out what the problem is.
1{
2 "code": 500,
3 "error": "Internal Server Error"
4}