Print

Import Wikipedia Data to Google Sheets

In this guide, we’ll show how to pull data from Wikipedia directly into Google Sheets, using the API Connector add-on for Sheets.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Pull Wikipedia API Data into Sheets

For this example, we'll pull in the most viewed Wikipedia articles in December, 2022. Where it says your_contact_info, enter your email address or the URL to a contact page. While this request will work without including it, Wikipedia requests that you set a unique User-Agent that allows them to contact you quickly.

  1. Open up Google Sheets and click Extensions > API Connector > Open > Create request.
  2. In the request form enter the following:
    • ApplicationCustom
    • MethodGET
    • Request URLhttps://wikimedia.org/api/rest_v1/metrics/pageviews/top/en.wikipedia/all-access/2022/12/all-days
    • Headers:
      • User-Agentyour_contact_info
  3. Create a new tab and click Set current to use that tab as your data destination.
  4. Name your request and click Run.
    wikipedia-toparticles

Part 2: More Example API URLs

Experiment with endpoints as described in the documentation. If you just want to get started, you can try out the following requests, one at a time:

  • Fetch a random Wikipedia article:
    https://en.wikipedia.org/api/rest_v1/page/random/summary
  • Get metadata and an abstract about a specific page:
    https://en.wikipedia.org/api/rest_v1/page/summary/Google_Sheets
  • List of births on a specific day:
    https://en.wikipedia.org/api/rest_v1/feed/onthisday/births/06/02
  • Pageviews per day for in April 2020 for the Wikipedia article on Tiger King
    https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/Tiger_King/daily/20200401/20200430

Part 3: API Documentation

Official API documentation: https://en.wikipedia.org/api/rest_v1/

Pageview analytics documentation: https://wikitech.wikimedia.org/wiki/Analytics/AQS/Pageviews

Leave a Comment

Jump To