PasteDB Python SDK
Official Python SDK for PasteDB — FastAPI powered text and image sharing platform.
Installation
pip install pastedb
Authentication
Get your API key from PasteDB Dashboard → API Keys.
export PASTEDB_API_KEY="pdb_xxxxxxxxxxxx"
ME
● Me()
from pastedb import Client
client = Client(api_key="pdb_xxxxxxxxxxxxx")
print(client.me())
Response if API key is valid
{
'email': 'your@email.com',
'created_at': '2026-06-21T05:26:34.361000' # Dummy
}
Quick Start
from pastedb import Client
# Initialize client - reads PASTEDB_API_KEY env var or pass api_key
client = Client(api_key="pdb_xxxxxxxxxxxxx")
# Create a paste - pass data as dict
paste = client.create_paste({
"content": "print('Hello from PasteDB!')",
"title": "Hello World",
"syntax": "python"
})
print(paste["id"]) # abc123
Core API Methods
The SDK methods mirror the FastAPI backend routes. All data is passed as dictionaries and responses are returned as dictionaries.
1. Create Paste
POST /pastes
from pastedb import Client
"content": "Your text here",
"title": "My Paste",
"syntax": "javascript"
})
# Private paste with password
paste = client.create_paste({
"content": "Secret data",
"visibility": "private",
"password": "mySecret123"
})
# Custom URL + expiry
paste = client.create_paste({
"content": "Temporary data",
"custom_id": "temp-data-2024",
"expiration": "1d",
"syntax": "json"
})
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
content |
str | Yes | Paste content |
title |
str | No | Default: Untitled |
syntax |
str | No | Default: text |
visibility |
str | No | public or private, default public |
password |
str | No | Password for private/public pastes |
custom_id |
str | No | Custom slug for URL |
expiration |
str | No | 1h, 1d, 7d, 30d, never |
Response
{
"id": "abc123",
"title": "My Paste",
"content": "Your text here",
"syntax": "javascript",
"visibility": "public",
"created_at": "1781262330.906314"
}
OR
{
'status': 'success',
'id': '6a378ece819c1a9b62472339',
'custom_id': None
}
2. Get Paste
GET /pastes/{paste_id}
client = Client()
# Get by ID
paste = client.get_paste("abc123")
# Get by custom slug
paste = client.get_paste("my-custom-url")
# Get private paste - pass password in params
paste = client.get_paste("secret123", params={"password": "mySecret123"})
print(paste["title"])
print(paste["content"])
4. Update Paste
PATCH /pastes/{paste_id}
client = Client()
paste = client.update_paste("abc123", {
"title": "Updated Title",
"content": "New content here",
"syntax": "markdown"
})
5. Delete Paste
DELETE /pastes/{paste_id}
client = Client()
client.delete_paste("abc123")
7. Get Analytics
GET /pastes/{paste_id}/analytics
client = Client()
stats = client.get_analytics("abc123")
print(stats["views"]) # 142
print(stats["unique_visitors"]) # 89
Error Handling
The SDK raises requests.HTTPError for API errors. Status codes match FastAPI:
from pastedb import Client
from requests import HTTPError
client = Client(api_key="pdb_live_xxx")
try:
paste = client.get_paste("invalid-id")
except HTTPError as e:
if e.response.status_code == 404:
print("Paste not found")
elif e.response.status_code == 401:
print("Invalid API key")
elif e.response.status_code == 403:
print("Password required")
else:
print(f"API error: {e}")
Client Configuration
from pastedb import Client
client = Client(
api_key="pdb_live_xxx", # Optional, uses env var if None
base_url="https://api.pastedb.netlify.app", # Override default
)
FastAPI Backend Reference
Your backend routes use these FastAPI dependencies:
from fastapi import FastAPI, HTTPException, Depends, Query, Cookie, Request, status, Response
The SDK handles auth via Authorization: Bearer <api_key> header or cookies.
Examples
CLI Upload
import sys
from pastedb import Client
client = Client()
content = sys.stdin.read()
paste = client.create_paste({"content": content, "title": "CLI Paste"})
print(paste["url"])
Usage: cat file.py | python paste.py
Supported Syntax
text, python, javascript, typescript, json, yaml, markdown, html, css, sql, bash, c, cpp, java, go, rust, php, ruby, swift, kotlin, and many more.
License
MIT License
Built with ❤️ using FastAPI
Metadata
Release files for pastedb 1.0.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pastedb-1.0.18.tar.gz | 4.6 kB | With provenance | Details for pastedb-1.0.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pastedb-1.0.18-py3-none-any.whl | Python 3 | none | any | Details for pastedb-1.0.18-py3-none-any.whl |
Total release size: 9.7 kB
Release files / pastedb-1.0.18.tar.gz
| Download URL | pastedb-1.0.18.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43ffbd77c5a8ff4200d1f4b0ed497cccd7173b58c0299869acbcf3e2409f65d2
|
|
BLAKE2b-256 checksum How to use checksums |
0979adfb0868082aa1fbf37fed18d4346ddfbd8576427998f52510d7c5700554
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logRelease files / pastedb-1.0.18-py3-none-any.whl
| Download URL | pastedb-1.0.18-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70150a970cd524aa856ea94db87161284daa092f3d705ea161c94deb53e0d7a1
|
|
BLAKE2b-256 checksum How to use checksums |
6300483ff45a298a8cada0037d61aa5de8b5f3e19c1f46d7b0203008dd8dff65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logSecurity for pastedb 1.0.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pastedb-1.0.18.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.