Search API Connector Documentation

Print

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.

CONTENTS

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.

  1. 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/
  • Endpoints:
    • /mapbox.places
    • /mapbox.places-permanent

Forward geocoding, which allows you to request the geographical coordinates for passed location name, needs to be constructed in the following way:

GET https://api.mapbox.com/geocoding/v5/{endpoint}/{search_text}.json?access?token=YOUR-TOKEN

Reverse geocoding, which allows you to request a location name based on a sent geographical coordinates, needs to be constructed in the following way:

GET https://api.mapbox.com/geocoding/v5/{endpoint}/{longitude},{latitude}.json?access?token=YOUR-TOKEN

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.

  1. Open up Google Sheets and click Add-ons > API Connector > Open.
  2. In the Create tab, enter the API URL constructed like this:
https://api.mapbox.com/geocoding/v5/mapbox.places/Belgrade.json?access_token=ENTER-YOUR-TOKEN

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):
https://api.mapbox.com/geocoding/v5/mapbox.places/Belgrade.json?country=US&access_token=YOUR-API-TOKEN
  • Pull the data that are on the map on (-73.989, 40.733):
https://api.mapbox.com/geocoding/v5/mapbox.places/-73.989,40.733.json?access_token=YOUR-API-TOKEN
  • Pull the POI data that are on the map on (-73.989, 40.733):
https://api.mapbox.com/geocoding/v5/mapbox.places/-73.989,40.733.json?types=poi&access_token=YOUR-API-TOKEN

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.
Previous Import MapBox Optimization Data to Google Sheets
Next Import Metals API Data to Google Sheets

Leave a Comment