Read from the package's own PHP files at the commit baf23c76f152: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.
WikidataSourceclassWikidata, 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
WikidataSourceFactoryclassWikidata: 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 = 50The 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)$languagethe language of labels, descriptions and aliases ("en", "fr", "de"...), with Wikidata's fallbacks
$synonymshow many aliases to keep (0: none)
WikidataSource::getName()
public function getName(): stringWikidataSource::capabilities()
public function capabilities(): arrayWikidataSource::entity()
public function entity(Identifier|string $id): ?EntityWikidataSource::search()
public function search(Query $query): PageItems 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
| Option | Default | |
|---|---|---|
language | 'en' | |
synonyms | 20 | |
throttle | 0.3 | |
base_uri | WikidataSource::BASE_URI |