Rmly's Pastebin
Easily share text online
API Documentation
Hello and welcome to the API Documentation! This page provides detailed information on how to interact with our API along with some examples.
Fun fact: This website is also interacting with the API :)
Endpoints
Here are the API endpoints along with the request methods and with their parameters.
Wait! Before we get to that, we should know some general information about the API that applies to all endpoints, right?
-
The base URL of the API is:
https://paste-api.rmly.dev
- All endpoints exclusively accept JSON bodies.
Okay! Now let's get to the endpoints:
-
POST
/createPaste
- creates a paste- Max requests: 50 in 10 minutes
-
name
- the paste name (optional)
Accepts:[a-Z, A-Z, 0-9]
Length:<=50
Default:[randomAdjective]-[randomNoun]-[randomNumber]
-
password
- the paste password (optional)
Accepts:any
Length:<=32
Default:null
(The paste has no password) -
content
- the paste content (required)
Accepts:any
Length:<=100.000
-
token
- whether or not to generate a token (optional)
Accepts:true / false
Default:false
-
expiresIn
- when the paste will expire from now (optional)
Accepts:one-time / 1d / 1w / 1mo
Default:null
(the paste will never expire)
-
POST
/generateToken
- generates a temporary token for a passworded paste- Max requests: 100 in 10 minutes
-
id
- the paste id (required)
Accepts:UUIDv4
-
authorization
- authorization to view paste (required, request header)
Accepts:[pastePassword]
-
GET
/getPaste
- gets a paste- Max requests: 100 in 10 minutes
-
id
- the paste id (required, URL query param)
Accepts:UUIDv4
-
authorization
- authorization to view paste (required if paste passworded, request header)
Accepts:[pastePassword]
orBearer [pasteToken]
-
GET
/getPasteInfo
- gets information about a paste- Max requests: 100 in 10 minutes
-
id
- the paste id (required, URL query param)
Accepts:UUIDv4
-
GET
/getPublicPastes
- gets the public pastes- Max requests: 100 in 10 minutes
-
page
- the page number (required, URL query param)
Accepts:[pageNumber]
Examples
How about some examples?
Creating a paste in JavaScript using the Fetch API:
async function createPaste(name, content, password, expiresIn) {
const requestBody = {
name: name,
content: content,
password: password,
expiresIn: expiresIn,
token: false,
}
const requestConfig = {
method: 'post',
body: JSON.stringify(requestBody),
headers: {
'Content-Type': 'application/json',
},
}
try {
const response = await fetch(
'https://paste-api.rmly.dev/createPaste',
requestConfig
)
const result = await response.json()
if (!response.ok) {
console.error('Error creating paste:', result)
return
}
console.log('Paste created successfully:', result)
} catch (e) {
console.error('Error creating paste:', e)
}
}
const pasteName = 'myNewPaste'
const pasteContent = 'Hello, World!'
const pastePassword = 'MySuperSecretPassword'
const pasteExpiresIn = '1d'
createPaste(pasteName, pasteContent, pastePassword, pasteExpiresIn)
The code above creates a paste named
myNewPaste
. It includes the content
Hello, World!
, a password of
MySuperSecretPassword
, and an expiration set to 1 day.
Example response:
Paste created successfully: {
status: 'success',
id: '1cc107a2-ac32-47ac-a35b-312450170020',
name: 'myNewPaste',
passworded: true,
createdAt: '2023-08-09T13:25:34.931Z',
expiresAt: '2023-08-10T13:25:34.931Z'
}
Getting a paste in JavaScript using the Fetch API:
async function getPaste(id, password) {
const requestConfig = {
headers: {
'Content-Type': 'application/json',
Authorization: password,
},
}
try {
const response = await fetch(
`https://paste-api.rmly.dev/getPaste?id=${id}`,
requestConfig
)
const result = await response.json()
if (!response.ok) {
console.error('Error getting paste:', result)
return
}
console.log('Got paste successfully:', result)
} catch (e) {
console.error('Error getting paste:', e)
}
}
const pasteId = '1cc107a2-ac32-47ac-a35b-312450170020'
const pastePassword = 'MySuperSecretPassword'
getPaste(pasteId, pastePassword)
The code above retrieves a paste with the ID
1cc107a2-ac32-47ac-a35b-312450170020
and uses the password
MySuperSecretPassword
.
Example response:
Got paste successfully: {
status: 'success',
id: '1cc107a2-ac32-47ac-a35b-312450170020',
name: 'myNewPaste',
createdAt: '2023-08-09T13:25:34.000Z',
expiresAt: '2023-08-10T13:25:34.931Z',
content: 'Hello, World!'
}