wikidata.client — Client session

class wikidata.client.Client(base_url: str='https://www.wikidata.org/wiki/', opener: typing.Union=None, entity_type_guess: bool=True, repr_string: typing.Union=None) → None

Wikidata client session.

Parameters:
  • base_url (str) – The base url of the Wikidata. WIKIDATA_BASE_URL is used by default.
  • opener (urllib.request.OpenerDirector) – The opener for urllib.request. If omitted or None the default opener is used.
  • entity_type_guess (bool) – Whether to guess type of Entity from its id for less HTTP requests. True by default.

New in version 0.2.0: The entity_type_guess option.

entity_type_guess = True

(bool) Whether to guess type of Entity from its id for less HTTP requests.

New in version 0.2.0.

get(entity_id: <function NewType.<locals>.new_type at 0x7f4911a66378>) → wikidata.entity.Entity

Get a Wikidata entity by its EntityId.

guess_entity_type(entity_id: <function NewType.<locals>.new_type at 0x7f4911a66378>) → typing.Union

Guess EntityType from the given EntityId. It could return None when it fails to guess.

Note

It always fails to guess when entity_type_guess is configued to False.

Returns:The guessed EntityId, or None if it fails to guess.
Return type:Optional[EntityType]

New in version 0.2.0.