Official Python client for the David Data financial-data API (api.davidhf.com).
Project description
David Data — Python SDK
Official Python client for the David Data financial-data
API (https://api.davidhf.com). One consistent interface for real market
data and synthetic scenarios — prices, fundamentals, filings, news,
earnings, analyst & insider data, 13F holdings, and macro series.
pip install david-data # core (httpx only)
pip install david-data[pandas] # + DataFrame helpers
Quickstart
Every data call is keyed by a scenario_id — a synthetic world. Pick one,
then pull data from it.
from david_data import DavidData
dd = DavidData(api_key="sk_...") # or set DAVID_DATA_API_KEY
# 1. Find a scenario
scenario = dd.scenarios.list(limit=1)[0]
sid = scenario["id"]
print(scenario["name"])
# 2. Pull data from it
bars = dd.prices.get("AAPL", scenario_id=sid, start_date="2024-01-01")
income = dd.financials.income_statements("AAPL", scenario_id=sid, period="quarterly", limit=5)
news = dd.news.list(ticker="AAPL", scenario_id=sid, limit=10)
print(bars[0]) # {'ticker': 'AAPL', 'open': ..., 'close': ..., 'volume': ...}
Repeating scenario_id= on every call gets old — set it once on the client and
omit it thereafter:
dd = DavidData(api_key="sk_...", scenario_id=sid)
dd.prices.get("AAPL") # uses the client default
dd.prices.get("AAPL", scenario_id="other-world") # override per call
Calling a data endpoint with no scenario_id (and no client default) raises a
clear error instead of guessing.
Set the key once via the environment and you can skip the argument entirely:
export DAVID_DATA_API_KEY="sk_..."
from david_data import DavidData
dd = DavidData()
Returns
Methods return parsed JSON — a list of record dicts for collection endpoints,
a dict for single-object endpoints — exactly like the underlying API, with the
envelope unwrapped for you (dd.prices.get(...) gives you the list of bars
directly). Convert any result to a DataFrame:
from david_data import to_df
df = to_df(dd.prices.get("AAPL", start_date="2024-01-01"))
Scenarios
A scenario is a self-contained synthetic world with its own universe of companies, prices, fundamentals, filings, and events. Browse what's available, or generate new ones:
for s in dd.scenarios.list(limit=10):
print(s["id"], "-", s["name"])
# Inspect one
dd.scenarios.get(sid)
dd.scenarios.manifest(sid) # tickers, date range, coverage
# Generate your own
created = dd.scenarios.create(start_date="2024-01-01", ticker_count=25)
What you can pull
| Group | Examples |
|---|---|
dd.prices |
get, snapshot, market_snapshot, tickers |
dd.financials |
income_statements, balance_sheets, cash_flow_statements, metrics, segments, as_reported, kpi_metrics, screener, line_items |
dd.company |
list, facts, tickers, ciks |
dd.news / dd.filings |
list, get / list, items, types |
dd.earnings / dd.analyst |
list, calendar / estimates, notes |
dd.insiders / dd.institutional |
trades, transactions / holdings, investors |
dd.index_funds / dd.corporate_actions |
list |
dd.macro |
series, interest_rates, banks |
dd.events |
timeline |
dd.scenarios |
list, get, manifest, create, bulk_generate, generate_library |
dd.metadata |
sectors, scenario_themes, scale_presets, … |
Dates accept either ISO strings ("2024-01-01") or datetime.date objects.
Errors & retries
All exceptions subclass DavidDataError. HTTP failures map to specific types:
from david_data import DavidData, NotFoundError, RateLimitError
dd = DavidData()
try:
dd.prices.get("AAPL")
except RateLimitError as e:
print("slow down; retry after", e.retry_after)
except NotFoundError:
print("no such ticker / scenario")
The client automatically retries 429 and transient 5xx responses with
exponential backoff (honouring Retry-After); tune with max_retries=.
Escape hatch
Any endpoint not yet wrapped is reachable directly:
dd.get("/metadata/institutional-readiness")
dd.post("/financials/search/screener", json={"scenario_id": "real", "filters": [...]})
Anything else
with DavidData() as dd: ...closes the connection pool on exit.- Bring your own
httpx.Clientviahttp_client=for proxies/custom transport. - Full endpoint reference: https://api.davidhf.com/docs
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file david_data-0.1.0.tar.gz.
File metadata
- Download URL: david_data-0.1.0.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
569985a5bcf4716053d82455ccc731ad24210176463572adcee620e8efd62ff7
|
|
| MD5 |
5b033c2f5a14a8dcd4e53d9d9c2d1c78
|
|
| BLAKE2b-256 |
cd55a8a4f129a0f01988807e016b21a21bea8ba904e674cca6362a33c09e9140
|
Provenance
The following attestation bundles were made for david_data-0.1.0.tar.gz:
Publisher:
publish.yml on David-Hedgefund/david-data-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
david_data-0.1.0.tar.gz -
Subject digest:
569985a5bcf4716053d82455ccc731ad24210176463572adcee620e8efd62ff7 - Sigstore transparency entry: 1943716950
- Sigstore integration time:
-
Permalink:
David-Hedgefund/david-data-python@ba463e0de681f0f6b5084be3f903faa4b5fa21fb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/David-Hedgefund
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ba463e0de681f0f6b5084be3f903faa4b5fa21fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file david_data-0.1.0-py3-none-any.whl.
File metadata
- Download URL: david_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b56f4f9d8b51710aac2f5eeeeecc168b137c5814e1b0b2196d5d73972f55c21d
|
|
| MD5 |
2ed740209acbc9e9a2f12db4ee5b81e8
|
|
| BLAKE2b-256 |
1389718e1ad0a2648f99d133cf1f8f0c9e20bd1136df506486164e56ae26fd83
|
Provenance
The following attestation bundles were made for david_data-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on David-Hedgefund/david-data-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
david_data-0.1.0-py3-none-any.whl -
Subject digest:
b56f4f9d8b51710aac2f5eeeeecc168b137c5814e1b0b2196d5d73972f55c21d - Sigstore transparency entry: 1943717106
- Sigstore integration time:
-
Permalink:
David-Hedgefund/david-data-python@ba463e0de681f0f6b5084be3f903faa4b5fa21fb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/David-Hedgefund
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ba463e0de681f0f6b5084be3f903faa4b5fa21fb -
Trigger Event:
release
-
Statement type: