Documentation / API v1
The Lenpaste 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 "createTime": 1653387358,
4 "deleteTime": 0
5}
GET /api/v1/get
Request parameters:
| Field | Required? | Default | Description |
|---|---|---|---|
id |
Yes | Paste ID. | |
openOneUse |
false |
If true, the entire contents of the paste will be returned, after which it will be deleted. If false, the API will return only id and oneUse, and the paste will not be deleted. |
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": "[email protected]",
11 "authorURL": "https://example.org"
12}
1{
2 "id": "5mqqHZRg",
3 "title": "",
4 "body": "",
5 "createTime": 0,
6 "deleteTime": 0,
7 "oneUse": true,
8 "syntax": "",
9 "author": "",
10 "authorEmail": "",
11 "authorURL": ""
12}
GET /api/v1/getServerInfo
Response example:
1{
2 "software": "Lenpaste",
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": "[email protected]",
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}
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}