Search API Connector Documentation
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.
- Before You Begin
- Part 1: Create your API Request URL
- Part 2: Pull Wikipedia API Data into Sheets
- Part 3: More Example API URLs
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Create Your API Request URL
We’ll first pull in information about a random Wikipedia article, then show how to extend this to other API requests.
- Base URL: https://en.wikipedia.org/api/rest_v1
- Endpoint: /page/random/summary
Putting it together, we get the full API Request URL:
Part 2: Pull Wikipedia API Data into Sheets
Now let’s enter that URL into API Connector.
- Open up Google Sheets and click Extensions > API Connector > Open.
- In the Create screen, enter the Request URL we just created
- Leave OAuth set to None.
- Under Headers, enter a key-value pair like this:
While this request will work without including a header, Wikipedia’s global API rules request that you set a unique User-Agent that allows them to contact you quickly. You may use an Email address or the URL to a contact page, like this:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see information about a random article populate your Google Sheet. If you’d like more random articles, switch to Append mode, and hit Run several times.
Part 3: More Example API URLs
Experiment with endpoints as described in the documentation here. If you just want to get started, you can try out the following requests, one at a time:
- Get metadata and an abstract about a specific page:
- List of births on a specific day:
- Pageviews per day for in April 2020 for the Wikipedia article on Tiger King
- Top 1000 articles in March, 2020 (Tip: switch to the Compact report style to avoid timing out):
The article Create API Request Based on a Cell describes how you can point to a cell to dynamically change the date or endpoint in the URL, which can be very convenient for constructing requests.
Part 4: API Documentation
Official API documentation: https://en.wikipedia.org/api/rest_v1/
Pageview analytics documentation: https://wikitech.wikimedia.org/wiki/Analytics/AQS/Pageviews