Skip to main content

Datahugger API doc

Python version

This module provides a unified interface to resolve, crawl, and download datasets exposed over HTTP-like endpoints. A key design goal is that dataset crawling can be consumed both synchronously and asynchronously using the same API.

Overview

  • Resolve a dataset from a URL
  • Crawl its contents as a stream of entries (files or directories)
  • Download and validate dataset contents using a blocking API backed by an async runtime

DOIResolver

Resolves Digital Object Identifiers (DOIs) to their target URLs using the DOI resolution service (e.g. https://doi.org/<doi>).

from datahugger import DOIResolver

doi_resolver = DOIResolver(timeout=30)

url = doi_resolver.resolve("10.34894/0B7ZLK", False)
assert url == "https://dataverse.nl/citation?persistentId=doi:10.34894/0B7ZLK"

# or for multiple resolving in one call
urls = doi_resolver.resolve_many(
    ["10.34894/0B7ZLK", "10.17026/DANS-2AC-ETD6", "10.17026/DANS-2BA-UAVX"], False
)

Parameters

  • doi or list of doi in resolve_many The DOI to resolve (e.g. "10.1000/xyz123"). The https://doi.org/ prefix should not be included.

  • follow_redirects Whether HTTP redirects should be followed.

    • True: Returns the final landing page URL (default).
    • False: Returns the first redirect target.

Core Concepts

DirEntry

Represents a directory in the dataset.

@dataclass
class DirEntry(Entry):
    path_crawl_rel: pathlib.Path
    root_url: str
    api_url: str

Fields

  • path_crawl_rel Path of the directory relative to the dataset root.

  • root_url Root URL of the dataset this directory belongs to.

  • api_url API endpoint used to query the directory contents.

FileEntry

Represents a file in the dataset.

@dataclass
class FileEntry(Entry):
    path_crawl_rel: pathlib.Path
    download_url: str
    size: int | None
    checksum: list[tuple[str, str]]
    TODO <- here the mimetype will be added.

Fields

  • path_crawl_rel Path of the file relative to the dataset root.

  • download_url URL from which the file can be downloaded.

  • size File size in bytes, if known.

  • checksum List of checksum pairs (algorithm, value) (e.g. ("sha256", "...")).

ZipEntry

Represents a ZIP archive entry in the dataset. A ZipEntry is a container object that describes a downloadable archive file and the files contained within it.

@dataclass
class ZipEntry(Entry):
    download_url: str
    size: int | None
    checksum: list[tuple[str, str]]
    version: str | None
    creation_date: str | None
    last_modification_date: str | None
    files: list[FileInZipEntry]

Fields

  • download_url URL from which the ZIP archive can be downloaded.

  • size Size of the ZIP archive in bytes, if known.

  • checksum List of checksum pairs (algorithm, value) (e.g. ("sha256", "...")) used to verify archive integrity.

  • version Optional version identifier of the archive.

  • creation_date Optional creation timestamp of the archive.

  • last_modification_date Optional last modification timestamp of the archive.

  • files List of files contained inside the ZIP archive. Each entry describes a file within the archive (path, size, checksum, and optional metadata such as mimetype).

Iteration Model

SyncAsyncIterator[T]

A protocol that allows a single object to be used as both a synchronous and an asynchronous iterator.

class SyncAsyncIterator(Protocol[T]):
    def __aiter__(self) -> AsyncIterator[T]: ...
    async def __anext__(self) -> T: ...
    def __iter__(self) -> Iterator[T]: ...
    def __next__(self) -> T: ...

This enables APIs that can be consumed in either context without duplication.

Dataset

The central abstraction representing a remote dataset.

class Dataset:
    def crawl(self) -> SyncAsyncIterator[FileEntry | DirEntry | ZipEntry]: ...
    def crawl_file(self) -> SyncAsyncIterator[FileEntry]: ...
    def download_with_validation(
        self, dst_dir: pathlib.Path, limit: int = 0, includes = None, excludes = None,
    ) -> int: ...
    def id(self) -> str: ...
    def root_url(self) -> str: ...

Dataset.crawl()

def crawl(self) -> SyncAsyncIterator[FileEntry | DirEntry | ZipEntry]

Returns a stream of dataset entries (optional type that can be either DirEntry or FileEntry).

The returned object supports both:

Synchronous iteration

for entry in dataset.crawl():
    print(entry)

Asynchronous iteration

async for entry in dataset.crawl():
    print(entry)

Entries are yielded as either DirEntry or FileEntry.

Dataset.download_with_validation()

def download_with_validation(
    self, dst_dir: pathlib.Path, limit: int = 0, includes = None, excludes = None,
) -> int

Downloads files in the dataset into the given directory and validates them using the provided checksums.

  • This is a blocking call.
  • Internally backed by a Rust async runtime.
  • Intended for use from synchronous Python code.

Parameters

  • dst_dir Destination directory for downloaded files.

  • limit Maximum number of files to download. 0 means no limit.

Dataset.root_url()

def root_url(self) -> str

Returns the dataset’s root URL.

Resolving a Dataset

resolve

def resolve(url: str, /) -> Dataset

Resolves a dataset from a given URL.

Example

dataset = resolve("https://example.com/dataset")

The returned Dataset can then be crawled or downloaded.

Example Usage

Crawl a dataset synchronously

dataset = resolve("https://example.com/dataset")

for entry in dataset.crawl():
    if isinstance(entry, FileEntry):
        print("File:", entry.path_crawl_rel)
    elif isinstance(entry, DirEntry):
        print("Dir:", entry.path_crawl_rel)
    elif isinstance(entry, ZipEntry):
        print("Zip:", entry)

Crawl a dataset asynchronously

dataset = resolve("https://example.com/dataset")

async for entry in dataset.crawl():
    print(entry)

Download a dataset

dataset = resolve("https://example.com/dataset")
dataset.download_with_validation(dst_dir=pathlib.Path("./data"))

Metadata

Release files for datahugger-ng 0.6.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for datahugger-ng 0.6.9
File Actions
datahugger_ng-0.6.9-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for datahugger_ng-0.6.9-cp310-abi3-win_amd64.whl
datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_x86_64.whl
datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_i686.whl CPython 3.10 abi3 Linux musl 1.2+ x86-32 Details for datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_i686.whl
datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_armv7l.whl CPython 3.10 abi3 Linux musl 1.2+ ARMv7l Details for datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_armv7l.whl
datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_aarch64.whl
datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_x86_64.whl
datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_ppc64le.whl CPython 3.10 abi3 Linux glibc 2.28+ PowerPC 64-le Details for datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_ppc64le.whl
datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_i686.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-32 Details for datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_i686.whl
datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_armv7l.whl CPython 3.10 abi3 Linux glibc 2.28+ ARMv7l Details for datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_armv7l.whl
datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_aarch64.whl
datahugger_ng-0.6.9-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for datahugger_ng-0.6.9-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 70.0 MB

Release files / datahugger_ng-0.6.9-cp310-abi3-win_amd64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-win_amd64.whl
Size 3.9 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5f4a44e0387ecd1617e543ace9a9ef43dfd8865aee47ddff02673a96f9a90daa
BLAKE2b-256 checksum
How to use checksums
ee509fed226a129353c02d419e5963a933e8b4f1fcb22744fbfc1c790b968475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_x86_64.whl
Size 7.4 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
01740da8f42e9e0ab508dec4c5008f3a789097f81e52f991accfb486d14bbdde
BLAKE2b-256 checksum
How to use checksums
99059151381b236c80c7f1755e3b00d056b7fe2e092b4b9912c34bdb8c2930f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_i686.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_i686.whl
Size 6.9 MB
Tags CPython 3.10 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
759bbd149a8f7274577786adb5c0055f675cecd4bb028a9a8733f6a32395b385
BLAKE2b-256 checksum
How to use checksums
36e5e83551c1edbd049fe7328bc3ce19850f216a4dfd08136d2bf217c1cbc910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_armv7l.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_armv7l.whl
Size 6.3 MB
Tags CPython 3.10 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
a1f23f67f344d4d6b4b6c6e0a2e7ac4f82ccfa3fc7d9e503e0e577d7d59b0efa
BLAKE2b-256 checksum
How to use checksums
2811d6233c7e8e6bfd95116050fd0a9a04107de662037538e5e0325d200048a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-musllinux_1_2_aarch64.whl
Size 7.5 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2294c7f8afad82a3c9d957c396c3db2b8c1fc4ae9c08600a5e50f596491bdc47
BLAKE2b-256 checksum
How to use checksums
5adc05748d209fb0f6366d2df2727467666b87600d4fd406692a6cc8d9586222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_x86_64.whl
Size 6.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
84cb02c2a5cafb4b53b7240c3c7721feafebc77e1dace576f77833d233dd256c
BLAKE2b-256 checksum
How to use checksums
30baa829d7785a5951a6675b0bdec1bb61beb1d6894fcffb246ba594cfa9c389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_ppc64le.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_ppc64le.whl
Size 7.3 MB
Tags CPython 3.10 Linux glibc 2.28+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
0744ea61fb972cf15c976481012475d1dddab43b48492026903cae06c21e3e38
BLAKE2b-256 checksum
How to use checksums
2865e6f1c1be1a9588f69e368aa352ed0853a592d3ce66faac03676d86f6f51a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_i686.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_i686.whl
Size 6.4 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-32 abi3
SHA-256 checksum
How to use checksums
62952803282ed6ed945a13d27615bd96c692dbe181817fd18c98a353635e5af2
BLAKE2b-256 checksum
How to use checksums
60d37a8d959793451d7d325c26ce3078143b850df4bfdc42622c16dcd8bcc627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_armv7l.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_armv7l.whl
Size 6.1 MB
Tags CPython 3.10 Linux glibc 2.28+ ARMv7l abi3
SHA-256 checksum
How to use checksums
264ff29e20150dd6c1c736a0a02e2d6c093ea43ea7db9980b797a0c6ed80f81e
BLAKE2b-256 checksum
How to use checksums
6f29c6de240239a5e39a799b420b9dff6ab6ad01cff4f5600f068834e382d565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-manylinux_2_28_aarch64.whl
Size 7.2 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
60e3754ce36a2a834b84150d38c04d8781265df8760fbda8215f15801af530f2
BLAKE2b-256 checksum
How to use checksums
1ab803993002ba052cc80f451b45ca5eb3635f8c0346614fad759104b772ba13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / datahugger_ng-0.6.9-cp310-abi3-macosx_11_0_arm64.whl

Download URL datahugger_ng-0.6.9-cp310-abi3-macosx_11_0_arm64.whl
Size 4.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
830b014d27a130256f3433f88da3655af06e9044ee2975e25c14fb2dd0e0197f
BLAKE2b-256 checksum
How to use checksums
79230a943ea9f5fd90722f27a2694788486a42c7eb0b4d182f675086b573e332
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Security for datahugger-ng 0.6.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

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