A library for interacting with MediaWiki API from Ruby. Uses adapter-agnostic Faraday gem to talk to the API.
Add this line to your application's Gemfile:
gem "mediawiki_api"
And then execute:
$ bundle
Or install it yourself as:
$ gem install mediawiki_api
Assuming you have MediaWiki installed via MediaWiki-Vagrant.
require "mediawiki_api"
client = MediawikiApi::Client.new "http://127.0.0.1:8080/w/api.php"
client.log_in "username", "password" # default Vagrant username and password are "Admin", "vagrant"
client.create_account "username", "password"
client.create_page "title", "content"
client.get_wikitext "title"
client.protect_page "title", "reason", "protections" # protections are optional, default is "edit=sysop|move=sysop"
client.delete_page "title", "reason"
client.upload_image "filename", "path", "comment", "ignorewarnings"
client.meta :siteinfo, siprop: "extensions"
client.prop :info, titles: "Some page"
client.query titles: ["Some page", "Some other page"]
Any API action can be requested using #action
. See the
MediaWiki API documentation for supported
actions and parameters.
MediaWiki API gem at: Gerrit, GitHub, RubyGems, Code Climate.
See https://www.mediawiki.org/wiki/Gerrit
- Fix error handling for token requests
- Automatic response parsing.
- Handling of API error responses.
- Watch/unwatch support.
- Query support.
- Public MediawikiApi::Client#action method for advanced API use.
- Added MediawikiApi::Client#protect_page.
- Updated documentation.
- Added MediawikiApi::Client#upload_image.
- Added MediawikiApi::Client#get_wikitext.
- Updated documentation.
- Complete refactoring.
- Removed MediawikiApi#create_article, #create_user and #delete_article.
- Added MediawikiApi::Client#new, #log_in, #create_page, #delete_page, #create_account.
- Added unit tests.
- Added MediawikiApi#delete_article.
- Added MediawikiApi#create_article and #create_user.