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

bash
x-api-key: <your_api_key>

Get Current User

GET
Base URL / auth/me

Retrieve the currently authenticated user's profile information.

Request

curl
curl -X GET "https://pstr.net/api/auth/me" \
  -H "x-api-key: <your_api_key>"

Response

json
{
  "success": true,
  "user": {
    "id": "123",
    "username": "johndoe",
    "email": "user@example.com",
    "createdAt": "2023-01-01T00:00:00Z"
  }
}

Get Recent Pastes

GET
Base URL / posts/recent/list

Retrieve a list of the most recently created public pastes.

Parameters

limit
query

Number of pastes to return (max 50, default 10)

page
query

Pagination offset (default 1)

Request

curl
curl -X GET "https://pstr.net/api/posts/recent/list?limit=5"

Response

json
{
  "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

GET
Base URL / posts/:id

Retrieve the content and metadata of a specific paste by its ID or custom link.

Parameters

id Required
path

The unique ID or custom link of the paste

Request

curl
curl -X GET "https://pstr.net/api/posts/abc12345"

Response

json
{
  "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

POST
Base URL / posts

Create a new paste. Anonymous pastes are allowed. Send `x-api-key` header to associate with your account.

Parameters

content Required
body

The raw text content of the paste

title
body

Title of the paste

language
body

Programming language (e.g., 'javascript', 'python'). Auto-detected if omitted.

expiresAt
body

ISO 8601 Date string for expiration

customLink
body

Custom URL slug (Premium/Auth only)

password
body

Password for protection (Premium/Auth only)

Request

curl
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

json
{
  "success": true,
  "message": "Post created successfully",
  "post": {
    "id": "abc12345",
    "title": "Untitled Paste",
    "language": "text",
    "url": "https://pstr.net/paste/abc12345"
  }
}