siznax
wptools
Python

Wikipedia tools (for Humans): easily extract data from Wikipedia, Wikidata, and other MediaWikis

Last updated Jul 6, 2026
594
Stars
77
Forks
39
Issues
0
Stars/day
Attention Score
71
Language breakdown
No language data available.
Files click to expand
README

Wikipedia tools (for Humans) ============================

.. image:: https://img.shields.io/pypi/v/wptools.svg :target: https://pypi.python.org/pypi/wptools/

.. image:: https://travis-ci.org/siznax/wptools.svg?branch=master :target: https://travis-ci.org/siznax/wptools

.. image:: https://coveralls.io/repos/github/siznax/wptools/badge.svg?branch=master :target: https://coveralls.io/github/siznax/wptools

Python and command-line MediaWiki access for Humans

  • get page extracts, image, Infobox data, Wikidata, and more
  • get a random page, category, or site
  • get page statistics
  • get category members
  • get site info and stats
  • get data in any language
This package is intended to make it as easy as possible to get data from MediaWiki instances, expose more Wikidata, and extend Wikimedia APIs just for kicks. We say "(for Humans)" because that is a goal_. Questions, feedback, and especially contributions_ are welcome!

Install


.. code-block:: bash

$ pip install wptools ✨🦄✨

Example


.. code-block:: python

>>> import wptools

Get a page object:

.. code-block:: python

>>> page = wptools.page('Gandhi')

Get API:Query_ data:

.. _API:Query: https://www.mediawiki.org/wiki/API:Query

.. code-block:: python

>>> page.get_query() en.wikipedia.org (query) Gandhi en.wikipedia.org (imageinfo) File:Portrait Gandhi.jpg Mahatma Gandhi (en) data { aliases: M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M... assessments: Pakistan, Alternative Views, South Afric... description: pre-eminent leader of Indian nationalism ... extext: Mahātmā Mohandas Karamchand Gandhi ( ; H... extract:

Mahātmā Mohandas Karamchand Gandhi {u'size': 2951123, 'kind': 'query-pageimage', u... label: Mahatma Gandhi length: 262,790 links: 10 Janpath, 14th Dalai Lama, 1915 Singapore M... modified: page pageid: 19379 random: Salt redirected: {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'} redirects: {u'ns': 0, u'pageid': 55342, u'title': u'M... requests: query, imageinfo title: Mahatma Gandhi url: https://en.wikipedia.org/wiki/Mahatma_Gandhi urlraw: https://en.wikipedia.org/wiki/MahatmaGandhi?action=raw watchers: 1,811 wikibase: Q1001 wikidata_url: https://www.wikidata.org/wiki/Q1001 }

Get API:Parse_ data:

.. _API:Parse: https://www.mediawiki.org/wiki/API:Parse

.. code-block:: python

>>> page.get_parse() en.wikipedia.org (parse) Gandhi en.wikipedia.org (imageinfo) File:MKGandhi.jpg Mahatma Gandhi (en) data { image: {u'size': 2951123, 'kind': 'parse-image', u'des... infobox: knownfor, othernames, image, signature, bi... iwlinks: https://biblio.wiki/wiki/MohandasK.Gandhi,... pageid: 19379 parsetree: