https://github.com/eggpi/yamwapi
A simple and modern wrapper for the MediaWiki API. Use me to talk to Wikipedia.
https://github.com/eggpi/yamwapi
Last synced: 2 months ago
JSON representation
A simple and modern wrapper for the MediaWiki API. Use me to talk to Wikipedia.
- Host: GitHub
- URL: https://github.com/eggpi/yamwapi
- Owner: eggpi
- License: mit
- Created: 2017-09-21T19:48:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:23:07.000Z (over 3 years ago)
- Last Synced: 2025-10-13T18:48:31.128Z (9 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yamwapi
A simple and modern Python wrapper for the [MediaWiki API](https://www.mediawiki.org/wiki/API:Main_page).
(Yes, yet another.)
Use me to talk to Wikipedia.
## Features
This library particularly suited for large batch jobs that perform many queries
to Wikipedia. Features include:
* Simple (but relatively low-level) API
* Persistent connections by default
* Uses POST for requests, allowing large payloads
This library is used by [Citation Hunt](https://tools.wmflabs.org/citationhunt),
and, as such, is in active development and production use.
## Examples
Fetching the Wikitext of a page requires a single method:
```python
import yamwapi
api = yamwapi.MediaWikiAPI('https://en.wikipedia.org/w/api.php', 'yamwapi UA')
print api.get_page_contents(title = 'Wikipedia')
```
Other methods and options can be accessed via a lower level API:
```python
api.options.maxlag = 10
print api.parse({'text': '{{ cn }}', 'contentmodel': 'wikitext'})
```
## But why another library?
If you're considering this library, also be sure to have a look at
[mwapi](https://pypi.org/project/mwapi/), which is similar, but slightly lower
level.