SDKs

The short version

  • Delivr publishes two typed clients: TypeScript and Python. Both call https://api.delivr.ai.
  • Both take the same API key and secret as raw HTTP. Authenticate as in Authentication.
  • Both come from the same API definitions, so a method has the same name in each language.
  • The SDKs do not cover every endpoint. See What the SDKs cover before you pick one.

Install

LanguagePackageInstall
TypeScript@delivrai/sdknpm i @delivrai/sdk
Python (3.9 or later)delivr-sdkpip install delivr-sdk

In Python, import the package as delivr_sdk.

Make a first call

Create a key and secret in the dashboard under Settings > API keys. Then call whoami. It bills nothing and returns the organization and projects the key can reach.

import { Configuration, IdentityApi } from "@delivrai/sdk";

const config = new Configuration({
  apiKey: (header) =>
    header === "X-Api-Key" ? process.env.DELIVR_API_KEY! : process.env.DELIVR_API_SECRET!,
});
const me = await new IdentityApi(config).whoami();
import os
from delivr_sdk import Configuration, IdentityApi
from delivr_sdk.api_client import ApiClient

config = Configuration(api_key={
    "ApiKey": os.environ["DELIVR_API_KEY"],
    "ApiSecret": os.environ["DELIVR_API_SECRET"],
})
me = IdentityApi(ApiClient(config)).whoami()

Keep the key and secret in environment variables or a secret store. Do not put them in browser code.

Names

Each API tag is a class, such as AudiencesApi, IdentityApi, EventsApi, or CampaignsApi. Each operation is a method named after its operationId in the API reference. TypeScript uses camel case, such as getAudienceRecords. Python uses snake case, such as get_audience_records.

Parameters follow the same rule. For example, project_id is projectId in TypeScript and project_id in Python.

Page through audience records

An audience can hold millions of records. Each SDK has a helper that follows next_cursor until the last page. If a page answers 503 with a Retry-After header, the helper waits and retries that page. Every other error reaches your code.

import { AudiencesApi, iterateAudienceRecords } from "@delivrai/sdk";

for await (const row of iterateAudienceRecords(new AudiencesApi(config), {
  id: 4769,
  projectId: "YOUR_PROJECT_ID",
})) {
  console.log(row);
}
from delivr_sdk import AudiencesApi, iter_audience_records

for row in iter_audience_records(AudiencesApi(ApiClient(config)), id=4769, project_id="YOUR_PROJECT_ID"):
    print(row)

For the billing rules of this call, see Paging Audience Records.

What the SDKs cover

The SDKs cover these areas:

  • Sign-in, API clients, whoami, and UID2 conversion
  • Audiences: create, update, delete, clone, refresh, pause, resume, sample, status, download, paged records, and size estimate
  • Campaign reads: list, detail, performance, budget, and match rates
  • Events (v1, v2, and the v3 tier routes), identity lookup, and contact query
  • Exports and integrations
  • Field catalog, taxonomy, and topic requests
  • Intent lookup, discovery, and previews
  • Lists
  • Pixel script, event ingest, and cookie sync
  • Platform management: organizations, projects, pixels, and members

The SDKs do not yet cover these endpoints. Call them over HTTP:

  • Predictive Signals, including the members download
  • Lookalike audiences and audience dependents
  • Suppression notices
  • Billing reads
  • Campaign writes

Each endpoint in the API reference shows a request you can copy.

Versions

The SDKs follow semantic versions. A new endpoint or optional field raises the minor version. A removed or renamed operation raises the major version. Pin the version in your lockfile.


Did this page help you?