Libraries

Official Trackified clients for TypeScript, Python, Go, Ruby and PHP.

Embed
Preview of the card
<a href="https://trackified.net/docs/libraries"><img src="https://trackified.net/docs/_api/public/orgs/e2a7773e-db9e-41cb-bd59-bd248745cac3/spaces/9d63a5d4-feb0-4803-84a5-dc68639362a6/pages/bbe57e75-4c78-4e5c-af3e-996572de0f90/social-card.svg?v=3e7ae33eec8b" alt="Libraries" width="600" height="315"></a>

Each library wraps the whole API: trackings, carriers, webhooks, webhook deliveries, API keys and usage. They all work the same way, so this page covers what they share. Each language page has install steps and a full example.

The source for each is on GitHub under github.com/trackified.

Client options

Every client reads the API key from TRACKIFIED_API_KEY and the API host from TRACKIFIED_BASE_URL (default https://api.trackified.net). You can pass both in code instead.

Option

TypeScript

Python

Go

Ruby

PHP

Default

API key

apiKey

api_key

WithAPIKey

api_key:

apiKey

TRACKIFIED_API_KEY

Base URL

baseURL

base_url

WithBaseURL

base_url:

baseUrl

TRACKIFIED_BASE_URL, else https://api.trackified.net

Timeout

timeout (ms)

timeout (s)

WithTimeout

timeout: (s)

timeout (s)

30 seconds

Retries

maxRetries

max_retries

WithMaxRetries

max_retries:

maxRetries

2

Request hooks

onRequest, onResponse

on_request, on_response

WithHooks

on_request:, on_response:

onRequest, onResponse

none

A client with no key fails as soon as you create it. The base URL works with or without /v1 at the end. health() checks that the API is up, with no key needed.

New in 0.2: health checks, carrier name resolution, webhook updates and secret rotation, typed events, request hooks and new error classes. See What's new in 0.2.

Retries

Network errors, 408, 429 and 5xx responses are retried with exponential backoff and jitter, starting near half a second and capped at 8 seconds between tries. A 429 waits for the Retry-After header. Other 4xx errors are never retried. See Pagination, retries and idempotency.

Idempotency

trackings.create sends an Idempotency-Key header, a fresh UUID unless you pass your own, and reuses it across that call's retries. A retried create never adds a second tracking.

The libraries send a key on bulk creates too, but the API ignores it there. Don't blindly retry a bulk create that timed out; check what was added first.

Typed errors

Every API error is a subclass of one base error (TrackifiedError) carrying the HTTP status, the error code, the message and the request_id. Catch the subclass you care about: ValidationError (400, 422), AuthenticationError (401), QuotaExceededError (402), PermissionError (403), NotFoundError (404), ConflictError (409), RateLimitError (429, with the retry-after seconds), APIError (5xx) and ConnectionError (no response, with code timeout or connection). After a timeout the outcome is unknown: retry with the same idempotency key. Errors has the full table.

Pagination

list returns one page with data and pagination (limit, offset, total). Each library also has a helper that walks every page for you:

Language

One page

Every page

TypeScript

client.trackings.list()

for await (const t of client.trackings.iterate())

Python

client.trackings.list()

for t in client.trackings.list_auto_paging()

Go

client.Trackings.List(ctx, p)

for t, err := range client.Trackings.All(ctx, p)

Ruby

client.trackings.list.data

client.trackings.list.each

PHP

$client->trackings->list()

foreach ($client->trackings->all() as $t)

Webhook verification

Each library verifies the x-tracking-signature header against the raw request body, rejects signatures more than 5 minutes old, and parses the event. constructEvent (or construct_event, ConstructEvent) returns the event or fails with a reason. verify returns a boolean, and verifyDetailed returns {valid, reason}. Each takes several secrets during a rotation. trackingOf returns the tracking for any event type. See Verifying webhooks.

Method names

TypeScript

Python

Go

Ruby

PHP

Add a tracking

trackings.create

trackings.create

Trackings.Create

trackings.create

trackings->create

Add a batch

trackings.createBulk

trackings.create_bulk

Trackings.BulkCreate

trackings.bulk_create

trackings->bulkCreate

Get

trackings.get

trackings.get

Trackings.Get

trackings.get

trackings->get

Update

trackings.update

trackings.update

Trackings.Update

trackings.update

trackings->update

Stop tracking

trackings.delete

trackings.delete

Trackings.Delete

trackings.delete

trackings->delete

Check again now

trackings.retrack

trackings.retrack

Trackings.Retrack

trackings.retrack

trackings->retrack

Detect a carrier

carriers.detect

carriers.detect

Carriers.Detect

carriers.detect

carriers->detect

Resolve a carrier name

carriers.resolve

carriers.resolve

Carriers.Resolve

carriers.resolve

carriers->resolve

Search the catalog

carriers.search

carriers.catalog

Carriers.Catalog

carriers.catalog

carriers->catalog

Add a webhook

webhooks.create

webhooks.create

Webhooks.Create

webhooks.create

webhooks->create

Update a webhook

webhooks.update

webhooks.update

Webhooks.Update

webhooks.update

webhooks->update

Rotate its secret

webhooks.rotateSecret

webhooks.rotate_secret

Webhooks.RotateSecret

webhooks.rotate_secret

webhooks->rotateSecret

Health

health

health

Health

health

health

Usage

usage.get

usage.get

Usage.Get

usage.get

usage->get

Verify what you installed

Every release is built in GitHub Actions and carries a signed build-provenance attestation.

For the npm package, check the registry signatures and provenance of what's installed:

npm audit signatures

For any release file (a Go, Python, Ruby or PHP package from its GitHub Release, or a CLI archive), check it against the repo that built it:

gh attestation verify trackified-0.1.0.gem --repo trackified/trackified-ruby
Updated