View Source MediaWiki client

Unofficial client modules for connecting to Wikipedia, Wikidata, and other MediaWiki sites from Elixir code. Supports multiple APIs: Action, EventStreams, and Scoring.

API reference for the current version: Documentation and examples

Overview:

Installation

Install this package by adding mediawiki_client to your dependencies in mix.exs,

def deps do
  [
    {:mediawiki_client, "~> 0.4.0"}
  ]
end

Documentation is generated with mix docs.

Updating

Please see the change log for a history of breaking changes. This library is still pre-1.0 and open to improvement.

Livebook examples

An Livebook notebook is included to demonstrate usage.

livebook server notebooks/demo.livemd

Quick start

Fetch some statistics about German Wikipedia,

Wiki.SiteMatrix.new()
|> Wiki.SiteMatrix.get!("dewiki")
|> Wiki.Action.new()
|> Wiki.Action.get!(
  action: :query,
  meta: :siteinfo,
  siprop: :statistics
)
# %Wiki.Action.Session{
#   ...
#   result: %{
#     "batchcomplete" => true,
#     "query" => %{
#       "statistics" => %{
#         "activeusers" => 19687,
#         "admins" => 188,
#         "articles" => 2583285,
#         "edits" => 211219883,
#         "images" => 130199,
#         "jobs" => 0,
#         "pages" => 7163473,
#         "queued-massmessages" => 0,
#         "users" => 3715461
#       }
#     }
#   },
#   ...
# }

Additional examples are included in the source documentation .

Error handling

Most methods come in an assertive and a non-assertive form, for example the Wiki.Action.get() method returns an {:ok, ...} or a {:error, ...} tuple, and Wiki.Action.get!() throws the error directly.

Development

The project homepage is on GitLab. To contribute, feel free to start with an issue, push a merge request, or contact maintainers.

To run all tests,

mix test.all

To generate a test coverage report,

mix coveralls.html