Skip to content
/ yamwapi Public

A simple and modern wrapper for the MediaWiki API. Use me to talk to Wikipedia.

License

Notifications You must be signed in to change notification settings

eggpi/yamwapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yamwapi

A simple and modern Python wrapper for the MediaWiki API.

(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, and, as such, is in active development and production use.

Examples

Fetching the Wikitext of a page requires a single method:

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:

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, which is similar, but slightly lower level.

About

A simple and modern wrapper for the MediaWiki API. Use me to talk to Wikipedia.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages