API Connector Documentation
Import Moz Data to Google Sheets
In this guide, we’ll walk through how to pull data from the Moz API directly into Google Sheets, using the API Connector add-on for Sheets.
For this guide we'll show how to use their free API plan, but you can of course use their paid plans if you have access. We'll first get our Moz API credentials, and then set up a request to pull in data to your spreadsheet.
Content
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get Your Moz API Key
- If you haven't already, log into Moz.com
- Click Products > Moz Links API > Get Connected, or navigate directly to https://moz.com/products/api/pricing
- Click the Try it free! link. The free plan allows for one request every ten seconds, up to 2,500 rows per month.
- On the next page you'll need to enter your credit card details, even if you don't plan to upgrade. You won't be charged unless you upgrade to a paid account.
- Proceed through their payment form, accept their terms and conditions, and click Sign Up
- You'll now be presented with your credentials.
To encode your token, enter your credentials in the format
access_id:secret_key
into this form (i.e. your access ID, then a colon, and then your secret key).
The encoding script runs in your browser, and none of your credentials are seen or stored by this site.
Part 2: Pull Moz API Data into Sheets
You can create a request using any of the endpoints and parameters described in Moz's API documentation. For this example we'll get a list of Top pages on a target domain. Substitute your encoded credentials from above where it says your_encoded_credentials
.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- The MOZ API top pages endpoint requires constructing a request body containing all the filters and conditions of your request. So, in this example we will use "target", "scope" and "limit" in our request body
{ "target": "moz.com", "scope": "root_domain", "limit": 1 }
- In the request form enter the following:
- Application:
Custom
- Method:
POST
- Request URL:
https://lsapi.seomoz.com/v2/top_pages
- Headers:
Authorization
:Basic
your_encoded_credentials
- Request body:
{ "target": "moz.com", "scope": "root_domain", "limit": 20 }
- Application:
- 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 Coda data populate your sheet.
Part 3: More Example API URLS
- Anchor Text
- Method:
POST
- Request URL:
https://lsapi.seomoz.com/v2/anchor_text
- Request body:
{"target": "string", "scope": "string", "limit": number, "next_token: "string"}
- Method:
- URL Metrics
- Method:
POST
- Request URL:
https://lsapi.seomoz.com/v2/url_metrics
- Request body:
{"targets": ["string"], "daily_history_deltas": ["string"], "daily_history_values": ["string"], "monthly_history_deltas": ["string"], "monthly_history_values": ["string"], "distributions": boolean}
- Method:
- For other example of requests that can be made, do check the official Moz API documentation
Part 4: Handle Pagination
- Moz limits the the number of records returned in a response. By default the MOZ API top_pages endpoint sends 25 results in a response, but you can set any number between 1 and 50 as the number of responses per page as shown in their documentation:
- To get more results from subsequent pages, we can use the Cursor Body pagination option.
- Pagination type:
cursor body
- Next token parameter:
next_token
- Next token path:
next_token
- Run until:
response field empty
- Response field path:
next_token
- Pagination type:
Part 5: API Documentation
Official API documentation: https://moz.com/help/links-api