Skip to content
A Pythonic wrapper for the Wikipedia API
Python Shell
Branch: master
Clone or download
Latest commit 2065c56 Nov 11, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs wikipedia.languages() May 20, 2014
tests strip Category: prefix from categories Aug 19, 2014
wikipedia Added 'html.parser' to BeautifulSoup call Nov 9, 2016
.travis.yml dropping down `requests` dependency to 2.0.0 Jul 29, 2014 v1.4 featuring WikipediaPage.categories Nov 15, 2014
LICENSE set up shop in the cheese shop Aug 23, 2013
README.rst Fix typo in README Apr 7, 2016
requirements.txt dropping down `requests` dependency to 2.0.0 Jul 29, 2014
runtests runtests script for laziness & convenience May 15, 2014 determine package version without importing wikipedia in (fix May 31, 2014


Wikipedia License

Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia.

Search Wikipedia, get article summaries, get data like links and images from a page, and more. Wikipedia wraps the MediaWiki API so you can focus on using Wikipedia data, not getting it.

>>> import wikipedia
>>> print wikipedia.summary("Wikipedia")
# Wikipedia (/ˌwɪkɨˈpiːdiə/ or /ˌwɪkiˈpiːdiə/ WIK-i-PEE-dee-ə) is a collaboratively edited, multilingual, free Internet encyclopedia supported by the non-profit Wikimedia Foundation...

# [u'Barak (given name)', u'Barack Obama', u'Barack (brandy)', u'Presidency of Barack Obama', u'Family of Barack Obama', u'First inauguration of Barack Obama', u'Barack Obama presidential campaign, 2008', u'Barack Obama, Sr.', u'Barack Obama citizenship conspiracy theories', u'Presidential transition of Barack Obama']

>>> ny ="New York")
>>> ny.title
# u'New York'
>>> ny.url
# u''
>>> ny.content
# u'New York is a state in the Northeastern region of the United States. New York is the 27th-most exten'...
>>> ny.links[0]
# u'1790 United States Census'

>>> wikipedia.set_lang("fr")
>>> wikipedia.summary("Facebook", sentences=1)
# Facebook est un service de réseautage social en ligne sur Internet permettant d'y publier des informations (photographies, liens, textes, etc.) en contrôlant leur visibilité par différentes catégories de personnes.

Note: this library was designed for ease of use and simplicity, not for advanced use. If you plan on doing serious scraping or automated requests, please use Pywikipediabot (or one of the other more advanced Python MediaWiki API wrappers), which has a larger API, rate limiting, and other features so we can be considerate of the MediaWiki infrastructure.


To install Wikipedia, simply run:

$ pip install wikipedia

Wikipedia is compatible with Python 2.6+ (2.7+ to run unittest discover) and Python 3.3+.


Read the docs at

To run tests, clone the repository on GitHub, then run:

$ pip install -r requirements.txt
$ bash runtests  # will run tests for python and python3
$ python -m unittest discover tests/ '*'  # manual style

in the root project directory.

To build the documentation yourself, after installing requirements.txt, run:

$ pip install sphinx
$ cd docs/
$ make html


MIT licensed. See the LICENSE file for full details.


  • wiki-api by @richardasaurus for inspiration
  • @nmoroze and @themichaelyang for feedback and suggestions
  • The Wikimedia Foundation for giving the world free access to data
Bitdeli badge
You can’t perform that action at this time.