Unofficial Elixir client modules for Wikipedia and other MediaWiki sites.
About the current version: Documentation and examples
Overview:
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 an beginning Elixir programmer so please suggest improvements. The public interface will evolve, and the 0.x releases in particular are likely to include breaking changes between versions. These will be documented in the change log.
Install this package by adding wiki_elixir
to your dependencies in mix.exs
,
def deps do
[
{:wiki_elixir, "~> 0.1"}
]
end
Documentation is generated with mix docs
.
A simple call to the action API,
Wiki.Action.new("https://de.wikipedia.org/w/api.php")
|> Wiki.Action.get(
action: :query,
meta: :siteinfo,
siprop: :statistics
)
|> (&(&1.result)).()
|> IO.inspect()
See the module documentation for detailed usage and more examples.
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.
Some parameters are set by default, but can be overridden by including in the query.
- The
:format
parameter defaults to:json
. :formatversion
defaults to2
.
A few configuration variables are available under the :wiki_elixir
application,
but aren't necessary for normal use. Example overrides can be seen in
config/test.exs, in this case to mock network access.
:eventsource_adapter
- Defaults toHTTPoison
, this will be used for the EventStreams HTTP client.:eventstream_endpoint
- API endpoint forWiki.EventStreams
, might be overridden to target a staging server for example.:ores_endpoint
- API endpoint forWiki.Ores
.:tesla_adapter
- This will fall back toTesla.Adapter.Hackney
, as a stable client which performs certificate validation.:user_agent
- Sent in request headers, defaults towiki_elixir/<version>
...
The project's homepage is currently on GitLab. To contribute, please submit an issue or a merge request.
Several linters are configured, the easiest way to use them is to install the pre-push git hook using,
mix git_hooks.install