API Reference

Simple REST API. No authentication required for basic usage. All responses are JSON.

Base URL

https://petrolabs.me

Rate Limits

Create paste10 requests / minute per IP
Read paste60 requests / minute per IP

Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After

POST/api/paste

Create a new paste.

Request body

{
  "content": string,        // required, max 500KB
  "title":   string,        // optional, max 100 chars
  "language": string,       // optional, default "plaintext"
  "expiresIn": "1h" | "1d" | "7d" | "30d" | "never",
  "isPrivate": boolean,     // hide from recent list
  "burnAfterRead": boolean  // delete after first view
}

Response 201

{
  "id": "abCdEfGhIj",
  "url": "https://petrolabs.me/paste/abCdEfGhIj",
  "expiresAt": 1735689600000,  // null if never
  "createdAt": 1735600000000
}

Example

curl -X POST https://petrolabs.me/api/paste \
  -H "Content-Type: application/json" \
  -d '{
    "content": "console.log(\"Hello, World!\")",
    "language": "javascript",
    "title": "My Paste",
    "expiresIn": "7d"
  }'
GET/api/pastes/:id

Retrieve a paste by ID.

Response 200

{
  "id": "abCdEfGhIj",
  "content": "...",
  "language": "javascript",
  "title": "My Paste",
  "createdAt": 1735600000000,
  "expiresAt": null,
  "views": 42,
  "isPrivate": false,
  "burnAfterRead": false
}

Example

curl https://petrolabs.me/api/pastes/abCdEfGhIj
GET/api/pastes

List 20 most recent public pastes.

Response 200

{
  "pastes": [
    {
      "id": "abCdEfGhIj",
      "title": "My Paste",
      "language": "javascript",
      "createdAt": 1735600000000
    }
  ]
}

Error responses

{
  "error": "Human-readable message",
  "code": "MACHINE_READABLE_CODE"
}
400INVALID_JSON / MISSING_CONTENT / INVALID_EXPIRY
403BOT_DETECTED / SUSPICIOUS_REQUEST
404NOT_FOUND
413CONTENT_TOO_LARGE
429RATE_LIMITED
500SERVER_ERROR

Supported languages

plaintext, javascript, typescript, python, java, c, cpp, csharp, go, rust, php, ruby, swift, kotlin, html, css, json, yaml, xml, bash, sql, markdown, dockerfile