Skip to main content

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. David builds and curates the library; browse it and pull data from any scenario:

for s in dd.scenarios.list(limit=10):
    print(s["id"], "-", s["name"])

# Inspect one
dd.scenarios.get(sid)
dd.scenarios.validation(sid)        # data-integrity report

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, validation
dd.metadata sectors, scenario_themes, …

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

Point-in-time (no look-ahead): every dated endpoint takes a cutoff so you only see what was public as of a date. Use as_of on prices.snapshot, news.list, analyst.estimates, earnings.list, insiders.transactions, kpi_guidance, and corporate_actions.list; use report_period_lte on the statement and metric views (financials.*, financials.metrics, kpi_metrics, kpi_non_gaap). Use news.list(market_only=True) for just the market/macro coverage.

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.Client via http_client= for proxies/custom transport.
  • Full endpoint reference: https://api.davidhf.com/docs

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

david_data-0.1.2.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

david_data-0.1.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file david_data-0.1.2.tar.gz.

File metadata

  • Download URL: david_data-0.1.2.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for david_data-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8c7c33091d09a47227ea86dacfe155d46464aaad314ec5fe9e4cf66245ef8d7d
MD5 ce88fca6f26ed3620c8804010c383f12
BLAKE2b-256 a23de7c4fecba966b3d63b92ad1cec43f031f95abe902cb247243e5d78368d9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for david_data-0.1.2.tar.gz:

Publisher: publish.yml on David-Hedgefund/david-data-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file david_data-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: david_data-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for david_data-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ddda9e64cef76fefb38d6a072819dde85170b28a5861cf35a37bf1cc29b0a28f
MD5 bd4a3bd7a9eea96eb326190aae8962aa
BLAKE2b-256 dec01e10c6d4e03a790d518e83fe7ac7975dc841837d4d044ce7cf8c5420b797

See more details on using hashes here.

Provenance

The following attestation bundles were made for david_data-0.1.2-py3-none-any.whl:

Publisher: publish.yml on David-Hedgefund/david-data-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page