Skip to main content

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. 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.

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

Project details


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.1.tar.gz (28.0 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.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: david_data-0.1.1.tar.gz
  • Upload date:
  • Size: 28.0 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.1.tar.gz
Algorithm Hash digest
SHA256 54c036740930340ce49d967cc5e6b12f4554976a5cf16a9a33dd2a479cbe4154
MD5 cdd4b4d64df6a357f968e4a8f191a482
BLAKE2b-256 de204f818b20cd461ef05050ae1cd6816c2015b699843e58827cc63204646742

See more details on using hashes here.

Provenance

The following attestation bundles were made for david_data-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: david_data-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4582962bbf1c8b901603de57f8573cc2e0b3590ecb148b31d70ed9ec5e008b8
MD5 f931aaf52c1fc118bbc4cd91ffc6195f
BLAKE2b-256 7936121a5f2cb216cf5edc38e88d5904b9abb213d4c0a0b490a0b3c5ea21d1e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for david_data-0.1.1-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.

Supported by

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