wikidata.client — Client session

wikidata.client.WIKIDATA_BASE_URL = ''

(str) The default base_url of Client constructor.

Changed in version 0.3.0: As the meaning of Client constructor’s base_url parameter, it now became to from (which contained the trailing path wiki/).

class wikidata.client.Client

Wikidata client session.


New in version 0.5.0: The cache_policy option.

Changed in version 0.3.0: The meaning of base_url parameter changed. It originally meant which contained the trailing path wiki/, but now it means only

New in version 0.2.0: The entity_type_guess option.

cache_policy = <wikidata.cache.NullCachePolicy object>

(CachePolicy) A caching policy for API calls.

New in version 0.5.0.

datavalue_decoder = None

(Union[Decoder, Callable[[Client, str, Mapping[str, object]], object]]) The function to decode the given datavalue. It’s typically an instance of Decoder or its subclass.

decode_datavalue(datatype: str, datavalue: typing.Mapping[str, object]) → object

Decode the given datavalue using the configured datavalue_decoder.

New in version 0.3.0.

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 0x7f63cea5b620>, load: bool = False) → wikidata.entity.Entity

Get a Wikidata entity by its EntityId.

  • entity_id – The id of the Entity to find.
  • load (bool) – Eager loading on True. Lazy loading (False) by default.

The found entity.

Return type:


New in version 0.3.0: The load option.

guess_entity_type(entity_id: <function NewType.<locals>.new_type at 0x7f63cea5b620>) → typing.Union[wikidata.entity.EntityType, NoneType]

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


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.