Skip to main content

epidatpy

License: MIT Github Actions PyPi Read the Docs

The Python client for the Delphi Epidata API.

Install

Install with the following commands:

# Latest dev version
pip install "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"

# PyPI version
pip install epidatpy

Usage

from epidatpy import CovidcastEpidata, EpiDataContext, EpiRange

# All calls using the `epidata` object will now be cached for 7 days
epidata = EpiDataContext(use_cache=True, cache_max_age_days=7)

# Obtain a DataFrame of the most up-to-date version of the smoothed covid-like illness (CLI)
# signal from the COVID-19 Trends and Impact survey for the US
epidata.pub_covidcast(
    data_source="jhu-csse",
    signals="confirmed_cumulative_num",
    geo_type="nation",
    time_type="day",
    geo_values="us",
    time_values=EpiRange(20210405, 20210410),
).df()

CAST API (snapshot / archive)

The CAST API exposes versioned signals (NSSP, pophive, NWSS, ...). Use epidata_snapshot for a single as-of view, epidata_archive for the full report-time history, or epidata to dispatch between them.

from epidatpy import EpiDataContext, EpiRange

epidata = EpiDataContext()

# Source-level metadata (signals, geo_types, available date ranges).
epidata.epidata_meta(source="nssp")

# Latest snapshot of a signal (omit `snapshot_date` to fetch the newest version).
epidata.epidata_snapshot(
    source="nssp",
    signals="pct_ed_visits_influenza",
    geo_type="state",
    geo_values="ca,ny",
    reference_time=EpiRange("2025-01-01", "2025-06-01"),
).df()

# Full report-time history, filtered to report_times on or before 2025-10-16.
epidata.epidata_archive(
    source="nssp",
    signals="pct_ed_visits_influenza",
    geo_type="state",
    report_time="<2025-10-16",
).df()

# Router: pass `report_time` (or `snapshot_date="*"`) for archive, `snapshot_date` for snapshot.
epidata.epidata(
    source="nssp",
    signals="pct_ed_visits_influenza",
    geo_type="state",
    report_time=EpiRange("2025-01-01", "2025-10-16"),
).df()

geo_values, reference_time, and an EpiRange report_time lower bound are filtered locally after the request.

Development

The following commands are available for developers:

make install        # setup venv, install dependencies and local package
make test           # run unit tests
make format         # format code
make lint           # check linting
make doc            # build docs
make doc-preview    # preview docs in browser
make release        # build distribution packages
make upload         # upload the current version to pypi
make clean          # clean build and docs artifacts

Release Process

dev is the only long-lived branch; each release line lives on a rel-X.Y branch. Everything is driven by the create_release workflow, run with a bump of major, minor, or patch:

  • major / minor: bumps the version on dev, cuts a new rel-X.Y branch at that commit, and tags vX.Y.0.
  • patch (hotfix): bumps the patch version on an existing rel-X.Y branch and tags vX.Y.Z. Land the fix on that branch first (commit directly or cherry-pick from dev); set release_branch to pick the branch (defaults to the line matching dev's version).

Either way the workflow creates a GitHub release with auto-generated notes. Pushing the vX.Y.Z tag then triggers pypi_publish (build + upload to PyPI) and documentation (docs rebuild). Because publishing is a separate workflow keyed off the tag rather than a step inside create_release, a failed PyPI upload can be re-run against the existing tag via the pypi_publish workflow's Run workflow button — without redoing the release cut.

Download files

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

Source Distribution

epidatpy-0.6.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

epidatpy-0.6.0-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file epidatpy-0.6.0.tar.gz.

File metadata

  • Download URL: epidatpy-0.6.0.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for epidatpy-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d91db226b46926b2e7cc622a4b4d943026cfb9669eae06ef18622c68a213ba6a
MD5 545dd472194980e335969c8951330182
BLAKE2b-256 f5380ae916e8cad859c3c7181c33ffa55141781a79a857c2eaf4334f2505b730

See more details on using hashes here.

Provenance

The following attestation bundles were made for epidatpy-0.6.0.tar.gz:

Publisher: pypi_publish.yml on cmu-delphi/epidatpy

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

File details

Details for the file epidatpy-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: epidatpy-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for epidatpy-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecf19f0c76cc4ba4c9ce86e56d590d3f837e306f20fa177e4d59bc5901948043
MD5 a12158fd4454cadb9ca6acd8c8e9be98
BLAKE2b-256 316bc36d9ec83d758ef0c1371eeded8ab11df1e848243eba800e67b0fa628dc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for epidatpy-0.6.0-py3-none-any.whl:

Publisher: pypi_publish.yml on cmu-delphi/epidatpy

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.6.0 This release

2 files

0.5.1

2 files

0.5.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page