Wikimedia Enterprise API Documentation

Introduction

Welcome to the Wikimedia Enterprise API Documentation and Reference guide. Wikimedia Enterprise provides a suite of APIs designed for high-volume access to Wikimedia project data; including Wikipedia and many others.

Here are some examples of what you can do with Wikimedia Enterprise APIs:

Download and import all of the Wikimedia project data you desire:

  • Call the Snapshot API to receive a bulk file containing all of the articles in a specific project, updated daily.

Look up a single Wikipedia project article in a consistent format:

Stream real time updates from Wikimedia projects into your system:

  • Hook into the Realtime Streaming API streams to have new updates (like live article revisions) pushed directly to your system as they happen.
  • Use the Realtime Batch API to download new updates within the last day in bulk (updated on the hour).

First Steps

Accessing the Wikimedia Enterprise API requires authentication credentials, known as tokens, that you must pass with each request. First, if you do not have an account, signup for a free account here.

Getting your API Keys

Wikimedia Enterprise APIs all use JWT authentication passed via the header for access control. Now that you’ve received your username and password, use them in the /login endpoint to receive your tokens.

All WME API requests must be made over HTTPS. Calls without authentication in the header will fail.

curl -L https://auth.enterprise.wikimedia.com/v1/login -H "Content-Type: application/json" -d '{"username": "janedoe","password":"secret"}'

Refresh token expires in 90 days, Access and ID tokens expire in 1 day. Use your Refresh token to obtain a new access token after it expires.

An important reminder: Your credentials carry many privileges related to your account, so be careful to keep them secure. Do not share your WME credentials in publicly accessible areas such as GitHub, client-side code, etc.

{
  "id_token": "...id token goes here...",
  "access_token": "...access token goes here...",
  "refresh_token": "...refresh token goes here...",
  "expires_in": 86400
}

Making your first calls

Now you are ready to make your first call. Start by running this curl command using your access_token to fetch the list of supported projects in Wikimedia Enterprise APIs.

You should receive a list of all supported Wikimedia projects, including the project language and the size of the download.  If not, check your credentials, and try again. Note the project id name (e.g. “enwiki” for English Wikipedia) as that is the identifier you will use to identify that project in other calls.

curl -H "Authorization: Bearer ACCESS_TOKEN" -L https://api.enterprise.wikimedia.com/v1/projects

Next, try using the Snapshot API. Run this curl command to download the Afrikaans Wikipedia snapshot to your machine.

Open the downloaded file to see newline-delimited JSON with a line representing each article in the project. To learn about the data provided for each article, visit the data dictionary.

curl -H "Authorization: Bearer ACCESS_TOKEN" -L https://api.enterprise.wikimedia.com/v1/exports/download/0/afwiki --output afwiki.tar.gz

Next, try calling the On-demand API to get a specific article of interest. Let’s use Douglas Adams in English Wikipedia as an example, with this curl command.

You should have received a JSON response containing the same data as an article represented in the Snapshot API’s English Wikipedia file. The main difference here (besides being able to query individually) is that this response returns the live version of the article that is actively on the project today, whereas the Snapshot updates daily (for paid users) or monthly (for free users). If you don’t have and are interested in daily access, contact us.

curl -H "Authorization: Bearer ACCESS_TOKEN" -L 'https://api.enterprise.wikimedia.com/v1/pages/meta/enwiki/Douglas%20Adams'

There you have it! You’ve made your first calls with Wikimedia Enterprise. Please explore the API reference, the data dictionary, or FAQs to find more ways you can use these APIs for your work.