API Documentation (v1)

Welcome to the Paster.sh REST API v1. Our API allows you to create and manage pastes programmatically from any application, extension, or script. The API is public and does not require authentication, CSRF tokens, or browser sessions.

Key Features:
  • No CSRF Required: Direct access from extensions, curl, and scripts.
  • JSON Responses: Pure programmatic output for easy parsing.
  • Stateless: No cookies or sessions needed.
  • HTTPS Only: All requests must be encrypted for security.

Create Paste

Endpoint: POST https://api.paster.sh/v1/create

Request Parameters

Parameter Type Required Description
content string Yes The paste content (max 512KB)
title string No Paste title (max 255 chars)
visibility string No public, unlisted, or private (default: public)
syntax string No Syntax highlighting language (default: plain)
expiration string No never, 10min, 1hour, 1day, 1week (default: never)

Supported Syntax Languages

plain, javascript, python, html, css, bash, php, sql, json, xml, markdown, java, c, cpp, csharp, ruby, go, rust, typescript

Example Request (cURL)

curl -X POST https://api.paster.sh/v1/create \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hello World from API",
    "title": "My API Paste",
    "syntax": "python",
    "visibility": "public"
  }'

Success Response (JSON)

{
    "success": true,
    "code": "abc123",
    "url": "https://paster.sh/abc123",
    "raw": "https://api.paster.sh/v1/raw/abc123"
}

Get Raw Paste Content

Endpoint: GET https://api.paster.sh/v1/raw/SHORT_CODE

Retrieve the raw content of a paste directly:

curl https://api.paster.sh/v1/raw/abc123

Error Responses

HTTP Code Error Message Reason
400 Content is required The content field is empty or missing
403 HTTPS is required Request made over insecure HTTP
413 Paste exceeds maximum size Content exceeds 512KB
429 Too many requests Rate limit exceeded (5 requests per minute)

Technical Notes

  • IP-Based Rate Limiting: Applied to all API requests to prevent abuse.
  • Statelessness: Do not send Cookie or Referer headers; they are ignored.
  • UTF-8 Encoding: Ensure your content is properly UTF-8 encoded.
  • Integration: Ideal for browser extensions, IDE plugins, and automation scripts.