hapiq — Python library
Python bindings for hapiq, a CLI tool for downloading scientific datasets from GEO, SRA, Zenodo, Figshare, Ensembl, scPerturb, BioStudies, HCA, and VCP with full provenance tracking.
The library implements the HDL (Has Data Locally) pattern: a Dataset object holds your download parameters but only fetches data when you explicitly call fetch(). Repeated calls with skip_existing=True (the default) are instant if the data is already on disk.
Installation
Wheels for Linux (x86_64, aarch64) and macOS 12+ (x86_64, arm64) ship a static
hapiq binary of the same version, so no Go toolchain is required.
pip install hapiq
For development, install from the repo:
cd python/
pip install -e .
Usage
Download a dataset
from hapiq import Dataset
ds = Dataset("geo", "GSE133344", include_ext=[".h5ad", ".csv.gz"])
# Inspect metadata without downloading
print(ds.metadata.title)
print(f"{ds.metadata.file_count} files, {ds.metadata.total_size} bytes")
# Download (skips files already present by default)
paths = ds.fetch("/data/geo/GSE133344")
# → [PosixPath('/data/geo/GSE133344/sample.h5ad'), ...]
Search for datasets
from hapiq import search
results = search("geo", "single cell RNA-seq lung cancer", organism="Homo sapiens")
for r in results:
print(r.accession, r.title)
Full download result with provenance
result = ds.fetch_result("/data/geo/GSE133344")
print(result.witness_file) # path to hapiq.json provenance file
print(result.bytes_downloaded) # bytes transferred this run
for f in result.files:
print(f.path, f.checksum) # SHA-256 per file
Supported sources
| Source | ID format | Search |
|---|---|---|
geo |
GSE123456 |
✓ |
sra |
SRR123456, SRP123456 |
|
zenodo |
10.5281/zenodo.1234567 |
|
figshare |
DOI or article ID | |
ensembl |
species + release | |
scperturb |
dataset name | ✓ |
biostudies |
S-BSST123 |
|
hca |
project UUID | |
vcp |
dataset ID | ✓ |
API reference
Dataset(source, id, **filters)
| Parameter | Type | Default | Description |
|---|---|---|---|
source |
str |
— | Source name (e.g. "geo") |
id |
str |
— | Dataset accession |
include_ext |
list[str] |
None |
Only download files with these extensions |
exclude_ext |
list[str] |
None |
Skip files with these extensions |
max_file_size |
str |
None |
Skip files larger than this (e.g. "500MB") |
filename_pattern |
str |
None |
Glob pattern for filenames |
organism |
str |
None |
Filter by organism (case-insensitive) |
subset |
list[str] |
None |
Download only these sub-accessions |
exclude_raw |
bool |
False |
Skip raw data files (FASTQ, BAM) |
exclude_supplementary |
bool |
False |
Skip supplementary files |
parallel |
int |
8 |
Concurrent downloads |
timeout |
int |
300 |
Per-request timeout in seconds |
limit_files |
int |
0 |
Stop after N files (0 = no limit) |
ds.metadata → Metadata
Cached property. Fetches dataset info (title, file count, organisms, etc.) without downloading any files.
ds.fetch(out_dir, *, resume=False, skip_existing=True, dry_run=False) → list[Path]
Download files, return their local paths. With skip_existing=True (default), files already present are not re-downloaded.
ds.fetch_result(out_dir, *, resume=False, skip_existing=True) → DownloadResult
Like fetch() but returns the full result including checksum info, download stats, and the path to the hapiq.json witness file.
search(source, query, *, organism=None, entry_type=None, limit=0, timeout=60) → list[SearchResult]
Environment variables
| Variable | Effect |
|---|---|
NCBI_API_KEY |
Raises GEO rate limit from 3 → 10 req/s |
VCP_TOKEN |
JWT for private CZI Virtual Cell Platform datasets |
Development
cd python/
pip install -e . # builds hapiq/bin/hapiq; needs Go
pytest tests/ -m "not integration" # unit tests (no network)
pytest tests/ -m integration # integration tests (hits GEO)
HAPIQ_DOWNLOAD_TEST=1 pytest tests/ -m integration # includes actual file download
The bundled binary must report the package version (hapiq/_version.py).
After changing Go code, run pip install -e . again to rebuild it, or delete
hapiq/bin/hapiq to use hapiq from PATH.
TODO
- Async
fetch()variant for use in notebook environments
Metadata
Release files for hapiq 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| hapiq-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details for hapiq-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| hapiq-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details for hapiq-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| hapiq-0.1.3-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details for hapiq-0.1.3-py3-none-macosx_12_0_x86_64.whl |
| hapiq-0.1.3-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details for hapiq-0.1.3-py3-none-macosx_12_0_arm64.whl |
Total release size: 22.9 MB
Release files / hapiq-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | hapiq-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
8c87b0d76a9678b886e04f346b25ed3da0167a5747b16a35803e36dd6bd90bc2
|
|
BLAKE2b-256 checksum How to use checksums |
9ff15ff8bebc7ddb57873fae60eec811e48aa1b5373cd58cdf3f7fa430e9c8b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / hapiq-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | hapiq-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
797bee48a9969fc02803f782f9926c1db8dcfec05b46ede1e15ad355885ae880
|
|
BLAKE2b-256 checksum How to use checksums |
4175face304ef6e48124e26a7a5435765e4a89567f3e9beece041625065c2617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / hapiq-0.1.3-py3-none-macosx_12_0_x86_64.whl
| Download URL | hapiq-0.1.3-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
11d808002a7c1da6fba140ba639b52c9d28d2a972baaa20776a837fd4625697a
|
|
BLAKE2b-256 checksum How to use checksums |
55de20127d56e837b675c6b7c7b9735e9c339fe000db3e8f10ac44e5892d778b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / hapiq-0.1.3-py3-none-macosx_12_0_arm64.whl
| Download URL | hapiq-0.1.3-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6e0fee6bc5eb511edaf516ef9a12ffe950a681cf794f20cfb68ec2d20eae5c1f
|
|
BLAKE2b-256 checksum How to use checksums |
8d04893e4bd0b9576a0e45638011db92c8d21149fa5dcfe596595bfa2c48ddf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for hapiq 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for hapiq-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.