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")

Iteration Helpers

Iterate through your snippets (single page only).

# Iterate snippets
for snippet in api.ls_iter(include_deleted=True):
    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, include_deleted=False) — List your snippets.
  • api.ls_iter(limit=20, include_deleted=False) — Iterator for listing snippets (single page).
  • api.user(uid) — List another user's public snippets.
  • api.find(q) — Search snippets.
  • api.find_iter(q) — Iterator for searching snippets (single page).
  • 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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tp_sdk-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 876b69a01dc87f3c3224273588ae3d1faf43c345ed65aad60f42baa86d8a5547
MD5 29aa9f754686eb788fc9714c88737c83
BLAKE2b-256 6d6051f884cc308f7479502442c203ed87f6791eda41f7a1d4f284c90b6f965d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tp_sdk-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: tp_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3590966d1bf137b37bdd06164847493737e7cb5ecaf1dc21d61cbda65e4e062
MD5 fae98cedd1f535f87606ec3721cdc09f
BLAKE2b-256 1860837ca7fc0d73579a6fa7f6ef835f2fe20196a8e4bf58242e4bfa325db7f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tp_sdk-0.2.1-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