Skip to main content

This library provides a Python client to interact with the DigitalNZ API version 3. It supports searching records and getting metadata for a specific record, returning all results as Python dictionaries loaded from the returned JSON.

Usage

from dnz_client import get_client
client = get_client("my API token")  # Omit token for anonymous use
_and = {"collection": "Music 101", "subject": "Cats", "Weddings"}
_or = {"category": ["Books", "Articles"]}
results = client.search(
    text="Wanganui OR Whanganui", _and=_and, _or=_or,
    geo_bbox=["-41", "174", "-42", "175"], "direction": "asc")
metadata = client.metadata(record_id=6330666, fields=["id", "title"])

The keyword arguments passed to the search method are those specified in the API documentation.

The arguments _and, _or, and _without contain dictionaries keyed to the fields that are so joined; each value may be a string or list of strings.

The keyword arguments facets, fields, and geo_bbox each take a list of strings.

The other fields (direction, exclude_filters_from_facets, facets_page, page, per_page, sort, and text) are either string or integer values, as appropriate.

The return values of both search() and metadata() are dictionaries loaded from the JSON returned by DigitalNZ.

Limitations

OR filters combined across multiple fields are not supported. For example, it is supported to search for records where the category is either “Audio” or “Videos”, but searching for those records where the category is either “Audio” or “Videos” and the year is either “2014” or “2015” is not.

The client does no checking that supplied values are sensible or permitted by the DigitalNZ API. For example, any string may be passed as the direction field, though the API permits only “asc” and “desc”.

Exceptions

See the underlying api-client documentation for the exceptions the client raises.

Metadata

Release files for dnzapi 0.0.1

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

Source distribution (sdist)

Source distribution for dnzapi 0.0.1
File Size Uploaded
dnzapi-0.0.1.tar.gz 22.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dnzapi 0.0.1
File Interpreter ABI Platform
dnzapi-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / dnzapi-0.0.1.tar.gz

Download URL dnzapi-0.0.1.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f688156c240b825526fdd9618ddb69e82407020f08a6793d910dc32359a73c11
BLAKE2b-256 checksum
How to use checksums
4ae1ea52fc28c4d59d1ca9e8bea81b53cf2ef4b3be93c9801337f78ab76b596d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / dnzapi-0.0.1-py3-none-any.whl

Download URL dnzapi-0.0.1-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6f550041ecc32119a330bad6610adecd68ab7bd95b097e177c97a5ba49d7e88
BLAKE2b-256 checksum
How to use checksums
14fbd9b8699d8b40af314202a91dae10458cde90f38b5075e40173add1e4bf43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release 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