Skip to main content

nuldc

A simple CLI for consuming Northwestern University Libraries Digital Collections API. It also includes a set of python helpers for rolling your own scripts.

Quickstart

Install it

pip install nuldc

Upgrading to a new verson

pip install --upgrade nuldc

❯ nuldc --help

NULDC

USAGE:
    nuldc works <id> [--as=<format>]
    nuldc collections <id> [--as=<format> --all]
    nuldc search <query> [--model=<model>] [--as=<format>] [--all]
    nuldc csv <query> [--fields=<fields>] [--all] <outfile>
    nuldc xml <query> [--all] <outfile>
    nuldc --version

OPTIONS:
    --as=<format>      get results as [default: opensearch]
    --model=<model>    search model (works,collections,filesets) [default: works]
    --all              get all records from search
    --fields=<fields>  optional set of fields,e.g id,ark,test defaults to all
    -h --help          Show this screen

ARGUMENTS:
    as: opensearch
        iiif

Examples

Get a work

Let's get a work's manifest

nuldc works c1960aac-74f0-4ce8-a795-f713b2e3cc22

Maybe we should grab that work as a IIIF manifest.

nuldc works c1960aac-74f0-4ce8-a795-f713b2e3cc22 --as iiif

Get collection's metadata

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2

or get metadata as iiif

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2 --as iiif

Get the whole collection as IIIF, stitching together all the pages

nuldc collections ecacd539-fe38-40ec-bbc0-590acee3d4f2 --as iiif --all

Search for things

Simple search

nuldc search "berkeley AND guitars"

Page through all the results and return one big list of items (limit 200 pages)

nuldc search "trains AND chicago" --all

as iiif

nuldc search "trains AND chicago" --as iiif --all

Save to CSV

Dumping to CSV is simple. By default it dumps all the fields that are "label". If you need to dig into specific fields you can do that as well.

nuldc csv "trains AND chicago" --all example.csv

Fields with role-qualified labels, such as contributors, use the role-aware label when the API returns one. For example, a contributor list may export as Northwestern Community Ensemble (Contributor)|Pitts, Ronald E. (Donor)|Pitts, Ronald E. (Photographer) instead of repeating the same bare contributor name for each role.

Let's grab just a few fields.

nuldc csv "trains AND chicago" --all --fields id,title,ark example.csv

It also supports "dot" notation for getting into nested, special purpose fields.

nuldc csv "trains AND chicago" --all --fields id,title,ark,subject.id example.csv

Save to xml

You can export search results to an xml serialization of the data structure as well.

nuldc xml "trains AND chicago" out.xml

Or get all the records

nuldc xml "trains AND chicago" --all all.xml

Pipeable and Works great with jq!

All of this is pipe-able too, so if you want to do further analysis with JQ or pipe data through some other processing pipeline, go for it! For instance, let's grab just a coupld of fields from the json and reformat it into a simplified shape.

nuldc search "berkeley AND guitars" --all | jq -r '.data[] | [.title,.id]

You can search within specific fields and perform complex searches using the opensearch/elasticsearch query-string-query syntax. The query syntax is valid for all "search" operations: search, csv, xml.

Examples:

Get a csv file of all works that have a fileset label including "recto"

nuldc csv "file_sets.label:Recto*" ~/Desktop/rectos.csv

Look at results that have a subject that includes "Chicago"

nuldc search "subject.label:*Chicago*"

Get Results that have a subject of "Chicago" AND a title of "Bus"

nuldc search "subject.label:*Chicago* AND title:bus"

Get results from a known collection that were modified before a certain date:

nuldc search "modified_date:<2022-10-01 AND collection.title:Berkeley*"

Development

This project is built using POETRY. Follow the latest install instructions, clone the repository and poetry install.

Tests

This project uses pytest and has a very small set of tests to ensure things are running as expected.

From a poetry shell run pytest.

Metadata

Release files for nuldc 0.12.2

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

Source distribution (sdist)

Source distribution for nuldc 0.12.2
File Size Uploaded Provenance Actions
nuldc-0.12.2.tar.gz 8.2 kB Without provenance Details for nuldc-0.12.2.tar.gz

Built distribution (wheel)

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

Total release size: 18.2 kB

Release files / nuldc-0.12.2.tar.gz

Download URL nuldc-0.12.2.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3f674e115b55eeee8ea5a66d52b147b7568cddb1c708728ed9973387e709fb4b
BLAKE2b-256 checksum
How to use checksums
218e719d3bc4cb29d3fc46c16bb7d95837cebcb9fe8f063cac338ad089545492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.0 Linux/6.17.0-1013-azure

Release files / nuldc-0.12.2-py3-none-any.whl

Download URL nuldc-0.12.2-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d079834a26619efbacc810329b6a5f1d7a0438c849e21a1aa759fc3ece307e50
BLAKE2b-256 checksum
How to use checksums
0f60c342a73a9c63773a0cdffc0e2e1ea944ab61a8038f75a2a3be69ca5c077a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.11.0 Linux/6.17.0-1013-azure

Security for nuldc 0.12.2

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