Skip to main content
https://badge.fury.io/py/pymw.svg https://travis-ci.org/5j9/pymw.svg?branch=master https://codecov.io/gh/5j9/pymw/branch/master/graph/badge.svg

Yet another MediaWiki client library for Python. It’s not stable yet and it requires Python 3.9+!

Installation

pip install pymw

Usage

To avoid directly providing username and password for login calls create a .pymw.json file in your home directory with the following format:

{
    "https://test.wikipedia.org/w/api.php": {
        "<Username@Special:BotPasswords>": {
            "BotPassword": "<BotPassword>"
        },
        "<Username2>": {
            "BotPassword": "<BotPassword>",
            "limit": 500
        }
    },
    "https://*.wikipedia.org/w/api.php": {
        "<Username>": {
            "BotPassword": "<BotPassword>"
        }
    }
}

As you can see, glob patterns are supported.

Notable features

  • Has a post_and_continue method that can handle continuations.

  • Parameter values can be str or any Python iterable. Iterable values that are not an str instance will be converted to a pipe-joined str before being sent.

  • The post_and_continue method automatically breaks a value that has too many items in it into several API calls according the API limit for the current user and yields the results. (Currently this feature works only if there is just one violating parameter. The algorithm might be improved in the future to handle more complex situations.)

  • prop method handles batchcomplete signals for prop queries and yields the results as soon as a batch is complete.

  • Configurable maxlag. Waits as the API recommends and then retries.

  • Automatically tries to login before performing actions that are known to require login.

  • Automatically tries to login if an API call returns login-required error (requires username and password to be set in ~/.pymw.json).

  • Some convenient methods for accessing common API calls, e.g. for login and upload.

  • Lightweight. pymw is a thin wrapper. Method signatures are very similar to the parameters in an actual API URL. You can consult MediaWiki’s documentation if in doubt about what a parameter does.

  • The post_and_continue method can handle most toomanyvalues errors by automatically splitting the violating parameter into several API calls. (not a feature to rely on in production, but nice to have during a console session for example.)

  • Supports setting a custom User-Agent header for each API instance.

Metadata

Release files for pymw 0.9.1

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

Source distribution (sdist)

Source distribution for pymw 0.9.1
File Size Uploaded
pymw-0.9.1.tar.gz 17.3 kB Details

Built distribution (wheel)

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

Total release size: 39.2 kB

Release files / pymw-0.9.1.tar.gz

Download URL pymw-0.9.1.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
14a30db808d4f7b907adb11546c17a3f3e328254c823d01c2e105dbb02e4da51
BLAKE2b-256 checksum
How to use checksums
48862c18f7386dd73a67dcf5aca7370d00dd6bf2554f63b659e9a78dd4486cee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b5

Release files / pymw-0.9.1-py3-none-any.whl

Download URL pymw-0.9.1-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cd083cd24af86f83475341b3081dfa6f8619724b253c2e636f1369dc63b2270
BLAKE2b-256 checksum
How to use checksums
1a98a57ce303ce57cc871f9798a583ed4c86552cad14015258c6eeb87faf7b68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b5

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

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