Entity¶
-
class
wikibase_api.models.
Entity
(api)¶ Collection of API functions for Wikibase entities (items, properties, …)
Example function call:
from wikibase_api import Wikibase wb = Wikibase( # Parameters ) content = {"labels": {"en": {"language": "en", "value": "Updated label"}}} r = wb.entity.update("Q1", content=content) print(r)
-
add
(entity_type, content=None)¶ Create a new Wikibase entity
Parameters: - entity_type (str) – Type of entity to be created (e.g.
"item"
) - content (dict) – Content of the new entity
Returns: Response
Return type: dict
- entity_type (str) – Type of entity to be created (e.g.
-
get
(entity_ids, attributes=None, languages=None)¶ Get the data of one or multiple Wikibase entities
Parameters: - entity_ids (str or list(str)) – Entity identifier(s) (e.g.
"Q1"
or["Q1", "Q2"]
) - attributes (list(str)) – Names of the attributes to be fetched from each entity (e.g.
"claims"
) - languages (list(str)) – Languages to return the fetched data in (e.g.
"en"
)
Returns: Response
Return type: dict
- entity_ids (str or list(str)) – Entity identifier(s) (e.g.
-
remove
(title, reason=None)¶ Delete the specified Wikibase entity
Parameters: - title (str) – Entity title (e.g.
"Item:Q1"
or"Property:P1"
) - reason – Reason for the deletion (if not set, Wikibase will use an automatically generated reason)
Returns: Response
Return type: dict
- title (str) – Entity title (e.g.
-
search
(search_key, language, entity_type='item', limit=10, offset=0)¶ Search for entities based on their labels and aliases
Parameters: - search_key (str) – String for which Wikibase entities’ labels and aliases are searched
- language (str) – Languages to search in (e.g.
"en"
) - entity_type (str) – Type of entities to search for. Default: “item”
- limit (int) – Maximum number of results to return. Default: 10
- offset (int) – Offset where to continue a search. Default: 0
Returns: Response
Return type: dict
-
update
(entity_id, content)¶ Modify the specified Wikibase entity
Parameters: - entity_id (str) – Entity identifier (e.g.
"Q1"
) - content (dict) – Content to add to the entity
Returns: Response
Return type: dict
- entity_id (str) – Entity identifier (e.g.
-