PasteDB Python SDK
Project description
PasteDB Python SDK
Official Python SDK for interacting with the PasteDB API.
Supports:
- Create and manage pastes
- Explore public pastes
- Semantic vector search
- Star system
- Collections
- Markdown rendering
- Code execution
- API key management
- Analytics
Installation
pip install pastedb
Quick Start
import pastedb
client = PasteDBClient(
api_key="YOUR_API_KEY"
)
paste = client.create_paste(
title="Hello World",
content="print('Hello')",
syntax="python"
)
print(paste)
Initialize Client
from client import PasteDBClient
client = PasteDBClient(
api_key="YOUR_API_KEY"
)
Parameters
Parameter| Type| Description api_key| str| Your PasteDB API key base_url| str| Custom API URL
Paste Methods
create_paste()
Create a new paste.
paste = client.create_paste(
title="Example",
content="print('Hello')",
syntax="python"
)
Parameters
Parameter| Type| Default| Description title| str| Required| Paste title content| str| Required| Paste content syntax| str| plaintext| Syntax language visibility| str| public| public/private/unlisted expiration| str| never| Expiration time password| str| None| Password protection tags| list| []| Tags list
get_paste()
Get a paste by ID.
paste = client.get_paste("abc123")
edit_paste()
Edit an existing paste.
client.edit_paste(
"abc123",
title="Updated Title"
)
You can update:
- title
- content
- syntax
- visibility
- tags
- expiration
delete_paste()
Delete a paste.
client.delete_paste("abc123")
fork_paste()
Create a copy of an existing paste.
forked = client.fork_paste("abc123")
raw()
Get raw paste text.
raw = client.raw("abc123")
print(raw)
Search Methods
search()
Search public pastes.
results = client.search(
query="fastapi auth",
syntax="python"
)
Parameters
Parameter| Type| Description query| str| Search query syntax| str| Filter by language user| str| Filter by user tags| list| Filter by tags
vector_search()
Semantic vector search powered by MongoDB Vector Search.
results = client.vector_search(
"dark animated navbar"
)
Finds similar pastes by meaning instead of exact keywords.
Explore Methods
explore()
Get explore page pastes.
pastes = client.explore()
trending()
Get trending pastes.
trending = client.trending()
latest()
Get latest public pastes.
latest = client.latest()
popular()
Get most popular pastes.
popular = client.popular()
Star Methods
star()
Toggle star on a paste.
client.star("abc123")
If already starred, it removes the star.
Analytics Methods
paste_stats()
Get analytics for a paste.
stats = client.paste_stats("abc123")
Example response:
{
"views": 120,
"copies": 30,
"shares": 12,
"stars": 9
}
User Methods
me()
Get current authenticated user.
user = client.me()
user_pastes()
Get public pastes from a user.
pastes = client.user_pastes("aditya")
user_starred()
Get starred pastes from a user.
starred = client.user_starred("aditya")
Collection Methods
create_collection()
Create a collection.
collection = client.create_collection(
name="Frontend Snippets",
description="Useful frontend snippets"
)
add_to_collection()
Add paste to collection.
client.add_to_collection(
collection_id="123",
paste_id="abc123"
)
get_collection()
Get collection details.
collection = client.get_collection("123")
Code Runner Methods
run()
Execute code.
result = client.run(
language="python",
code="print('Hello')"
)
supported_languages()
Get supported execution languages.
languages = client.supported_languages()
Markdown Methods
render_markdown()
Render markdown into HTML.
html = client.render_markdown(
"# Hello World"
)
API Key Methods
create_api_key()
Create API key.
key = client.create_api_key(
"My Application"
)
get_api_keys()
Get all API keys.
keys = client.get_api_keys()
delete_api_key()
Delete API key.
client.delete_api_key("key123")
Error Handling
The SDK raises "PasteDBError" when requests fail.
from client import PasteDBClient, PasteDBError
try:
client = PasteDBClient(
api_key="INVALID"
)
client.me()
except PasteDBError as e:
print(e)
Example Project
from client import PasteDBClient
client = PasteDBClient(
api_key="YOUR_API_KEY"
)
paste = client.create_paste(
title="Quick Sort",
content="print('Sorting')",
syntax="python",
tags=["algorithm", "python"]
)
print("Created:", paste)
stats = client.paste_stats(
paste["id"]
)
print(stats)
Features
- Clean Python API
- Easy authentication
- Semantic search
- Code execution
- Collections support
- Markdown rendering
- Analytics support
- API key management
- Fast integration
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pastedb-1.0.12.tar.gz.
File metadata
- Download URL: pastedb-1.0.12.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1800bfb50c71478f0b827bf4b5893d849519c4cfc68f700d52d297156f55fa86
|
|
| MD5 |
21b972e01ea0ee89093498ed2e59a35c
|
|
| BLAKE2b-256 |
374423cf8aa2089d88990d0b5dd72514ba6bb123dfbb29927a96ee39bd5000a5
|
Provenance
The following attestation bundles were made for pastedb-1.0.12.tar.gz:
Publisher:
publish.yml on sorathiya903/pastedb-package-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pastedb-1.0.12.tar.gz -
Subject digest:
1800bfb50c71478f0b827bf4b5893d849519c4cfc68f700d52d297156f55fa86 - Sigstore transparency entry: 1561949913
- Sigstore integration time:
-
Permalink:
sorathiya903/pastedb-package-python@a62ba4703c58032c3dacaf5cd55b150e5dcaf89d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sorathiya903
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a62ba4703c58032c3dacaf5cd55b150e5dcaf89d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pastedb-1.0.12-py3-none-any.whl.
File metadata
- Download URL: pastedb-1.0.12-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f49f0e5a83e40abb66bf5535b85fde82ab9c8b2ee5aafd0411197ca7af663ddf
|
|
| MD5 |
28c2f37fb41718025316f285021c17da
|
|
| BLAKE2b-256 |
6c880ad575ae627f1f348514bf34937f7d399947e7b02e7e0002f51eb4f8ee23
|
Provenance
The following attestation bundles were made for pastedb-1.0.12-py3-none-any.whl:
Publisher:
publish.yml on sorathiya903/pastedb-package-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pastedb-1.0.12-py3-none-any.whl -
Subject digest:
f49f0e5a83e40abb66bf5535b85fde82ab9c8b2ee5aafd0411197ca7af663ddf - Sigstore transparency entry: 1561950077
- Sigstore integration time:
-
Permalink:
sorathiya903/pastedb-package-python@a62ba4703c58032c3dacaf5cd55b150e5dcaf89d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sorathiya903
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a62ba4703c58032c3dacaf5cd55b150e5dcaf89d -
Trigger Event:
push
-
Statement type: