Pstr API
Welcome to the Pstr API documentation. Our API allows you to programmatically create, retrieve, and manage pastes. Whether you're building a CLI tool, an IDE plugin, or just automating your workflow, we've got you covered. You can authenticate requests using API Keys generated in your User Settings.
Authentication
Most read operations are public. To create pastes under your account or access premium features (like custom links and password protection), you need to authenticate using an API Key.
You can generate an API Key in your Account Settings. Include it in the `x-api-key` header of your requests.
Example Header
x-api-key: <your_api_key> Get Current User
GETRetrieve the currently authenticated user's profile information.
Request
curl -X GET "https://pstr.net/api/auth/me" \
-H "x-api-key: <your_api_key>" Response
{
"success": true,
"user": {
"id": "123",
"username": "johndoe",
"email": "user@example.com",
"createdAt": "2023-01-01T00:00:00Z"
}
} Get Recent Pastes
GETRetrieve a list of the most recently created public pastes.
Parameters
Number of pastes to return (max 50, default 10)
Pagination offset (default 1)
Request
curl -X GET "https://pstr.net/api/posts/recent/list?limit=5" Response
{
"success": true,
"posts": [
{
"uniqueId": "abc12345",
"title": "My Script",
"language": "javascript",
"views": 42,
"createdAt": "2023-10-27T10:00:00Z"
}
],
"pagination": {
"total": 100,
"page": 1,
"pages": 10
}
} Get a Paste
GETRetrieve the content and metadata of a specific paste by its ID or custom link.
Parameters
The unique ID or custom link of the paste
Request
curl -X GET "https://pstr.net/api/posts/abc12345" Response
{
"success": true,
"post": {
"uniqueId": "abc12345",
"title": "My Script",
"content": "console.log('Hello World');",
"language": "javascript",
"isPublic": true,
"views": 43,
"createdAt": "2023-10-27T10:00:00Z"
}
} Create a Paste
POSTCreate a new paste. Anonymous pastes are allowed. Send `x-api-key` header to associate with your account.
Parameters
The raw text content of the paste
Title of the paste
Programming language (e.g., 'javascript', 'python'). Auto-detected if omitted.
ISO 8601 Date string for expiration
Custom URL slug (Premium/Auth only)
Password for protection (Premium/Auth only)
Request
curl -X POST "https://pstr.net/api/posts" \
-H "Content-Type: application/json" \
-H "x-api-key: <your_api_key>" \
-d '{
"title": "My New Paste",
"content": "console.log(\"Hello World\");",
"language": "javascript"
}' Response
{
"success": true,
"message": "Post created successfully",
"post": {
"id": "abc12345",
"title": "Untitled Paste",
"language": "text",
"url": "https://pstr.net/paste/abc12345"
}
}