tetrak_authority.wikidata

A polite client for Wikidata’s SPARQL endpoints and its search API.

Wikidata asks three things of a bulk reader: identify yourself in the user agent, go one request at a time, and back off when told to. The client does all three and counts its requests, so a snapshot can say how many it made.

Two SPARQL endpoints are known. The Wikidata Query Service is live but times out on the queries that enumerate a subset by label language; the QLever mirror answers those in a second from a copy a little behind live. The snapshot records which one it used.

Module Attributes

WDQS

The Wikidata Query Service, live, 60-second query limit.

QLEVER

a copy a little behind live, no practical query limit.

API

The Wikidata API, for wbsearchentities.

Transport

take a URL and headers, return the body.

Functions

user_agent(version[, contact])

The user agent Wikimedia's policy asks for: a name, a version, a contact.

Classes

Cell(value[, language])

One bound value in a SPARQL result row.

Client([endpoint, user_agent, pause, ...])

A rate-limited reader of one SPARQL endpoint and the Wikidata API.

Exceptions

RequestFailed

A request failed after the retries the client allows, or the endpoint rejected the query.