API Example

Parameters

Parameter Description Location
content Content of the paste, be it text or Markdown. Body (JSON)
edit_code (optional) Custom edit code, else we generate one. Body (JSON)
title (optional) Custom paste title (recommended). Body (JSON)
Token API Secret key for the authentication. Headers

Code

# Basic API example for CREATING a paste.

import requests

TOKEN = "API_SECRET_KEY_HERE"
MESSAGE = '''Your text link, ..., [Markdown](<https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet>) is \\n also *supported*.'''

try:
    response = requests.post(
        "<https://paster.so/api/v3/pastes/markdown>",
        headers={
            "Content-Type": "application/json",
            "Authorization": TOKEN
        },
        json={
            "content": MESSAGE,
            "title": "🎁"
        }
    )
    response_data = response.json()
    paste_data = response_data.get("data", {})

    if paste_data.get("url"):
        print(paste_data["url"])
    else:
        print("Response did not contain a URL:", response_data)
except requests.exceptions.RequestException as e:
    print("Error making the request:", e)