Import MapBox Search Service Data to Google Sheets
MapBox provides four different services: Maps, Navigation, Search, and Accounts. In this tutorial, we will teach you how to use the MapBox Search Service with Google sheets, using the API Connector add-on for Sheets. We will first register to the website to get a personal token and then set up requests for getting the data from the MapBox Search API.
- Before You Begin
- Part 1: Get your Mapbox API Token
- Part 2: Create your API Request URL
- Part 3: Pull MapBox API data into Sheets
- Part 4: More Example API URLs
- Part 5: Limitations
BEFORE YOU BEGIN
Click here to install the API Connector add-on from the Google Marketplace.
PART 1: GET YOUR MAPBOX API TOKEN
The MapBox Search service contains a geocoding API which allows you to do forward and reverse geocoding operations. Conversion of a location’s name to coordinates represents forward geocoding, while the opposite operation that turns geographical coordinates into a location’s name is the reverse geocoding.
- To start using the MapBox API, we will need to register on the MapBox site. After email confirmation, you will be directed to this page which contains a default public token. However, we need to make a personal one. Click on the button Create a token.
Name your token and select all the scopes, and then save it.
Now you get your token, that you will need to run your requests!
PART 2: CREATE YOUR API REQUEST URL
To create API requests, we will use some examples provided in MapBox Geocoding API documentation.
- API root: https://api.mapbox.com/geocoding/v5/
Forward geocoding, which allows you to request the geographical coordinates for passed location name, needs to be constructed in the following way:
Reverse geocoding, which allows you to request a location name based on a sent geographical coordinates, needs to be constructed in the following way:
PART 3: PULL MAPBOX API DATA INTO GOOGLE SHEETS
Let’s pull some data! In this example, we will pull all the places named Belgrade on the map. Open API Connector to import the data into the sheets.
- Open up Google Sheets and click Add-ons > API Connector > Open.
- In the Create tab, enter the API URL constructed like this:
3. Now create a new tab, give it a name and click Set current to use that tab as your data destination.
4. Give a name to your request and click run!
5. And now you should be able to see the pulled data.
PART 4: MORE EXAMPLE API URLS
We encourage you to go through the provided documentation and explore more ways to pull the data, using optional parameters.
- Pull the coordinates for locations named Belgrade in the US (please note: permitted values are ISO 3166 alpha 2 country codes separated by commas):
- Pull the data that are on the map on (-73.989, 40.733):
- Pull the POI data that are on the map on (-73.989, 40.733):
PART 5: LIMITATIONS
- The Geocoding API rate limit is 600 requests per minute
- If you want to run multiple forward and reverse geocoding queries in a single request, you should use mapbox.places-permanent endpoint, which is a paid feature.