All Projects → magnusmanske → mediawiki_rust

magnusmanske / mediawiki_rust

Licence: Apache-2.0, Unknown licenses found Licenses found Apache-2.0 LICENSE-APACHE Unknown LICENSE-MIT
Rust API interface for MediaWiki sites.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to mediawiki rust

mediawiki-api-demos
Demo apps and code snippets in Python, Javascript and PHP demonstrating how to use various modules of the MediaWiki Action API
Stars: ✭ 125 (+443.48%)
Mutual labels:  mediawiki, mediawiki-api
scalawiki
scalawiki is a MediaWiki client in Scala
Stars: ✭ 30 (+30.43%)
Mutual labels:  mediawiki, mediawiki-api
Mwclient
Python client library to interface with the MediaWiki API
Stars: ✭ 221 (+860.87%)
Mutual labels:  mediawiki
Mermaid
Provides a parser function to generate diagrams and flowcharts with the help of the mermaid script language
Stars: ✭ 27 (+17.39%)
Mutual labels:  mediawiki
rdf2smw
Convert RDF to Semantic MediaWiki facts in MediaWiki XML format, with a standalone commandline tool
Stars: ✭ 18 (-21.74%)
Mutual labels:  mediawiki
discord-wiki-bot
Wiki-Bot is a bot with the purpose to easily search for and link to wiki pages. Wiki-Bot shows short descriptions and additional info about the pages and is able to resolve redirects and follow interwiki links.
Stars: ✭ 69 (+200%)
Mutual labels:  mediawiki
tutorials
Collection of tutorials for various libraries and technologies
Stars: ✭ 98 (+326.09%)
Mutual labels:  mediawiki
Mediawiki
🌻 The collaborative editing software that runs Wikipedia. Mirror from https://gerrit.wikimedia.org/g/mediawiki/core. See https://mediawiki.org/wiki/Developer_access for contributing.
Stars: ✭ 2,752 (+11865.22%)
Mutual labels:  mediawiki
WikibaseImport
Import entities from another Wikibase instance (e.g. Wikidata)
Stars: ✭ 25 (+8.7%)
Mutual labels:  mediawiki
wikibot
Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。
Stars: ✭ 26 (+13.04%)
Mutual labels:  mediawiki
go-mwclient
A Go package for interacting with the MediaWiki API.
Stars: ✭ 37 (+60.87%)
Mutual labels:  mediawiki-api
vicuna
Tool for uploading files to Wikimedia Commons and other Wikimedia projects
Stars: ✭ 36 (+56.52%)
Mutual labels:  mediawiki
matomo-mediawiki-extension
www.mediawiki.org/wiki/Extension:Piwik_Integration
Stars: ✭ 18 (-21.74%)
Mutual labels:  mediawiki
wiki-scripts
Framework for writing bots, maintenance scripts or performing data analysis on wikis powered by MediaWiki
Stars: ✭ 27 (+17.39%)
Mutual labels:  mediawiki-api
Wiktionaryparser
A Python Wiktionary Parser
Stars: ✭ 224 (+873.91%)
Mutual labels:  mediawiki
Nodemw
MediaWiki API client written in node.js
Stars: ✭ 216 (+839.13%)
Mutual labels:  mediawiki
SemanticWikibase
Makes Wikibase data available in Semantic MediaWiki
Stars: ✭ 14 (-39.13%)
Mutual labels:  mediawiki
SemanticExtraSpecialProperties
Provides extra special properties to Semantic MediaWiki.
Stars: ✭ 24 (+4.35%)
Mutual labels:  mediawiki
Dota2WebApi
A Dota 2 Web API for Liquipedia
Stars: ✭ 24 (+4.35%)
Mutual labels:  mediawiki
SemanticCite
Allows to manage citation resources using semantic annotations
Stars: ✭ 22 (-4.35%)
Mutual labels:  mediawiki

Build Status crates.io docs.rs

A MediaWiki client library in Rust

Examples

Get all categories of "Albert Einstein" on English Wikipedia

let mut api = mediawiki::api::Api::new("https://en.wikipedia.org/w/api.php").unwrap();

// Query parameters
let params = api.params_into(&[
    ("action", "query"),
    ("prop", "categories"),
    ("titles", "Albert Einstein"),
    ("cllimit", "500"),
]);

// Run query; this will automatically continue if more results are available, and merge all results into one
let res = api.get_query_api_json_all(&params).unwrap();

// Parse result
let categories: Vec<&str> = res["query"]["pages"]
    .as_object()
    .unwrap()
    .iter()
    .flat_map(|(_page_id, page)| {
        page["categories"]
            .as_array()
            .unwrap()
            .iter()
            .map(|c| c["title"].as_str().unwrap())
    })
    .collect();

dbg!(&categories);

Edit the Wikidata Sandbox Item (as a bot)

let mut api = mediawiki::api::Api::new("https://www.wikidata.org/w/api.php").unwrap();
api.login("MY BOT USER NAME", "MY BOT PASSWORD").unwrap();

let token = api.get_edit_token().unwrap();

let params = api.params_into(&[
    ("action", "wbeditentity"),
    ("id", "Q4115189"),
    ("data", r#"{"claims":[{"mainsnak":{"snaktype":"value","property":"P1810","datavalue":{"value":"ExampleString","type":"string"}},"type":"statement","rank":"normal"}]}"#),
    ("token", &token),
]);

let res = api.post_query_api_json(&params).unwrap();
dbg!(res);

Edit via OAuth

let json = json!({"g_consumer_key":"YOUR_CONSUMER_KEY","g_token_key":"YOUR_TOKEN_KEY"});
let oauth = mediawiki::api::OAuthParams::new_from_json(&json);
let mut api = mediawiki::api::Api::new("https://www.wikidata.org/w/api.php").unwrap();
api.set_oauth(Some(oauth));

Query Wikidata using SPARQL

let api = mediawiki::api::Api::new("https://www.wikidata.org/w/api.php").unwrap(); // Will determine the SPARQL API URL via site info data
let res = api.sparql_query ( "SELECT ?q ?qLabel ?fellow_id { ?q wdt:P31 wd:Q5 ; wdt:P6594 ?fellow_id . SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE],en'. } }" ).unwrap() ;
println!("{}", ::serde_json::to_string_pretty(&res).unwrap());

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].