Skip to main content

PyPI version Version Build Status GitHub Issues License [Docs

MediaWikiAPI 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 <https://www.mediawiki.org/wiki/API>__ so you can focus on using Wikipedia data, not getting it.

>>> from mediawikiapi import MediaWikiAPI
>>> mediawikiapi = MediaWikiAPI()
>>> print mediawikiapi.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...

>>> mediawikiapi.search("Barack")
# [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 = mediawikiapi.page("New York")
>>> ny.title
# u'New York'
>>> ny.url
# u'http://en.wikipedia.org/wiki/New_York'
>>> 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'

>>> mediawikiapi.conf.language = "fr"
>>> mediawikiapi.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.

Installation

To install MediaWikiAPI, simply run:

pip install mediawikiapi

MediaWikiAPI is compatible with Python 3 and Python 2.7.

Documentation

The documentation is available here Changelog could be find in the documentation.

To run tests, clone the repository on GitHub <https://github.com/lehinevych/MediaWikiAPI>__, then run:

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

in the root project directory.

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

pip install sphinx
cd docs/
make html

License

MIT licensed. See the LICENSE file <https://github.com/lehinevych/MediaWikiAPI/blob/master/LICENSE>__ for full details.

Credits

  • @goldsmith for making such a fantastic library to fork

Metadata

Release files for mediawikiapi 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mediawikiapi 1.1.0
File Size Uploaded Provenance Actions
mediawikiapi-1.1.0.tar.gz 12.5 kB Without provenance Details for mediawikiapi-1.1.0.tar.gz

Release files / mediawikiapi-1.1.0.tar.gz

Download URL mediawikiapi-1.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9bc868756783f9813f6f234feb34df33a3c923834ac273864a619a0522c18266
BLAKE2b-256 checksum
How to use checksums
865b4a3ebb548a7a65d5d89d2c24ada48601e5b9d196f7d268c5d37ab4889824
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mediawikiapi 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page