# Wiki Elixir

Unofficial Elixir client modules for connecting to Wikipedia and other MediaWiki sites.  Supports the Action, EventStreams, and Ores APIs.

API reference for the current version: [Documentation and examples](

* `Wiki.Action` connects to the [Action API](,
a rich set of commands to query or edit almost anything on a wiki.
* `Wiki.EventStreams` to access [EventStreams](,
a real-time feed of events.
* `Wiki.Ores` to access the [ORES]( service [API](,
machine-learning models for estimating revision and edit quality.

This library is beta-quality, and written by a beginning Elixir programmer so
please suggest improvements.  The public interface will evolve, and this
[0.x]( series in particular are likely to include breaking changes
between versions.  These will be documented in the [change log](

## Installation

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

def deps do
    {:wiki_elixir, "~> 0.2"}

Documentation is generated with `mix docs`.

## Usage

A simple call to the action API,

|> 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
#       }
#     }
#   },
#   ...
# }

See the module documentation for detailed usage and more examples.

### Error handling

Methods are all assertive, and will throw a `RuntimeError` with details about the
API error, or a `Tesla.Error` if a network failure is detected.

### Defaults

These parameters are set by default, but can be overridden by including again in an outer caller,

* The `:format` parameter defaults to `:json`.
* `:formatversion` defaults to `2`.

A few configuration variables are available under the `:wiki_elixir` application,
but setting is not mandatory.  Example overrides can be seen in
[config/test.exs](config/test.exs), in this case to mock network access.

* `:eventsource_adapter` - Defaults to `HTTPoison`, this will be used for the
EventStreams HTTP client.
* `:eventstream_endpoint` - API endpoint for `Wiki.EventStreams`, might be
overridden to target a staging server for example.
* `:ores_endpoint` - API endpoint for `Wiki.Ores`.
* `:tesla_adapter` - This will fall back to `Tesla.Adapter.Hackney`, as a stable
client which performs certificate validation.
* `:user_agent` - Sent in request headers, defaults to `wiki_elixir/<version>`...

## Development

Find the [project homepage]( on GitLab.
To contribute, please write a bug or merge request, or contact the author.

Several linters are configured, and may be run directly or called transparently
by installing the git pre-push hook,

```shell script
mix git_hooks.install

Then, `git push` will run all tests by default.  To push without passing tests, `git push --no-verify` to a branch.

To generate a test coverage report,
```shell script
mix coveralls.html