Helpers#

Functions calling the MediaWiki and Wikibase APIs directly. Import them from wikibaseintegrator.wbi_helpers.

API calls#

mediawiki_api_call_helper

A simplified function to call the MediaWiki API.

mediawiki_api_call

A function to call the MediaWiki API.

edit_entity

Creates a single new Wikibase entity and modifies it with serialised information.

Search and queries#

search_entities

Performs a search for entities in the Wikibase instance using labels and aliases.

fulltext_search

Perform a fulltext search on the mediawiki instance.

generate_entity_instances

A method which allows for retrieval of a list of Wikidata entities.

execute_sparql_query

Static method which can be used to execute any SPARQL query

Edits#

merge_items

A static method to merge two items.

merge_multiple_items

Merge several items into the one with the lowest numeric ID, one wbmergeitems call per merged item.

merge_lexemes

A static method to merge two lexemes

create_redirect

A static method to turn an item into a redirect to another item, with the wbcreateredirect API.

set_claim

Create or replace a single statement, with its qualifiers and references, with the wbsetclaim API.

remove_claims

Delete a claim from an entity

delete_page

Delete a page

Lexemes#

lexeme_add_form

Adds Form to Lexeme

lexeme_edit_form

Edits representations and grammatical features of a Form

lexeme_remove_form

Removes Form from Lexeme

lexeme_add_sense

Adds a Sense to a Lexeme

lexeme_edit_sense

Edits glosses of a Sense

lexeme_remove_sense

Removes Sense from Lexeme

Values#

parse_value

Parse values written as text (e.g. '3 March 1850', '1850s', '12±0.5') into data values, with the parsers of the Wikibase instance and the wbparsevalue API.

format_amount

A formatting function mostly used for Quantity datatype.

get_available_badges

Get the items which can be used as badges of sitelinks (e.g. 'Q17437796', featured article, on Wikidata), with the wbavailablebadges API.

check_constraints

Check the constraint violations of one or more entities or claims, using the target Wikibase instance's own constraint checker (the wbcheckconstraints API module provided by the WikibaseQualityConstraints extension).

Wikibase instance#

check_wikibase

Check the features of a Wikibase instance: the MediaWiki version, the installed extensions, the entity types and the datatypes it supports, and whether the SPARQL endpoint answers.

WikibaseCheck

The features of a Wikibase instance, as returned by check_wikibase().

get_user_agent

Return a user agent string suitable for interacting with the Wikibase instance.

download_entity_ttl

Downloads the TTL (Terse RDF Triple Language) content of a specific entity from a Wikibase instance.

Experimental#

format2wbi

Build a WikibaseIntegrator entity from a simplified JSON string: labels, descriptions and aliases by language, and the claims by property, each claim being a value or a list of values, and each value a string or a dict (e.g. {"value": "First Author", "qualifiers": {"P1545": "1"}, "references": [{"P248": "Q5"}]}, {"text": "...", "language": "en"}, {"amount": "12", "unit": "Q11573"}).