Crate mwapi[−][src]
Expand description
A MediaWiki API client library.
Goals:
- generic to fit any application, whether for interactive usage or writing a bot
- intended for use in async setups, and is compatible with being used with concurrency
- turns MediaWiki errors into Rust errors for you
- logging (using the
log
crate) for visiblity into errors
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
mwapi
handles low-level API functionality, including
- authentication, using BotPasswords or OAuth2
- error handling, transforming MediaWiki errors into Rust ones
- CSRF token handling with
post_with_token
- rate limiting and concurrency controls
- (planned) file uploads
More to come.
Re-exports
pub use client::Client;
pub use error::ErrorFormat;
Modules
Enums
Assert that your account has the specified login state, see API:Assert for more details.