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 forurllib.request
. If omitted orNone
the default opener is used. - entity_type_guess (
bool
) – Whether to guesstype
ofEntity
from itsid
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 guesstype
ofEntity
from itsid
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 givenEntityId
. It could returnNone
when it fails to guess.Note
It always fails to guess when
entity_type_guess
is configued toFalse
.Returns: The guessed EntityId
, orNone
if it fails to guess.Return type: Optional
[EntityType
]New in version 0.2.0.
- base_url (