Skip to main content
The Python SDK runs on Python 3.11 and newer and uses only the standard library.
Set these two values once in your terminal. Every example in these docs reads them, so no example has a host or a key typed into it.
Use a test key (it starts with tf_test_) while you build. Never paste a live key into a page, a ticket or a chat.

Create a client

base_url defaults to the production API. The first argument is an organization key, a teammate token, or a function that returns one. Keep organization keys on your servers.

Typed calls

Every operation in the API reference is a method named after it, with typed parameters and a typed answer (TypedDicts generated from the reference).

Pagination

paginate follows next_cursor and yields each item of a list.

Send events

tf.events.send checks every event before it sends anything, gives each event that needs one an idempotency key, and splits a long list into requests within the API’s limits. The builders are on Observation builders.

Errors

Every error answer raises a class named for its code, and every one extends TechnicallyFitError with code, message, status, request_id and details. A code this version does not know raises a plain TechnicallyFitError.

Retries and rate limits

The client sends a request again after a 429, and after a network failure, 500, 502, 503 or 504 when sending it again cannot change the outcome (reads, updates, and the event endpoints, whose events carry their own keys). It waits the Retry-After the API sent, or until the rate-limit window resets, or backs off with jitter. It never retries another 4xx.
A Retry-After longer than max_retry_after (60 seconds by default) is not waited out: the call raises RateLimitError with retry_after_seconds, so you can schedule the work.

Page through events

Use paginate to walk through paged endpoints such as GET /v1/events until next_cursor is None:

Sign a teammate in from a member app

A member app holds a teammate token, never an organization key. The SDK runs the sign-in flow and gives you a credential that refreshes itself. The issuer is the authorization server you configure.
When the refresh token no longer works (the teammate left, signed out or the app was turned off), calls raise TeammateSignedOutError: send the person back to sign-in.