dhlab.metadata.natbib2

Query service for natbib metadata

Module Contents

Classes

QueryBuilder

Query builder for the metadata_query2 service.

API

class dhlab.metadata.natbib2.QueryBuilder

Query builder for the metadata_query2 service.

This service allows for querying the Norwegian National Bibliography using Marc 21 fields and values.

Example of usage: builder = QueryBuilder() result = (builder.add_field(“field1”, “subfield1”, “value1”) .add_field(“field2”, “subfield2”, “value2”) .set_return_fields(“returnField1”, “returnField2”, “returnField3”) .set_limit(1000) .post())

Initialization

endpoint

https://api.nb.no/dhlab/metadata_query2

add_field(field, subfield=None, value=None)

Add a field constraint to the query.

Should be field + value for marc21 without subfields (<11) and field + subfield + value for marc21 with subfields (>=11

set_return_fields(*fields)

Specify which fields to return in the response.

set_limit(limit)

Specify the maximum number of records to return.

build()

Build the query.

post()

Post the query to the service and return the response.