Skip to main content

Python SDK for TeaserPaste API - Simple, Typed, and Fun.

Project description

TeaserPaste Python SDK

Official Python SDK for TeaserPaste API. Simple, typed, and ready for the Teaserverse.

Installation

# Using uv (Recommended)
uv add tp-sdk

# Using pip
pip install tp-sdk

Quick Start

Standard (Sync)

import tp

# Context Manager (Recommended for connection pooling)
with tp.TeaserPaste("YOUR_API_KEY") as api:
    # Create a new paste
    note = api.paste(tp.SnippetInput(
        title="Teaserverse Logs", 
        content="System status: All green.",
        expires=tp.Expiry.HOUR_1
    ))
    print(f"Created: {note.id}")

    # Get a paste
    data = api.get(note.id)
    print(data.content)

Async (AsyncIO)

import asyncio
import tp

async def main():
    async with tp.AsyncTeaserPaste("YOUR_API_KEY") as api:
        note = await api.get("xyz_123")
        print(note.title)

asyncio.run(main())

Features

Connection Pooling

The SDK now supports Context Manager usage (using with statement) to reuse HTTP connections, significantly improving performance for multiple requests.

Type Hints & Enums

Improved type safety for arguments and Models.

# Use Enum for expiry
from tp import Expiry
api.paste(tp.SnippetInput(..., expires=Expiry.WEEK_1))

# Explicit arguments for edit (IDE autocompletion enabled)
api.edit(snippet_id, title="New Title", visibility="private")

Pagination Helpers

Iterate through all your snippets without handling offsets manually.

# Lazy load all snippets
for snippet in api.ls_iter():
    print(snippet.title)

API Reference

"One-word" API's. Both Sync and Async clients support these methods.

  • api.paste(input) — Create a new snippet.
  • api.get(id, pwd=None) — Get a snippet.
  • api.edit(id, title=..., ...) — Update a snippet.
  • api.kill(id) — Soft delete a snippet.
  • api.live(id) — Restore a deleted snippet.
  • api.fork(id) — Copy a snippet to your account.
  • api.star(id, on=True) — Star (or unstar) a snippet.
  • api.ls(limit=20, skip=0) — List your snippets.
  • api.ls_iter(limit=20) — Iterator for listing snippets.
  • api.user(uid) — List another user's public snippets.
  • api.find(q) — Search snippets.
  • api.find_iter(q) — Iterator for searching snippets.
  • api.me() — Get your account info.

Configuration

You can configure the base URL via environment variable TP_BASE_URL or passing base_url to the constructor.

Development

# Install dependencies
uv sync

# Build
uv build

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tp_sdk-0.2.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tp_sdk-0.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file tp_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: tp_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tp_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9f44aeae1cccb53fe828ca3b3e674ac82a9384f93e3c63879ade3b410edf69d1
MD5 c1d8ccb15a4e39428676e934f3611e0c
BLAKE2b-256 add22d3057502f176c9353b11dd35caf5d1b0b26a5dfba44f96140279b001f70

See more details on using hashes here.

Provenance

The following attestation bundles were made for tp_sdk-0.2.0.tar.gz:

Publisher: publish.yml on TeaserPaste/tp-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tp_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tp_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tp_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0016b341cfa3e3e5fc7f61e7ec014c7dfd00267169c8cb4b1fa30c2bd24dd209
MD5 6c7cebcd476a457ebe631a5865f3c5b0
BLAKE2b-256 6941b3d77878eec184223fab70d22aea307bda2e5ef7b4cdf0ddc2411b9a54f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tp_sdk-0.2.0-py3-none-any.whl:

Publisher: publish.yml on TeaserPaste/tp-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page