Quickstart
Base path: /api/v1. For local development, use http://localhost:3000, and replace the domain with your service URL in production. All v1 requests require the header Authorization: Bearer <key>.
curl "http://localhost:3000/api/v1/codes?limit=20" \
-H "Authorization: Bearer $TRYCODE_API_KEY"Keep the key on your server or in an environment variable. Do not put it in browser JavaScript or a public repository.
Limits and views
Per-key limits per minute: 120 reads, 10 creates, and 60 updates or deletes. Counters are independent. Responses include X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. On a 429 response, wait the seconds specified in Retry-After.
Reading another public post through GET /api/v1/public/codes/{id} increments the view count and uses the configured limit. Reading your own post does not count. Password-protected posts can be opened in the web editor; API v1 returns 423 for them.
API keys
Create a key for your current account. Without signing in, it is linked to this guest browser; after GitHub sign-in, your posts and keys move to the account. A key can change only your posts and read the public catalog. Guest key management depends on this browser's cookie.
Your API keys
A key gives access to your posts through the REST API
Loading keys…
API endpoints
All endpoints return JSON. Your posts and public posts are paginated in groups of 20; pass nextCursor in the cursor parameter to get the next page.
/api/v1/codesList your posts/api/v1/codesCreate post/api/v1/codes/{id}Get your post/api/v1/codes/{id}Update content and settings/api/v1/codes/{id}Delete your post/api/v1/public/codesFind public posts/api/v1/public/codes/{id}Read a public postRequest examples
Create post
Add a title, language, and content, and optionally publish the post.
curl -X POST "http://localhost:3000/api/v1/codes" \
-H "Authorization: Bearer $TRYCODE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"sum.ts","language":"typescript","content":"const sum = (a: number, b: number) => a + b;","isPublic":true}'Update post
Send only the fields you want to change. Content updates in open editors too.
curl -X PATCH "http://localhost:3000/api/v1/codes/ABC123" \
-H "Authorization: Bearer $TRYCODE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content":"const sum = (a: number, b: number) => { return a + b; };","maxViews":100}'Find public posts
Filter the catalog by title and language. The preview field is null.
curl "http://localhost:3000/api/v1/public/codes?q=sum&language=typescript" \
-H "Authorization: Bearer $TRYCODE_API_KEY"Responses and errors
A create or read response contains a record. Lists return data and nextCursor. Timestamps and expiresAt use Unix time in milliseconds.
{
"record": {
"id": "ABC123",
"title": "sum.ts",
"language": "typescript",
"content": "const sum = (a: number, b: number) => a + b;",
"isPublic": true,
"allowOthersToEdit": false,
"canEdit": true,
"isOwner": true,
"passwordProtected": false,
"expiresAt": null,
"maxViews": null,
"burnAfterRead": false,
"viewCount": 0,
"createdAt": 1795046400000,
"updatedAt": 1795046400000
}
}Errors use the format {"error":{"code":"not_found","message":"Post not found"}}. Common statuses: