Aller au contenu

omnilab/wikidata Référence de l’API

Étage
Fournisseur · Omnilab
Version
1.x
Suite de conformité
non branchée
Vérifié en réel
Son README ne le dit pas
Licence
MIT
composer require omnilab/wikidata:1.x-dev

Lue dans les fichiers PHP du paquet au commit baf23c76f152 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.

Omnilab\Wikidata

  • WikidataSource class

    Wikidata, through its Action API (www.wikidata.org/w/api.php): an item by its Q-number, by the identifier of another base its statements carry (a PubChem CID, a ChEBI id, a CAS number, an InChIKey, a UniProt accession, an NCBI taxon... found with CirrusSearch's haswbstatement) or by a label; its label, description and aliases in the language asked, those identifiers as cross-references, a few properties with their units, and a search by label, narrowed to a domain when asked.

    5 methods · 2 constants

  • WikidataSourceFactory class

    Wikidata: any item, its labels in a language, its identifiers in the science bases and a few of its properties - no key needed.

    4 options

Omnilab\Wikidata

WikidataSource class

final class WikidataSource extends HttpSource WikidataSource.php:38

Wikidata, through its Action API (www.wikidata.org/w/api.php): an item by its Q-number, by the identifier of another base its statements carry (a PubChem CID, a ChEBI id, a CAS number, an InChIKey, a UniProt accession, an NCBI taxon... found with CirrusSearch's haswbstatement) or by a label; its label, description and aliases in the language asked, those identifiers as cross-references, a few properties with their units, and a search by label, narrowed to a domain when asked.

No key. Wikimedia asks for a User-Agent that names the caller and a way to reach them (a request without one is refused, 403), calls in series, and allows an unauthenticated client with such a User-Agent 200 calls a minute: the source leaves 0.3 s between two (the "throttle" option). An item costs two calls (its statements, then the labels of its class and of units the source does not know), three when found by another identifier.

const BASE_URI = 'https://www.wikidata.org/w/api.php'
const MAX_PER_PAGE = 50

The most items one search page is asked for (wbsearchentities and wbgetentities stop at 50).

WikidataSource::__construct()

public function __construct(HttpClientInterface $http, readonly string $language = 'en', readonly int $synonyms = 20, string $baseUri = self::BASE_URI, array $headers = [], float $throttle = 0.3)
$language

the language of labels, descriptions and aliases ("en", "fr", "de"...), with Wikidata's fallbacks

$synonyms

how many aliases to keep (0: none)

WikidataSource::getName()

public function getName(): string

WikidataSource::capabilities()

public function capabilities(): array

WikidataSource::entity()

public function entity(Identifier|string $id): ?Entity
public function search(Query $query): Page

Items by label or alias (wbsearchentities, in the source's language), or - for a domain - by text among the items that carry a statement of that domain (CirrusSearch with haswbstatement); each read whole.

WikidataSourceFactory class

final class WikidataSourceFactory extends SourceFactory WikidataSourceFactory.php:21

Wikidata: any item, its labels in a language, its identifiers in the science bases and a few of its properties - no key needed.

options: mailto: 'support@glitchr.io' # in the User-Agent: Wikimedia refuses a request that does not say who calls and how to reach them language: 'en' # labels, descriptions, aliases: "fr", "de", "ja"... with Wikidata's fallbacks synonyms: 20 # how many aliases to keep (0: none) throttle: 0.3 # seconds between two calls: 200 a minute for a client identified by its User-Agent base_uri: 'https://www.wikidata.org/w/api.php'

Options

OptionDefault
language'en'
synonyms20
throttle0.3
base_uriWikidataSource::BASE_URI