📡 API Documentation

A simple JSON API for creating and managing pastes programmatically.

🔑 Your API Key

Sign in to generate an API key. Guest pastes work without a key.

Overview

All API requests go to https://zpst.net/api.php with an action query parameter.

Responses are always JSON with an ok boolean field. Authenticated requests use the X-API-Key header.

ActionMethodAuthDescription
createPOSTOptionalCreate a new paste
get GET OptionalGet paste metadata + content
raw GET OptionalGet raw paste text only
deleteGET Key or tokenDelete a paste
list GET RequiredList your pastes

CLI Client — zpst

A bash script that wraps the API. Requires curl and python3.

zpst bash · curl · python3
Download .sh

Install

# Download and install
curl -fsSL https://zpst.net/download-client.php -o ~/.local/bin/zpst
chmod +x ~/.local/bin/zpst

# Set your API key (optional, needed for private pastes and list)
mkdir -p ~/.config/pastephp
echo 'PASTEPHP_KEY=your_api_key_here' >> ~/.config/pastephp/config
echo 'PASTEPHP_URL=https://zpst.net' >> ~/.config/pastephp/config

Examples

# Create from text
zpst create "hello world"

# Create from file (title + language auto-detected)
zpst create main.py

# Create with options
zpst create notes.txt --title "My Notes" --lang markdown --expiry 86400 --visibility unlisted

# Pipe into it
echo "SELECT * FROM users;" | zpst create --lang sql

# Create and copy URL to clipboard
zpst create script.sh | xclip -selection clipboard

# View paste content
zpst view aB3xKq

# Save paste to file
zpst download aB3xKq output.py

# Delete (use delete_token shown at creation for guest pastes)
zpst delete aB3xKq
zpst delete aB3xKq your_delete_token

# List your pastes
zpst list

# Show paste metadata
zpst info aB3xKq

Authentication

Pass your API key in the X-API-Key header. Guest usage (no key) is allowed for creating and reading public/unlisted pastes if the site permits it.

curl -H "X-API-Key: your_api_key_here" \
  "https://zpst.net/api.php?action=list"

POST Create Paste

https://zpst.net/api.php?action=create

Accepts JSON body or form POST (application/x-www-form-urlencoded).

Body Parameters

FieldTypeRequiredDescription
content string Paste content
title string NoPaste title
language string NoSyntax language (default: plaintext)
visibilitystring Nopublic · unlisted · private
expiry int NoSeconds: 0 never · 300 · 3600 · 21600 · 86400 · 2592000
password string NoPassword protect the paste
burn bool NoDelete after first view

Example

curl -X POST "https://zpst.net/api.php?action=create" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_key" \
  -d '{
    "content": "print(\"hello world\")",
    "title": "Hello",
    "language": "python",
    "expiry": 3600,
    "visibility": "unlisted"
  }'

Response

{
  "ok": true,
  "slug": "aB3xKq",
  "url": "https://zpst.net/p/aB3xKq",
  "raw_url": "https://zpst.net/raw/aB3xKq",
  "language": "python",
  "visibility": "unlisted",
  "expires_at": "2024-01-01 13:00:00",
  "burn": false,
  "delete_token": "abc123..."
}

Guest pastes include a delete_token — save it to delete the paste later.

GET Get Paste

https://zpst.net/api.php?action=get&slug=<slug>

Returns paste metadata and full content. For password-protected pastes, pass the password via ?password= or the X-Paste-Password header.

curl "https://zpst.net/api.php?action=get&slug=aB3xKq"

# Password protected
curl "https://zpst.net/api.php?action=get&slug=aB3xKq&password=secret"

GET Raw Content

https://zpst.net/api.php?action=raw&slug=<slug>

Returns the paste content as text/plain. Useful for piping directly into other tools.

# Print to terminal
curl "https://zpst.net/api.php?action=raw&slug=aB3xKq"

# Pipe into a command
curl -s "https://zpst.net/api.php?action=raw&slug=aB3xKq" | python3

# Save to file
curl -s "https://zpst.net/api.php?action=raw&slug=aB3xKq" > script.py

GET Delete Paste

https://zpst.net/api.php?action=delete&slug=<slug>&token=<token>

Delete using your API key (owner/admin) or the delete_token returned when a guest paste was created.

# Authenticated delete
curl -H "X-API-Key: your_key" \
  "https://zpst.net/api.php?action=delete&slug=aB3xKq"

# Guest delete with token
curl "https://zpst.net/api.php?action=delete&slug=aB3xKq&token=your_delete_token"

GET List Pastes

https://zpst.net/api.php?action=list

Lists pastes belonging to the authenticated user. Requires an API key.

ParamDefaultDescription
limit 25Results per page (max 100)
offset0 Pagination offset
curl -H "X-API-Key: your_key" \
  "https://zpst.net/api.php?action=list&limit=10&offset=0"

Errors

All errors return "ok": false with an error string and a relevant HTTP status code.

CodeMeaning
400Bad request — missing or invalid parameter
401Password required or wrong password
403Private paste or not authorized to delete
404Paste not found
410Paste has expired
429Rate limit exceeded — check Retry-After header
{ "ok": false, "error": "Paste not found." }