Skip to content

holocene-systems/wiki_elixir

 
 

Repository files navigation

Wiki Elixir

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.

Installation

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.

Usage

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.

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

Some parameters are set by default, but can be overridden by including in the query.

  • The :format parameter defaults to :json.
  • :formatversion defaults to 2.

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 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

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

About

Tools for working with Wikipedia data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%