Skip to main content
david-data is the official Python client for the David API. It wraps every endpoint, handles auth and retries, and unwraps responses into plain Python objects.

Install

Requires Python 3.9+.

Authenticate

Pass your key directly, or set the DAVID_DATA_API_KEY environment variable and omit it.

Quickstart

Every data call is keyed by a scenario_id. Pick a scenario from the library, then pull from it.
Methods return parsed JSON with the response envelope removed: a list of records for collections, a dict for single objects.

Set a default scenario

Repeating scenario_id= everywhere gets old. Set it once on the client and omit it; override per call when needed.
Calling a data endpoint with no scenario_id (and no default) raises a clear error instead of guessing.

What you can pull

Dates accept ISO strings ("2024-01-01") or datetime.date objects.

DataFrames

Convert any result to a pandas DataFrame with to_df (needs the [pandas] extra):

Errors & retries

Every exception subclasses DavidDataError. The client automatically retries 429 and transient 5xx responses with exponential backoff (honoring Retry-After); tune with max_retries=.

Escape hatch

Any endpoint not yet wrapped is reachable directly:

Client options