lobid-gnd API reference
Generated from the source with mkdocstrings. Every name below is importable
from bibliofabric.lobidgnd; nested value models stay importable from
bibliofabric.lobidgnd.models.
Client
bibliofabric.lobidgnd.LobidGndClient
Client for the lobid-gnd API.
The API needs no credentials. The client sends Accept:
application/json on every request. lobid asks for a descriptive,
stable User-Agent; pass mailto= and the core client builds one
with your contact address.
authorities: AuthoritiesResource
cached
property
The authority resource: /search queries and /{id}.json.
reconcile: ReconcileResource
cached
property
The GND reconciliation service client.
Settings
bibliofabric.lobidgnd.LobidGndSettings
lobid-gnd client settings.
Inherits timeout, max_retries, max_retry_wait,
max_requests_per_second, max_concurrency, user_agent and
mailto from :class:bibliofabric.config.BaseApiSettings and sets
lobid-gnd defaults (2 req/s, concurrency 2). The API needs no
credentials; lobid asks for a descriptive User-Agent, which the
mailto keyword of the client feeds.
Resources
bibliofabric.lobidgnd.AuthoritiesResource
Client for the authority routes: /search and /{id}.json.
The records are the JSON-LD authority resources of the GND. Search
pages by from/size; a query reaching past record 10000 cannot
be served upstream (Elasticsearch window), which the dialect caps.
suggest(query: str, *, fields: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> list[GndSuggestion]
async
Return autocomplete suggestions for query.
fields names the record fields the label is built from (for
example ["preferredName", "professionOrOccupation"]); None
uses the standard suggestion format. The answer is a bare JSON
array of {"label": ..., "id": ..., "category": ..., "image":
...} objects, where id is the d-nb.info URI.
download_jsonl(dest: Path | str, *, query: str | None = None, filters: BaseModel | Mapping[str, Any] | None = None, params: Mapping[str, Any] | None = None) -> Path
async
Stream every matching record as JSON lines into dest.
format=jsonl answers one JSON-LD record per line and ignores
size: the response holds the complete result set, so scope the
query (for example q=type:Country). Read the file with
:func:bibliofabric.lobidgnd.iter_gnd_jsonl. The download goes to
a temporary file next to dest that replaces dest only
after the last chunk arrived, so an interrupted download leaves no
partial file. The path is returned.
bibliofabric.lobidgnd.ReconcileResource
Client for the Reconciliation Specification 0.2 endpoint.
:meth:manifest reads the service description; :meth:query sends
one or more named queries as one application/x-www-form-urlencoded
queries parameter and returns the candidates of every query key.
manifest() -> ReconcileManifest
async
Return the service manifest (name, type tree, versions).
query(queries: Mapping[str, ReconcileQuery | Mapping[str, Any]]) -> ReconcileResponse
async
Run a reconciliation batch and return the keyed answers.
queries maps query keys to :class:ReconcileQuery models (or
raw mappings with the same keys). The keys come back as the keys
of the answer; response.candidates("q0") returns the
candidates of one query. The endpoint is a read-only POST, so the
request is retried.
Record models
bibliofabric.lobidgnd.GndResource
A GND authority record.
id is the d-nb.info URI of the record and gnd_identifier
the bare GND number. Search results carry fewer fields than direct
lookups; every field not served stays absent, and fields the model
does not declare stay reachable through the extra="allow" dict
surface (record.model_extra).
bibliofabric.lobidgnd.IdLabel
A linked node with an URI and a display label.
bibliofabric.lobidgnd.SameAsEntry
One cross-reference into another identifier collection.
bibliofabric.lobidgnd.SameAsCollection
The identifier collection a sameAs entry points into.
bibliofabric.lobidgnd.Depiction
An image of the entity and its page on Wikimedia Commons.
bibliofabric.lobidgnd.Geometry
A geographic coordinate in WKT form.
bibliofabric.lobidgnd.DescribedBy
The cataloguing metadata of a record (maintainer, creator, dates).
bibliofabric.lobidgnd.GndSuggestion
One autocomplete suggestion from format=json:suggest answers.
Reconciliation models
bibliofabric.lobidgnd.ReconcileManifest
The service manifest of the reconciliation endpoint.
bibliofabric.lobidgnd.ReconcileQuery
One query definition inside a reconciliation queries batch.
type narrows the candidates to one entity type
("Person", "SubjectHeading", ...), limit bounds the
candidate list, and properties carries the optional property
mappings of the specification as raw {"pid": ..., "v": ...}
objects.
to_body() -> dict[str, Any]
Return the JSON form the queries parameter carries.
bibliofabric.lobidgnd.ReconcileCandidate
One candidate match of a reconciliation answer.
bibliofabric.lobidgnd.ReconcileQueryResult
The candidate list of one query inside the batch.
bibliofabric.lobidgnd.ReconcileResponse
The whole answer body, keyed by the query keys of the request.
candidates(key: str) -> list[ReconcileCandidate]
Return the candidates of one query key, or an empty list.
Filters and helpers
bibliofabric.lobidgnd.GndFilter
Filters for client.authorities.search().
entity_type becomes the filter=type:<value> parameter. The
values the reconciliation manifest publishes are the entries of
bibliofabric.lobidgnd.GND_ENTITY_TYPES; upstream also indexes more
specific types (for example MusicalCorporateBody), which pass
through unchanged.
bibliofabric.lobidgnd.iter_gnd_jsonl(path: Path | str) -> Iterator[GndResource]
Yield one :class:GndResource per line of a downloaded JSONL file.
Write the file with
:meth:bibliofabric.lobidgnd.AuthoritiesResource.download_jsonl. The
file is read line by line, so memory use stays flat. An empty file
yields nothing; a line that is not a JSON object raises
:class:bibliofabric.APIError, and a record that fails validation
raises :class:bibliofabric.ValidationError.