WikibaseIntegrator is a Python library to read and write the data of a Wikibase instance, like Wikidata: items, properties, lexemes and MediaInfo entities, with their labels, claims, qualifiers and references, through the MediaWiki API and the SPARQL endpoint. Its "fast run" mode compares your data with the SPARQL endpoint and only writes what actually changed.
python -m pip install wikibaseintegratorPython 3.11.5 or newer is required.
from wikibaseintegrator import WikibaseIntegrator
from wikibaseintegrator.wbi_config import config
# Wikimedia asks every tool to identify itself: https://foundation.wikimedia.org/wiki/Policy:User-Agent_policy
config['USER_AGENT'] = 'MyTool/1.0 (https://www.wikidata.org/wiki/User:MyUsername)'
wbi = WikibaseIntegrator()
item = wbi.item.get('Q582')
print(item.labels.get('en')) # VilleurbanneTo log in and write, see Login and Entities.
The documentation is on GitHub Pages, for the latest release and for the development version:
- Installation and configuration: using another Wikibase instance, the User-Agent policy, debugging
- Entities: read, create and edit items, properties, lexemes, labels, claims, qualifiers and references
- Login: OAuth 2.0, OAuth 1.0a, bot passwords
- Data types, Structured Data on Commons
- Helpers: SPARQL queries, search, merges, the MediaWiki API, EditGroups
- Fast run and examples, including a bot for mass import
- API reference
Upgrading from an older version (v0.13, v0.12, v0.11)? See the breaking changes.
See Contributing to set up the development environment and run the tests.
WikibaseIntegrator is a fork of WikidataIntegrator, see About. To port a WikidataIntegrator script, see the migration guide.