Why use the Roads API
With the Roads API, you can get speed limits, estimated arrival times, or other road metadata. With this road metadata, you can enhance your driving apps with the follow capabilities:
- Connect latitude/longitude coordinates with a road or roads.
- Find the nearest road for a set of coordinates
- Get speed limits for road segments
What you can do with the Roads API
With the Roads API, you can map GPS coordinates to the geometry of the road, and determine the speed limit along road segments.
- Snap to Roads This service returns the most likely roads traveled based on the provided set of GPS coordinates. You can specify up to 100 GPS points collected along a route. Optionally, you can also request that the service interpolates additional points, resulting in a path that smoothly follows the geometry of the road.
- Nearest Roads This service returns the nearest road segment for a GPS point. You can specify up to 100 GPS points. The points you specify do not need to be part of a continuous path.
- Speed limits This service returns the posted speed limit for a road segment. The Speed Limit service is available to all customers with an Asset Tracking license. For Google Maps Platform Premium Plan customers who transitioned to pay-as-you-go pricing, the feature remains active.
How the Roads API works
The Roads API uses three endpoints which accept latitude/longitude coordinates or place IDs to provide road paths, segments, or speed limit data. The following example shows a request for nearest roads based on a set of latitude/longitude coordinates:
https://roads.googleapis.com/v1/nearestRoads ?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796 &key=YOUR_API_KEY
The following table summarizes the resources available through the Roads API along with the data it returns.
|Data resources||Data returned||Return format|
|Snap to roads||
Returns an array of up to 100 GPS points from a route. Includes road-snapped longitude/latitude coordinates along with place IDs. See details in Responses in the Snap to roads guide.
An array of up to 100 independent latitude/longitude coordinates along with place IDs for the nearest road for each specified point. Points do not need to be continuous. See details in Responses in the Nearest roads guide.
An array of up to 100 road metadata elements. These contain speed limits and place IDs, with units either in KPH or MPH. See details in Responses in the Speed limits guide.
How to use the Roads API
|1||Try the snap to roads demo||Click on the demo to create a track and see how the snap to roads endpoint provides smooth data. See Demo in the Snap to roads guide. You do not need an API key.|
|2||Get set up||Start with Set up your Google Cloud project and complete the setup instructions that follow and then learn how to use your API key.|
|3||Try a snap to roads request||Use one of the snap to roads examples and try one relevant to your use case.|
|4||Get speed limits for your road path||Using the same path data you provided for your snap to roads request, issue a speed limit query. See the Example request using a path.|
|5||Learn how to process long paths||Follow the sections on Processing long paths in the Advanced concepts guide.|
|6||Incorporate road data into your own app!||See the detailed code example from the road snapped demo to start building road data functionality into your own app.|
Available client libraries
Call this API in the language of your choice through one of the following client libraries:
- Java Client for Google Maps Services
- Python Client for Google Maps Services
- Go Client for Google Maps Services
- Node.js Client for Google Maps Services
The Java Client, Python Client, Go Client and Node.js Client for Google Maps Services are community-supported client libraries, open sourced under the Apache 2.0 License. Download them from GitHub, where you can also find installation instructions and sample code.