Skip to main content
The official Python SDK for TrailBase provides a fully-typed client for accessing your TrailBase backend from Python applications.

Installation

Install using pip:
Or using Poetry:

Requirements

  • Python 3.13+
  • httpx
  • PyJWT
  • cryptography

Initialization

Basic Client

Client with Tokens

Custom HTTP Client

Authentication

Login

Logout

Current User

Access Tokens

Record API

List Records

Read a Record

Create a Record

Create Multiple Records

Update a Record

Delete a Record

Filtering

Available Comparison Operators

Real-time Subscriptions

Subscribe to record changes using Server-Sent Events (SSE):

Error Handling

Advanced Usage

Custom Fetch

Streaming Responses

Type Definitions

User

Tokens

ListResponse

RecordId

Async Support

The current Python SDK is synchronous. For async operations, use httpx.AsyncClient and adapt the code accordingly.

Best Practices

Store tokens securely and never commit them to version control.
The client automatically refreshes auth tokens before they expire.
Use context managers or try-finally blocks to ensure proper cleanup of HTTP connections.

Example Application