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?

Okay! Now let's get to the endpoints:

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!'
}