mwapi

Crates.iomwapi
lib.rsmwapi
version
sourcesrc
created_at2021-06-18 07:00:06.025524
updated_at2024-11-23 13:08:47.117334
descriptionA MediaWiki API client library
homepagehttps://www.mediawiki.org/wiki/mwbot-rs
repositoryhttps://gitlab.wikimedia.org/repos/mwbot-rs/mwbot/
max_upload_size
id411656
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
cratesio (github:mwbot-rs:cratesio)

documentation

README

mwapi

crates.io docs.rs docs (main) pipeline status coverage report

A MediaWiki API client library.

mwapi is a low-level library for the MediaWiki Action API. If you intend to edit pages or want a higher-level interface, it's recommended to use mwbot, which builds on top of this crate.

Goals

  • generic to fit any application, whether for interactive usage or writing a bot
  • fully compatible with concurrent use cases
  • turns MediaWiki errors into Rust errors for you
  • logging (using the tracing crate) for visiblity into errors
  • follow all best practices

Quick start

let client = mwapi::Client::builder("https://en.wikipedia.org/w/api.php")
    .set_user_agent("mwapi demo")
    // Provide credentials for login:
    // .set_botpassword("username", "password")
    .build().await?;
let resp = client.get_value(&[
    ("action", "query"),
    ("prop", "info"),
    ("titles", "Taylor Swift"),
]).await?;
let info = resp["query"]["pages"][0].clone();
assert_eq!(info["ns"].as_u64().unwrap(), 0);
assert_eq!(info["title"].as_str().unwrap(), "Taylor Swift");

Functionality

  • authentication, using OAuth2 (recommended) or BotPasswords
  • error handling, transforming MediaWiki errors into Rust ones
  • CSRF token handling with post_with_token
  • rate limiting and concurrency controls
  • file uploads (needs upload feature)

See also

  • mwbot provides a higher level interface to interacting with MediaWiki
  • mwapi_responses is a macro to generate strict types for dynamic API queries

Contributing

mwapi is a part of the mwbot-rs project. We're always looking for new contributors, please reach out if you're interested!

License

This crate is released under GPL-3.0-or-later. See COPYING for details.

Commit count: 0

cargo fmt