Skip to main content

Client for querying DigitalNZ via its API

Project description

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.

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

dnzapi-0.0.1.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

dnzapi-0.0.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file dnzapi-0.0.1.tar.gz.

File metadata

  • Download URL: dnzapi-0.0.1.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dnzapi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f688156c240b825526fdd9618ddb69e82407020f08a6793d910dc32359a73c11
MD5 cd679bc655d8da029af017a476b1e559
BLAKE2b-256 4ae1ea52fc28c4d59d1ca9e8bea81b53cf2ef4b3be93c9801337f78ab76b596d

See more details on using hashes here.

File details

Details for the file dnzapi-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dnzapi-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for dnzapi-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b6f550041ecc32119a330bad6610adecd68ab7bd95b097e177c97a5ba49d7e88
MD5 4f52b7d7e5ee7b5f72b2de9551268401
BLAKE2b-256 14fbd9b8699d8b40af314202a91dae10458cde90f38b5075e40173add1e4bf43

See more details on using hashes here.

Supported by

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