FragBin REST API
All endpoints are unauthenticated; edit operations require the editKey issued at creation time. Base URL: https://fragbin.com
Create a Paste
POST /api/pastes
Body (JSON): { title?, content (string, required), language?, expiresAt? ("never"|"1h"|"1d"|"1w"|null), isPrivate?, password? }
curl -X POST https://fragbin.com/api/pastes \
-H "Content-Type: application/json" \
-d '{
"title": "Example",
"content": "console.log("Hello");",
"language": "javascript",
"expiresAt": "1h", # or "never" | "1d" | "1w" | null
"isPrivate": false,
"password": null
}'
# Response 201
# { "id": "<pasteId>", "editKey": "<secretEditKey>" }List Recent Public Pastes
GET /api/pastes (returns up to 50 most recent public, non-expired pastes).
curl https://fragbin.com/api/pastes
# Response 200: [ { id, title, language, createdAt, expiresAt, views, ... }, ... ]Get a Paste (JSON)
GET /api/pastes/:id
If the paste is password protected, supply ?password=PLAINTEXT or the x-edit-key header with the edit key to bypass password.
curl https://fragbin.com/api/pastes/<id>
# or with password
curl "https://fragbin.com/api/pastes/<id>?password=secret"
# or with edit key (also grants access to private/password pastes)
curl -H "x-edit-key: <editKey>" https://fragbin.com/api/pastes/<id>Update a Paste
PUT /api/pastes/:id with JSON body. Include editKey in body. Omit fields you do not wish to change.
curl -X PUT https://fragbin.com/api/pastes/<id> \
-H "Content-Type: application/json" \
-d '{
"editKey": "<editKey>",
"title": "Updated Title",
"content": "# New content",
"password": "newpass" // optional; will be hashed server-side
}'
# Response 200 { "ok": true }Raw Paste Content
GET /api/pastes/raw/:id (alias /r/:id) returns text/plain. Use ?password= or ?key= (edit key) for protected pastes.
# Long form
curl https://fragbin.com/api/pastes/raw/<id>
# Short alias
curl https://fragbin.com/r/<id>
# with password
curl "https://fragbin.com/r/<id>?password=secret"
# with edit key
curl "https://fragbin.com/r/<id>?key=<editKey>"Error Codes
400missing content403password required / invalid edit key404not found413content exceeds 20KB limit405method not allowed500server error
Field Notes
language: used for syntax highlighting; defaults totext.expiresAt: request accepts enum"never" | "1h" | "1d" | "1w" | null(null == never). Responses return computed ISO timestamp ornull.isPrivate: private pastes are excluded from public list & sitemap.password: stored as hash; never returned by API.editKey: keep secret; required for updates, can bypass password protection.
Rate Limits
No formal rate limit currently enforced; please be reasonable. Future revisions may add lightweight IP-based throttling.
Coming Soon
Search Paste by title
A forthcoming endpoint (e.g. GET /api/pastes/search?title=foo) will return matches on title (case-insensitive, partial). This will enable lightweight programmatic discovery of older public pastes without scraping.
Need help or have feedback? Reach out via the contact page.