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?, 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": 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
returns text/plain
. Use ?password=
or ?key=
(edit key) for protected pastes.
curl https://fragbin.com/api/pastes/raw/<id>
# with password
curl "https://fragbin.com/api/pastes/raw/<id>?password=secret"
# with edit key
curl "https://fragbin.com/api/pastes/raw/<id>?key=<editKey>"
Error Codes
400
missing content403
password required / invalid edit key404
not found413
content exceeds 20KB limit405
method not allowed500
server error
Field Notes
language
: used for syntax highlighting; defaults totext
.expiresAt
: ISO timestamp or null; expired pastes are hidden from listings.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.