Skip to main content

MediaWikiAPI

PyPI version Version Python package 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 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 (state)")
>>> ny.title
# u'New York (state)'
>>> ny.url
# u'http://en.wikipedia.org/wiki/New_York_(state)'
>>> ny.content
# u'New York is a state in the northeastern United States. New York was one of the original thir'...
>>> ny.links[0]
# u'1790 United States Census'

>>> mediawikiapi.config.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.

Changelog

Changelog could be find in the documentation.

Documentation

The documentation is available here

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

pip install -r requirements.txt
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 for full details.

Credits

  • @goldsmith for making such a fantastic library to fork

Metadata

Release files for mediawikiapi 1.1.6

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.6
File Size Uploaded Provenance Actions
mediawikiapi-1.1.6.tar.gz 15.0 kB Without provenance Details for mediawikiapi-1.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mediawikiapi 1.1.6
File Interpreter ABI Platform Actions
mediawikiapi-1.1.6-py3-none-any.whl Python 3 none any Details for mediawikiapi-1.1.6-py3-none-any.whl

Total release size: 30.8 kB

Release files / mediawikiapi-1.1.6.tar.gz

Download URL mediawikiapi-1.1.6.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ac1ee492e520e0d3a4a9dbd8eecfe517f9fc4c5dd89e427a7421faf423ff22b5
BLAKE2b-256 checksum
How to use checksums
90225dc160a1301d3bf02a0c5a78d64a46b56752d6e373020be9ebcaab2f4d96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / mediawikiapi-1.1.6-py3-none-any.whl

Download URL mediawikiapi-1.1.6-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fa235839af1c2ede09a1254b5764b04a904cb28f990fad1f91698ff73e51591
BLAKE2b-256 checksum
How to use checksums
cd5225ac8a5b89dbfb9668387b3fbbcb508b949228ffe29a25b238104134ec83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for mediawikiapi 1.1.6

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