API Reference · v1

PasteShare API

Ephemeral text over HTTP. No auth, no accounts, no trace — just paste, share, vanish.

Base URL https://paste.dockhub.dev/api/paste
Auth
None
Format
JSON
Max text
50,000 ch
TTL range
1m – 1hr
In-memory storage — pastes live only while the serverless instance is warm. For production persistence, swap the Map for Upstash Redis.
POST /api/paste Create a new paste
Request body
FieldTypeRequiredDescription
text string required Paste content. Max 50,000 characters.
ttl number optional Time-to-live in milliseconds. Min 60000, max 3600000. Default 600000 (10 min).
Example — fetch
fetch('https://paste.dockhub.dev/api/paste', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    text: 'hello world',
    ttl:  600000  // 10 min
  })
})
Example — cURL
curl -X POST https://paste.dockhub.dev/api/paste \
  -H "Content-Type: application/json" \
  -d '{"text":"hello world","ttl":600000}'
Response 200
{
  "id":        "abc12345",
  "url":       "/p/abc12345",
  "expiresAt": 1749999999000,
  "expiresIn": 600000
}
Responses
200 OKPaste created.
400 Bad Requesttext missing / exceeds 50k chars, or ttl out of range.
GET /api/paste?id={id} Read a paste
Query params
ParamTypeRequiredDescription
id string required The paste ID from the POST response.
Example — fetch
fetch('https://paste.dockhub.dev/api/paste?id=abc12345')
Example — cURL
curl 'https://paste.dockhub.dev/api/paste?id=abc12345'
Response 200
{
  "id":          "abc12345",
  "text":        "hello world",
  "createdAt":   1749999399000,
  "expiresAt":   1749999999000,
  "remainingMs": 598240
}
Response 410 — Expired
{
  "error":   "expired",
  "message": "This paste has expired."
}
Response 404 — Not found
{
  "error":   "not_found",
  "message": "Paste not found or already expired."
}
Responses
200 OKPaste found and returned.
404 Not FoundNo paste with this ID.
410 GonePaste existed but TTL has elapsed.
OPTIONS /api/paste CORS preflight

Handled automatically by the browser before cross-origin requests. You never need to call this manually. CORS is fully open — call the API from any frontend without a proxy.

Response headers
Access-Control-Allow-Origin:  *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
Responses
204 No ContentPreflight accepted. No body.
StatuserrorWhen
400 bad_request Missing/empty text, exceeds 50,000 chars, or ttl outside 60,000–3,600,000 ms.
404 not_found ID doesn't exist or was never created.
410 expired Paste existed but TTL has elapsed.
405 method_not_allowed HTTP method other than GET, POST, OPTIONS.
JavaScript — create & read
// 1. Create a paste (expires in 5 min)
const res = await fetch('https://paste.dockhub.dev/api/paste', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ text: 'secret note', ttl: 300000 })
});
const { id } = await res.json();

// 2. Read it back
const paste = await fetch(`https://paste.dockhub.dev/api/paste?id=${id}`)
  .then(r => r.json());

console.log(paste.text);        // 'secret note'
console.log(paste.remainingMs);  // ~299xxx ms
Python
import requests

# Create
r = requests.post(
    "https://paste.dockhub.dev/api/paste",
    json={"text": "hello from python", "ttl": 600000}
)
paste_id = r.json()["id"]

# Read
data = requests.get(
    "https://paste.dockhub.dev/api/paste",
    params={"id": paste_id}
).json()
print(data["text"])        # 'hello from python'
print(data["remainingMs"])  # ms until expiry