pub struct Builder { /* private fields */ }
Expand description
Build a new API client.
let client: Client = Client::builder("https://example.org/w/api.php")
.set_oauth2_token("foobar")
.set_errorformat(mwapi::ErrorFormat::Html)
.build().await?;
Implementations§
source§impl Builder
impl Builder
sourcepub fn new(api_url: &str) -> Self
pub fn new(api_url: &str) -> Self
Create a new Builder
instance. Typically you will use
Client::builder()
instead.
sourcepub fn set_user_agent(self, user_agent: &str) -> Self
pub fn set_user_agent(self, user_agent: &str) -> Self
Set a custom User-agent. Ideally follow the Wikimedia User-agent policy.
sourcepub fn set_oauth2_token(self, oauth2_token: &str) -> Self
pub fn set_oauth2_token(self, oauth2_token: &str) -> Self
Set an OAuth2 token for authentication
sourcepub fn set_errorformat(self, errorformat: ErrorFormat) -> Self
pub fn set_errorformat(self, errorformat: ErrorFormat) -> Self
Set the format error messages from the API should be in
sourcepub fn set_concurrency(self, concurrency: usize) -> Self
pub fn set_concurrency(self, concurrency: usize) -> Self
Set how many requests should be processed in parallel. On Wikimedia wikis, you shouldn’t exceed the default of 1 without getting permission from a sysadmin.
sourcepub fn set_maxlag(self, maxlag: u32) -> Self
pub fn set_maxlag(self, maxlag: u32) -> Self
Pause when the servers are lagged for how many seconds? Typically bots should set this to 5, while interactive usage should be much higher.
See mediawiki.org for more details.