Search API Connector Documentation
Import MapBox Directions Data to Google Sheets
- 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 Navigation service contains a directions API that shows you how to reach your destination. Although this API is made to pull a route on the map, a route can be pulled into the sheets giving the coordinates and geometry columns. This API can be used for:
- calculation of optimal routes for driving, walking, and cycling
- turn-by-turn instructions
- 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 would 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 the MapBox Directions API documentation.
- API root: https://api.mapbox.com/directions/v5/
To retrieve directions you should use following API link:
Please note: In order to retrieve directions you must specify at least two waypoints as starting and ending points.
PART 3: PULL MAPBOX API DATA INTO GOOGLE SHEETS
Now, let’s find a route between two points! In this example, we will pull a cycling route between two endpoints (-122.42, 37.78) and (-77.03, 38.91).
- 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.
- Request to access speed limit information using the max speed annotation between 3 passed pair of coordinates using the driving profile:
- Request a walking route between two locations:
- Request directions with radiuses and a polyline response through multiple waypoints:
- Request a route that approaches the destination on the curb of the driving side:
- Specify a departure time:
- Specify waypoints:
PART 5: LIMITATIONS
- Requests using the driving, walking, and cycling profiles can specify up to 25 total waypoints along the route.
- Requests using the driving-traffic profile can specify up to 3 waypoints along the route.
- Maximum 300 requests per minute.
- Maximum total of 10,000 kilometers between all waypoints.