Google Cloud

Predicting future travel times with the Google Maps APIs

Nov 10, 2015

[[read-time]] min read

  • If your application is used for scheduling deliveries, and you want to ensure you’ve allowed enough time between deliveries so your drivers won’t be late, you might want to use the pessimistic travel time estimates.
  • On the other hand, if you’re building a thermostat app, and you want the house to be warm by the time your user arrives home from work, you might want to use the optimistic travel time estimate to calculate when the user is likely to arrive.
  • If you want to give your user an estimate of the most likely travel time to their destination, the default best_guess traffic model will give you the most likely travel time considering both current traffic conditions and historical averages.

google map api travel time

“Taking the guesswork out of knowing how long it will take to drive between homes will help us provide a better customer experience to our users” – Curtis Howell, Product Manager Customer Engagement, Redfin

Related stories

Cloud_Gen-AI-Hero_2

101 real-world gen AI use cases featured at Google Cloud Next ’24

Next_Customer-Highlights-Hero_2 (1)

How 7 businesses are putting Google Cloud’s AI innovations to work

A (1)

How Best Buy is using generative AI to create better customer experiences

Cloud next 2024: more momentum with generative ai.

Workspace Cloud Next 2024

5 Workspace announcements from Google Cloud Next '24

7iptHNgwwfv7c2g

What's cooking: How Hellmann's is using Google Cloud AI to turn leftovers into meals

Let’s stay in touch. Get the latest news from Google in your inbox.

TravelTime Logo

Google Distance Matrix API vs. the TravelTime API: Which is Best for You?

9 minute read

By: victoria akinsowon

This post compares the product features of the Google Distance Matrix API and the TravelTime API. If you’re just looking to compare pricing and API limits, read this post instead. It compares prices with Google, Mapbox, Here, Graphhopper and more.

In this post, we’ll compare the differences between Google’s Distance Matrix API and the TravelTime API, including their matrix functionality, map services and support.

Distance Matrix CTA

What is the Travel Time Matrix API?

The Travel Time Matrix API allows you to calculate travel times to thousands of locations simultaneously, within milliseconds and for any mode of transport.

TravelTime also has two other APIs:

  • Isochrone API: Create isochrone maps to visualise where you can reach within a time limit
  • Routes API: Generate A to B routes, including turn-by-turn directions
  • Consumer-facing websites and apps: You can use the TravelTime API to filter, rank and list location search results by travel time on your website or app. The API can filter thousands of locations in milliseconds and is used in a range of different use cases, including recruitment and property websites.
  • Location analysis: You can also use TravelTime for location analysis , including office relocation or retail site selection. Here, the API can be used in a number of GIS software, including ArcGIS, QGIS and Alteryx.

What is the Google Distance Matrix API?

The Google Distance Matrix API allows you to calculate travel distance and time between multiple origins and destinations.

Common use cases for the Distance Matrix API include vehicle routing and analysis of traffic systems.

At a glance: the Google Distance Matrix API vs. TravelTime API

cta banner

Comparing distance matrix features

In this section, we’ll compare the functionality of Google’s Distance Matrix API with that of the TravelTime API.

The TravelTime API allows you to calculate a matrix of travel times between thousands of origins and destinations. Additionally, you can set a maximum travel time cut-off to automatically filter locations as reachable or unreachable.

Finally, TravelTime currently supports over 100 countries , with public transport data available for the vast majority of them. You can check out our list of supported countries here .

The Google Distance Matrix API lets you calculate the travel times for up to 25 origins or 25 destinations in one request.

‍ Key differences

1. matrix speed & performance.

With TravelTime’s performance and limits, you can calculate large volumes of times in under 100 milliseconds. This means it can be used within consumer-facing location searches without impacting app load times.

In contrast, it would be too slow to do this with Google’s Distance Matrix API if the consumer app has more than 25 locations.

2. Matrix multi-modal transport options

The TravelTime API calculates travel times for all transport modes. For public transport, you can choose one mode of public transport (which includes bus, train, subway, tram, coach and ferry) or you can also combine modes. This includes driving and train combined, driving and ferry combined, and cycling and ferry combined.

The Google Distance Matrix API calculates distances and times for public transport, driving, walking and cycling.

3. Fare data options

TravelTime provides fare data for public transport in the UK only. This includes data for standard, weekly, monthly and annual tickets.

Google provides fare data for public transport where available. This includes data for a standard ticket.

Comparing map services

Both Google and TravelTime also offer map services in addition to their matrix functionality. In this section, we’ll compare the map services of their APIs.

Isochrone API

Isochrones are maps that allow you to visualise all reachable locations within a time limit and by mode of transport.

isochrone

With the TravelTime API, you can create high-resolution isochrones for any type of public transport, as well as driving, cycling and walking. You can also combine transport modes – for example, to see where you can travel to within 30 minutes by driving and train. 

The API comes with adjustable parameters, which means you can customise your desired maximum walk times, transport connection times and more. What’s more, you have the flexibility to create isochrones through the API or, alternatively, though one of our dedicated GIS plugins .

In contrast, the Google Distance Matrix API doesn’t support the creation of isochrones through its API, nor does Google itself provide a built-in way to generate isochrones. 

You can use the TravelTime Routing API to create A-to-B routes, including turn-by-turn directions, and visualise these routes on a map or as a set of door-to-door instructions.

This can be done for all modes of transport, including all forms of public transport.

google map api travel time

If you want to do routing via Google, you will need to use Google’s separate Directions API.

You can use the Directions API to receive directions between locations for different transport modes, including driving, walking, cycling and public transport. Note that this is priced separately.

Geocoding and map tiles

Free unlimited access to geocoding and map tiles is included with every paid TravelTime API plan.

For geocoding, coordinates can be used to display addresses on a map or as inputs for other TravelTime API endpoints.

You will need to use Google’s separate Geocoding API to return geocoding information, and its separate Maps API for map tiles.

cta banner

How to create a distance matrix with the TravelTime API

To create a distance matrix, you first need to get a TravelTime API key .

Creating a distance matrix requires a single POST request, with a number of required parameters. These include:

  • Transportation type (these include ‘driving’, ‘public_transport’ and ‘walking’)
  • Departure or Arrival time
  • Travel time

To calculate a matrix with multiple origins and multiple destinations , you can simply add multiple searches into the request. Each of these searches can then include up to 2,000 locations. Learn more about creating a distance matrix here.

Alternatively, try our Matrix Developer Playground for free here .

TravelTime  

As standard, TravelTime’s support plans come with documentation, a comprehensive knowledge base and tutorials.

However, there are additional tiers that come with even more support. For example, the Standard tier includes a support portal, email support, onboarding workshop and a dedicated Customer Success Manager.

The Premium tier includes all the above, plus a 12-hour guaranteed first response time and 99.9% service uptime SLA.

  • ‍ Discover our support plans here

Google 

Support for the Google Distance Matrix API is comprised of a Stack Overflow Community, where you can ask technical questions, and is monitored by members of the Google Maps Platform team.

Alternatively, you can create support cases directly to the Maps Support Team – although this is restricted to Project Owners, Project Editors and Tech Support Editors only. According to Google, response times can take up to 24 hours on weekdays.

What customers say about the TravelTime API

Comprehensive transport data.

“TravelTime was the tool that stood out: it was the most reliable and the scope of its transport data was broader than any other service we considered.”

- Hugo Michalski, Co-Founder & CTO, Side

google map api travel time

$1 See how Side uses TravelTime

Layering travel time data with additional datasets

“It’s been great to analyse the data we get from TravelTime alongside other datasets like census or population data, to tell us how many people we can reach from certain locations.” 

- Tim Hirst, Data Scientist, SEGRO  

google map api travel time

Learn how SEGRO uses TravelTime

Better user experience

“TravelTime has enriched our user experience and increased conversions by 10%."

- Christophe De Rassenfosse, Chief Product Officer, Totaljobs

google map api travel time

See how Totaljobs uses TravelTime

Reliable and fast

“The TravelTime API is easy to use, reliable and fast - it’s an asset to our search functionality.” 

- Leo Lapworth, Web Operations Director, Foxtons

google map api travel time

Learn how Foxton uses TravelTime

TravelTime vs. Google: Which solution is best for me?  

Both the Google’s Distance Matrix API and the Travel Time Matrix API can calculate travel times and distances between locations with different transport modes.

However, the TravelTime API is more cost-effective than the Google Distance Matrix API for calculating large matrices of travel times at once.

And with a dedicated in-house data team , TravelTime offers a comprehensive and broad range of transport data, which includes all forms of public transport. This means that you can easily calculate travel times by the transport mode of your choice without breaking the bank.

TravelTime also comes with additional functionality that you may not have previously considered.

These include the ability to visualise travel times on a map (isochrones), as well as routing, geocoding and map tiles – all of which are included within all paid plans. And unlike Google, you won’t have to pay for separate APIs if you were looking to use these additional map services.

To learn more about what you can do with the TravelTime API,  check out our documentation  or to try TravelTime for yourself,  sign up for a free API key .

Calculate thousands of travel times with the TravelTime API

Read related articles

featured

  • Google Maps Platform
  • Español – América Latina
  • Português – Brasil
  • Tiếng Việt
  • Web Services
  • Directions API
  • Documentation

Getting directions through the Directions API

For direction calculations that respond in real time to user input (for example, within a user interface element), you can use the Directions API or, if you're using the Maps JavaScript API, use the Directions service . For server-side use, you can use Java Client, Python Client, Go Client and Node.js Client for Google Maps Services .

With the Directions API, you can:

  • Search for directions for several modes of transportation, including transit, driving, walking or cycling.
  • Return multi-part directions using a series of waypoints.
  • Specify origins, destinations, and waypoints as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia"), as place IDs, or as latitude/longitude coordinates

The API returns the most efficient routes when calculating directions. Travel time is the primary factor optimized, but the API may also take into account other factors such as distance, number of turns and many more when deciding which route is the most efficient.

Before you begin

Before you start using the Directions API, you need a project with a billing account and the Directions API enabled. To learn more, see Set up in Cloud Console .

Building your Directions API requests

A Directions API request takes the following form:

where outputFormat may be either of the following values:

  • json (recommended) indicates output in JavaScript Object Notation (JSON)
  • xml indicates output as XML

Note : URLs must be properly encoded to be valid and are limited to 16384 characters for all web services. Be aware of this limit when constructing your URLs.

As is standard in URLs, all parameters are separated using the ampersand ( & ) character. All reserved characters (for example the plus sign "+") must be URL-encoded . The list of parameters and their possible values are enumerated below.

Required parameters

Destination.

The place ID, address, or textual latitude/longitude value to which you wish to calculate directions. The options for the destination parameter are the same as for the origin parameter.

The place ID, address, or textual latitude/longitude value from which you wish to calculate directions.

Place IDs must be prefixed with place_id: . You can retrieve place IDs from the Geocoding API and the Places API (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see Place Autocomplete and Directions . For more about place IDs, see the Place ID overview .

If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.

Using place IDs is preferred over using addresses or latitude/longitude coordinates. Using coordinates will always result in the point being snapped to the road nearest to those coordinates - which may not be an access point to the property, or even a road that will quickly or safely lead to the destination.

If you pass coordinates, the point will snap to the nearest road. Passing a place ID is preferred. If you do pass coordinates, ensure that no space exists between the latitude and longitude values.

Plus codes must be formatted as a global code or a compound code. Format plus codes as shown here (plus signs are url-escaped to %2B and spaces are url-escaped to %20 ).

  • Global code is a 4 character area code and 6 character or longer local code (849VCWC8+R9 is 849VCWC8%2BR9 ).
  • Compound code is a 6 character or longer local code with an explicit location (CWC8+R9 Mountain View, CA, USA is CWC8%2BR9%20Mountain%20View%20CA%20USA ).

Optional parameters

Alternatives.

If set to true , specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server. This is only available for requests without intermediate waypoints. For more information, see the guide to waypoints .

arrival_time

Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time , but not both. Note that arrival_time must be specified as an integer.

Indicates that the calculated route(s) should avoid the indicated features. This parameter supports the following arguments:

  • tolls indicates that the calculated route should avoid toll roads/bridges.
  • highways indicates that the calculated route should avoid highways.
  • ferries indicates that the calculated route should avoid ferries.
  • indoor indicates that the calculated route should avoid indoor steps for walking and transit directions.

It's possible to request a route that avoids any combination of tolls, highways and ferries by passing multiple restrictions to the avoid parameter. For example:

departure_time

Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. If a departure_time later than 9999-12-31T23:59:59.999999999Z is specified, the API will fall back the departure_time to 9999-12-31T23:59:59.999999999Z. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). The departure time may be specified in two cases:

  • For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
  • For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. The departure_time must be set to the current time or some time in the future. It cannot be in the past.

The language in which to return results. Note that this applies only to the geocoded addresses in start_address and end_address , the localized text in distance and duration fields (in legs and steps), and the description of maneuvers in html_instructions , but not to the names and addresses in html_instructions , which are formatted in their local language and script.

  • See the list of supported languages . Google often updates the supported languages, so this list may not be exhaustive.
  • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header.
  • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
  • If a name is not available in the preferred language, the API uses the closest match.
  • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.

For the calculation of distances and directions, you may specify the transportation mode to use. By default, DRIVING mode is used. By default, directions are calculated as driving directions. The following travel modes are supported:

  • driving (default) indicates standard driving directions or distance using the road network.
  • walking requests walking directions or distance via pedestrian paths & sidewalks (where available).
  • bicycling requests bicycling directions or distance via bicycle paths & preferred streets (where available).
  • transit requests directions or distance via public transit routes (where available). If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference .

The region code, specified as a ccTLD ("top-level domain") two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").

traffic_model

Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where the request includes a departure_time . The available values for this parameter are:

  • best_guess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departure_time is to now.
  • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value.
  • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

The default value of best_guess will give the most useful predictions for the vast majority of use cases. It is possible the best_guess travel time prediction may be shorter than optimistic , or alternatively, longer than pessimistic , due to the way the best_guess prediction model integrates live traffic information.

transit_mode

Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions. The parameter supports the following arguments:

  • bus indicates that the calculated route should prefer travel by bus.
  • subway indicates that the calculated route should prefer travel by subway.
  • train indicates that the calculated route should prefer travel by train.
  • tram indicates that the calculated route should prefer travel by tram and light rail.
  • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway .

transit_routing_preference

Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. This parameter may only be specified for transit directions. The parameter supports the following arguments:

  • less_walking indicates that the calculated route should prefer limited amounts of walking.
  • fewer_transfers indicates that the calculated route should prefer a limited number of transfers.

Specifies the unit system to use when displaying results.

Directions results contain text within distance fields that may be displayed to the user to indicate the distance of a particular "step" of the route. By default, this text uses the unit system of the origin's country or region.

For example, a route from "Chicago, IL" to "Toronto, ONT" will display results in miles, while the reverse route will display results in kilometers. You may override this unit system by setting one explicitly within the request's units parameter, passing one of the following values:

  • metric specifies usage of the metric system. Textual distances are returned using kilometers and meters.
  • imperial specifies usage of the Imperial (English) system. Textual distances are returned using miles and feet.

Specifies an array of intermediate locations to include along the route between the origin and destination points as pass through or stopover locations. Waypoints alter a route by directing it through the specified location(s). The API supports waypoints for these travel modes: driving, walking and bicycling; not transit. You can supply one or more locations separated by the pipe character ( | or %7C ), in the form of a place ID, an address, or latitude/longitude coordinates. By default, the Directions service calculates a route using the waypoints in the order they are given. The precedence for parsing the value of the waypoint is place ID, latitude/longitude coordinates, then address.

  • If you pass a place ID, you must prefix it with place_id: . You can retrieve place IDs from the Geocoding API and the Places API (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see Place Autocomplete and Directions . For more about place IDs, see the Place ID overview . For efficiency and accuracy, use place ID's when possible. These ID's are uniquely explicit like a lat/lng value pair and provide geocoding benefits for routing such as access points and traffic variables. Unlike an address, ID's do not require the service to perform a search or an intermediate request for place details; therefore, performance is better.
  • If you pass latitude/longitude coordinates, the values go directly to the front-end server to calculate directions without geocoding. The points are snapped to roads and might not provide the accuracy your app needs. Use coordinates when you are confident the values truly specify the points your app needs for routing without regard to possible access points or additional geocoding details. Ensure that a comma ( %2C ) and not a space ( %20 ) separates the latitude and longitude values.
  • If you pass an address, the Directions service will geocode the string and convert it into latitude/longitude coordinates to calculate directions. If the address value is ambiguous, the value might evoke a search to disambiguate from similar addresses. For example, "1st Street" could be a complete value or a partial value for "1st street NE" or "1st St SE". This result may be different from that returned by the Geocoding API. You can avoid possible misinterpretations using place IDs.
  • Encoded polylines must be prefixed with enc: and followed by a colon ( : ). For example: waypoints=enc:gfo}EtohhU: .
  • You can also include multiple encoded polylines, separated by the pipe character ( | ). For example, waypoints=via:enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:| via:enc:udymA{~bxM:

Influence routes with stopover and pass through points

For each waypoint in the request, the directions response appends an entry to the legs array to provide the details for stopovers on that leg of the journey.

If you'd like to influence the route using waypoints without adding a stopover, add the prefix via: to the waypoint. Waypoints prefixed with via: will not add an entry to the legs array, but will route the journey through the waypoint.

The following URL modifies the previous request such that the journey is routed through Lexington without stopping:

The via: prefix is most effective when creating routes in response to the user dragging the waypoints on the map. Doing so allows the user to see how the final route may look in real-time and helps ensure that waypoints are placed in locations that are accessible to the Directions API.

Optimize your waypoints

By default, the Directions service calculates a route through the provided waypoints in their given order. Optionally, you may pass optimize:true as the first argument within the waypoints parameter to allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order. (This optimization is an application of the traveling salesperson problem.) Travel time is the primary factor which is optimized, but other factors such as distance, number of turns and many more may be taken into account when deciding which route is the most efficient. All waypoints must be stopovers for the Directions service to optimize their route.

If you instruct the Directions service to optimize the order of its waypoints, their order will be returned in the waypoint_order field within the routes object. The waypoint_order field returns values which are zero-based.

The following example calculates a road journey from Adelaide, South Australia to each of South Australia's main wine regions using route optimization.

Inspection of the calculated route will indicate that calculation uses waypoints in the following waypoint order:

Directions examples

The following request returns driving directions from Toronto, Ontario to Montreal, Quebec.

By changing the mode and avoid parameters, the initial request can be modified to return directions for a scenic bicycle journey that avoids major highways.

The following request searches for transit directions from Brooklyn, New York to Queens, New York. The request does not specify a departure_time , so the departure time defaults to the current time:

The following transit request includes a specific departure time.

Note: In this example the departure time is specified as July 30, 2012 at 09:45 am. To avoid an error, you must change the parameter to a time in the future before submitting the request.

The following request uses plus codes to return driving directions from H8MW+WP to GCG2+3M in Kolkata, India.

The following request returns driving directions from Glasgow, UK to Perth, UK using place IDs.

Travel modes

When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:

  • driving (default) indicates standard driving directions using the road network.
  • walking requests walking directions via pedestrian paths & sidewalks (where available).
  • bicycling requests bicycling directions via bicycle paths & preferred streets (where available).
  • transit requests directions via public transit routes (where available). If you set the mode to transit , you can optionally specify either a departure_time or an arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference .

Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.

Traffic information

Traffic information is used when all of the following apply (these are the conditions required to receive the duration_in_traffic field in the Directions response):

  • The travel mode parameter is driving , or is not specified ( driving is the default travel mode).
  • The request includes a valid departure_time parameter . The departure_time can be set to the current time or some time in the future. It cannot be in the past.
  • The request does not include stopover waypoints . If the request includes waypoints, prefix each waypoint with via: to influence the route but avoid stopovers. For example, &waypoints=via:San Francisco|via:Mountain View|...

Optionally, you can include the traffic_model parameter in your request to specify the assumptions to use when calculating time in traffic.

The following URL initiates a Directions request for a journey from Boston, MA to Concord, MA, via Charlestown and Lexington. The request includes a departure time, meeting all the requirements to return the duration_in_traffic field in the Directions response.

When calculating routes using the Directions API, you may specify waypoints to return a route that includes pass throughs or stopovers at intermediate locations. You can add waypoints to driving, walking or bicycling directions but not transit directions.

Specify locations in the waypoints parameter.

You can supply one or more locations separated by the pipe character ( | or %7C ), in the form of a place ID, an address, or latitude/longitude coordinates. By default, the Directions service calculates a route using the waypoints in the order they are given. The precedence for parsing the value of the waypoint is place ID, latitude/longitude coordinates, then address.

For efficiency and accuracy, use place ID's when possible. These ID's are uniquely explicit like a lat/lng value pair and provide geocoding benefits for routing such as access points and traffic variables. Unlike an address, ID's do not require the service to perform a search or an intermediate request for place details; therefore, performance is better.

  • If you pass an address, the Directions service will geocode the string and convert it into latitude/longitude coordinates to calculate directions. If the address value is ambiguous, the value might evoke a search to disambiguate from similar addresses. For example, "1st Street" could be a complete value or a partial value for "1st street NE" or "1st St SE". This result may be different from that returned by the Geocoding API. You can avoid possible misinterpretations using place IDs. See troubleshooting the results of my route request.

Alternatively, you can supply an encoded set of points using the Encoded Polyline Algorithm . You will find an encoded set is useful for a large number of waypoints, because the URL is significantly shorter. All web services have a URL limit of 16384 characters.

The following URL initiates a Directions request for a journey between Boston, MA and Concord, MA with stopovers in Charlestown and Lexington, in that order. The example uses addresses:

The following URL requests waypoints using latitude/longitude coordinates:

Here is the same request, using an encoded polyline:

Note that you can freely intermix a via: specifier with location modifiers . For example:

By default, the Directions service calculates a route through the provided waypoints in their given order. Optionally, you may pass optimize:true as the first argument within the waypoints parameter to allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order. (This optimization is an application of the traveling salesperson problem .) Travel time is the primary factor which is optimized, but other factors such as distance, number of turns and many more may be taken into account when deciding which route is the most efficient. All waypoints must be stopovers for the Directions service to optimize their route.

Restrictions

Directions may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid. The following restrictions are supported:

  • avoid=tolls
  • avoid=highways
  • avoid=ferries

It's possible to request a route that avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter. For example: avoid=tolls|highways|ferries .

Note: the addition of restrictions does not preclude routes that include the restricted feature; it biases the result to more favorable routes.

Unit systems

Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters.

Region biasing

You can set the Directions service to return results from a specific region by using the region parameter. This parameter takes a two-character ccTLD (country code top-level domain) argument specifying the region bias. Most ccTLD codes are identical to ISO 3166-1 alpha-2 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" ( .co.uk ) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland"). See Google Maps Platform Coverage Details for supported regions.

You may utilize any domain in which the main Google Maps application has launched driving directions.

For example, a directions request for "Toledo" to "Madrid" returns appropriate results when region is set to es and "Toledo" is then interpreted as the Spanish city:

A directions request for "Toledo" to "Madrid" sent without a region parameter does not return results, because "Toledo" is interpreted as the city in Ohio and not Spain:

Location Modifiers

You can use location modifiers to indicate how drivers should approach a particular location, by using the side_of_road parameter to specify which side of the road to use, or by specifying a heading to indicate the correct direction of travel. These modifiers may be freely mixed with the via: modifier for intermediate waypoints.

Specify that routes must pass through a particular side of the road

When specifying a waypoint, you can request that the route go through whichever side of the road the waypoint is biased towards by using the side_of_road: prefix. For example, this directions request will return a long route so that the vehicle ends on the side of the road to which the waypoint was biased:

When using side_of_road: with encoded polylines, the parameter is applied to every location along the polyline.

The side_of_road: modifier may only be used with the following restrictions:

  • The travel mode parameter is driving , or is not specified ( driving is the default travel mode).

Specify that routes should have a particular heading

When specifying a waypoint, you can request that the route go through the waypoint in a particular heading. This heading is specified with the prefix heading=X: , where X is an integer degree value between 0 (inclusive) and 360 (exclusive). A heading of 0 indicates North, 90 indicates East, and so on, continuing clockwise. For example, in this directions request the route goes east from the origin, then takes a U-turn:

The heading=X: modifier may only be used with the following restrictions:

  • The travel mode parameter is driving , bicycling , or is not specified ( driving is the default travel mode).
  • The side_of_road modifier is not specified for the same location.
  • The location is specified with a latitude/longitude value. You may not use heading with addresses, Place IDs, or encoded polylines.

Directions responses

Directions responses are returned in the format indicated by the output flag within the URL request's path.

A sample HTTP request is shown below, calculating the route from Chicago, IL to Los Angeles, CA via two waypoints in Joplin, MO and Oklahoma City, OK.

The above example requests JSON output. It's also possible to request XML output. Select the tabs below to see the sample JSON and XML responses.

The remainder of this documentation will use JSON syntax. In most cases, the output format does not matter for purposes of illustrating concepts or field names in the documentation. However, note the following subtle differences:

  • XML results are wrapped in a root <DirectionsResponse> element.
  • JSON denotes entries with multiple elements by plural arrays (such as steps and legs ), while XML denotes these using multiple singular elements (such as <step> and <leg> ).
  • JSON denotes waypoint order via the waypoint_order field, while XML denotes these using individual <waypoint_index> elements.
  • Blank elements are indicated through empty arrays in JSON, but by the absence of any such element in XML. A response that generates no results will return an empty routes array in JSON, but no <route> elements in XML, for example.

DirectionsResponse

Directionsroute.

Routes consist of nested legs and steps .

A rectangle in geographical coordinates from points at the southwest and northeast corners.

LatLngLiteral

An object describing a specific location with Latitude and Longitude in decimal degrees.

DirectionsLeg

Directionsstep.

Each element in the steps array defines a single step of the calculated directions. A step is the most atomic unit of a direction's route, containing a single step describing a specific, single instruction on the journey. E.g. "Turn left at W. 4th St." The step not only describes the instruction but also contains distance and duration information relating to how this step relates to the following step. For example, a step denoted as "Merge onto I-80 West" may contain a duration of "37 miles" and "40 minutes," indicating that the next step is 37 miles/40 minutes from this step.

When using the Directions API to search for transit directions, the steps array will include additional transit details in the form of a transit_details array. If the directions include multiple modes of transportation, detailed directions will be provided for walking or driving steps in an inner steps array. For example, a walking step will include directions from the start and end locations: "Walk to Innes Ave & Fitch St". That step will include detailed walking directions for that route in the inner steps array, such as: "Head north-west", "Turn left onto Arelious Walker", and "Turn left onto Innes Ave".

TextValueObject

An object containing a numeric value and its formatted text representation.

DirectionsPolyline

Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values. If you only have a few static points, you may also wish to use the interactive polyline encoding utility.

The encoding process converts a binary value into a series of character codes for ASCII characters using the familiar base64 encoding scheme: to ensure proper display of these characters, encoded values are summed with 63 (the ASCII character '?') before converting them into ASCII. The algorithm also checks for additional character codes for a given point by checking the least significant bit of each byte group; if this bit is set to 1, the point is not yet fully formed and additional data must follow.

Additionally, to conserve space, points only include the offset from the previous point (except of course for the first point). All points are encoded in Base64 as signed integers, as latitudes and longitudes are signed values. The encoding format within a polyline needs to represent two coordinates representing latitude and longitude to a reasonable precision. Given a maximum longitude of +/- 180 degrees to a precision of 5 decimal places (180.00000 to -180.00000), this results in the need for a 32 bit signed binary integer value.

  • DRIVING (default) indicates calculation using the road network.
  • BICYCLING requests calculation for bicycling via bicycle paths & preferred streets (where available).
  • TRANSIT requests calculation via public transit routes (where available).
  • WALKING requests calculation for walking via pedestrian paths & sidewalks (where available).

DirectionsTransitDetails

Additional information that is not relevant for other modes of transportation.

DirectionsTransitStop

Timezonetextvalueobject.

An object containing Unix time, a time zone, and its formatted text representation.

DirectionsTransitLine

Directionstransitagency, directionstransitvehicle, directionstrafficspeedentry, directionsviawaypoint.

The total fare for the route.

DirectionsStatus

The status field within the Directions response object contains the status of the request, and may contain debugging information to help you track down why the Directions service failed. The status field may contain the following values:

  • OK indicates the response contains a valid result.
  • NOT_FOUND indicates at least one of the locations specified in the request's origin, destination, or waypoints could not be geocoded.
  • ZERO_RESULTS indicates no route could be found between the origin and destination.
  • MAX_WAYPOINTS_EXCEEDED indicates that too many waypoints were provided in the request. For applications using the Directions API as a web service, or the directions service in the Maps JavaScript API, the maximum allowed number of waypoints is 25, plus the origin and destination.
  • MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed. This error occurs when more complex directions are returned. Try reducing the number of waypoints, turns, or instructions.
  • INVALID_REQUEST indicates that the provided request was invalid. Common causes of this status include an invalid parameter or parameter value.
  • The API key is missing or invalid.
  • Billing has not been enabled on your account.
  • A self-imposed usage cap has been exceeded.
  • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the service has received too many requests from your application within the allowed time period.
  • REQUEST_DENIED indicates that the service denied use of the directions service by your application.
  • UNKNOWN_ERROR indicates a directions request could not be processed due to a server error. The request may succeed if you try again.

DirectionsGeocodedWaypoint

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-04-12 UTC.

Predicting future travel times with the Google Maps APIs

Elena kelareva.

Product Manager, Google Maps APIs

  • If your application is used for scheduling deliveries, and you want to ensure you’ve allowed enough time between deliveries so your drivers won’t be late, you might want to use the pessimistic travel time estimates.
  • On the other hand, if you’re building a thermostat app, and you want the house to be warm by the time your user arrives home from work, you might want to use the optimistic travel time estimate to calculate when the user is likely to arrive.
  • If you want to give your user an estimate of the most likely travel time to their destination, the default best_guess traffic model will give you the most likely travel time considering both current traffic conditions and historical averages.

https://storage.googleapis.com/gweb-cloudblog-publish/images/Predictive_Maps.max-700x700.png

“Taking the guesswork out of knowing how long it will take to drive between homes will help us provide a better customer experience to our users” – Curtis Howell, Product Manager Customer Engagement, Redfin

  • Inside Google Cloud

Related articles

https://storage.googleapis.com/gweb-cloudblog-publish/images/whats_new.max-700x700.jpg

What’s new with Google Cloud

By Google Cloud Content & Editorial • 3-minute read

What’s new with Google Cloud - 2023

By Google Cloud Content & Editorial • 29-minute read

https://storage.googleapis.com/gweb-cloudblog-publish/images/Google_Cloud_AIML_thumbnail.max-700x700.jpg

Shared fate: Protecting customers with generative AI indemnification

By Neal Suggs • 4-minute read

https://storage.googleapis.com/gweb-cloudblog-publish/images/People-of-GC_Jack_Ngare.max-700x700.jpg

“The time is now.” Why this Kenyan Googler is betting on Africa’s tech opportunity

There’s a lot your users can figure out about a place just by exploring your map–what’s nearby, whether the locations are relatively close to each other, and even roughly how far a place is based on the map’s scale. With Google Maps Platform you can take some of the guesswork out of the picture by quantifying distances via straight line distance and route distance . Each uses a different approach and solves for different user problems or actions. So today we’re explaining what each is, when to use one over the other, and how to get started. 

To make these points, we’ll plot some distances on a map with some handy JavaScript. And because to calculate any sort of distance requires point A and point B, we’ll start by adding two markers to a basic Google Map:

Here we can see Central Park, as well as two nearby landmarks. The Dakota, perhaps most famous as John Lennon’s home. And The Frick Collection, an art gallery.

Suppose these were both on a New York City tour. You might be interested to know how far it is from one to the other. We’ll answer that question with some 200 year-old number crunching.

**Calculate the straight line distance from latitude and longitude**The simplest method of calculating distance relies on some advanced-looking math. Known as the Haversine formula, it uses spherical trigonometry to determine the great circle distance between two points. Wikipedia has more on the formulation of this popular straight line distance approximation.

To visualize the calculation, we can draw a Polyline between the two markers. Add the following lines after the markers in the JavaScript:

Reload the map and you should see a dark, diagonal line connecting the two markers, from one side of Central Park to the other. Using the JavaScript equivalent of the Haversine formula, we can determine the length of the Polyline, the straight distance between our two markers.

Add this function to your JavaScript, before the initMap function:

The function accepts two marker objects and returns the distance between them in miles. To use kilometers, set R = 6371.0710 . Before applying the Haversine formula, the function converts each marker’s latitude and longitude points into radians.

To call the function and report the distance below the map, add this code below your Polyline in the initMap function:

Load the map and you’ll see the following:

Now we know the straight line distance between The Dakota and The Frick Collection is 0.60 miles (rounded to two decimal places using the JavaScript toFixed function).

Of course, unless you’re a pigeon, your jaunt between the two locations is likely to be longer. A quick glance at the map shows there is no road or even pathway straight across Central Park. The Haversine formula is useful for basic proximity, but is insufficient for many use cases, especially within cities. For a more accurate travel distance, we’ll need to use another feature of the Maps JavaScript API.

**Get Directions with the Maps JavaScript API**When the straight line distance is not adequate, you’ll need more than a formula to determine the travel distance. Driving directions are one of the most popular features in Google Maps, so it’s unsurprising that it’s also made available via an API. You can use the Directions API for server-side requests, or the Directions Service in the Maps JavaScript API for client-side requests on the web.

Since our JavaScript map is already set, we’ll continue by using the Directions Service. Paste the following at the end of your initMap function:

After a successful call to the directions service, you’ll have the route added to the map. The message below the map is also extended to include the distance.

With a quick visual inspection, it’s clear that driving directions are much farther than the straight line distance. We can dig into the data that comes back in the response to find driving distance (1.6 miles, two and a half times farther), as well as the estimated duration. Here’s a JSON representation of the relevant section from the response:

While our example used driving directions, you can also pass other values to the travelMode field in your route object. The directions service can also accept  BICYCLING , TRANSIT , and WALKING values. Try adjusting the mode and running the code again to see how the directions result changes.

Which distance should I use? The two distance types in this post are useful in different scenarios. To give your users the best experience, you should use each in the appropriate situation.

You can use straight line distance to make quick calculations without a call to an external service. You’ll need to include the Haversine function used in this tutorial, but all you need are map coordinates to get an accurate result within the browser. However, as the name suggests, the distance will be a simple straight line. Roads, obstructions, and traffic are not factored into straight line distance.

Route distance, on the other hand, will return the distance along a route, including necessary turns and an understanding of the area’s traffic patterns. Due to the complexity of these calculations, route distance requires a call to the Directions Service, which will also return the duration of the route and even the path to plot visually on a map.

Whether you’re measuring distances around the globe or across town, use one of these approaches to help your users better understand their surroundings and make decisions. To explore even more tools for helping users get from here to there, check out the Google Maps Platform Routes APIs . And for more information on Google Maps Platform, visit our website .

Google Maps Travel Time

The google_travel_time sensor provides travel time from the Google Distance Matrix API .

You need to register for an API key by following the instructions here . You only need to turn on the Distance Matrix API.

Google now requires billing to be enabled (and a valid credit card loaded) to access Google Maps APIs. The Distance Matrix API is billed at US$10 per 1000 requests, however, a US$200 per month credit is applied (20,000 requests). The sensor will update the travel time every 5 minutes, making approximately 288 calls per day. Note that at this rate, more than 2 sensors will likely exceed the free credit amount. While this call frequency can not be decreased, you may have a use case which requires the data to be updated more often, to do this you may update on-demand (see automation example below).

A quota can be set against the API to avoid exceeding the free credit amount. Set the ‘Elements per day’ to a limit of 645 or less. Details on how to configure a quota can be found here

Configuration

To add the Google Maps Travel Time integration to your Home Assistant instance, use this My button:

If the above My button doesn’t work, you can also perform the following steps manually:

Browse to your Home Assistant instance.

Go to Settings > Devices & Services .

In the bottom right corner, select the Add Integration button.

From the list, select Google Maps Travel Time .

Follow the instructions on screen to complete the setup.

  • Origin and Destination can be the address or the GPS coordinates of the location (GPS coordinates have to be separated by a comma). You can also enter an entity ID that provides this information in its state, an entity ID with latitude and longitude attributes, or zone friendly name (case sensitive).

Dynamic Configuration

Tracking can be setup to track entities of type device_tracker , zone , sensor and person . If an entity is placed in the Origin or Destination then every 5 minutes when the platform updates it will use the latest location of that entity.

Tracking entity to entity

Origin: device_tracker.mobile_phone Destination: zone.home

Tracking entity to zone friendly name (e.g. “Eddies House”)

Origin: zone.home Destination: Eddies House

Entity Tracking

  • If state is a zone then the zone location will be used
  • If state is not a zone it will look for the longitude and latitude attributes
  • Uses the longitude and latitude attributes
  • Can also be referenced by just the zone’s friendly name found in the attributes.
  • If state is a zone or zone friendly name then will use the zone location
  • This includes all valid locations listed in the Configuration Variables

Updating sensors on-demand using Automation

Using automatic polling can lead to calls that exceed your API limit, especially when you are tracking multiple travel times using the same API key. To use more granular polling, disable automated polling.

You can use the homeassistant.update_entity service to update the sensor on-demand. For example, if you want to update sensor.morning_commute every 2 minutes on weekday mornings, you can use the following automation:

For more detailed steps on how to define a custom polling interval, follow the procedure below.

Defining a custom polling interval

If you want to define a specific interval at which your device is being polled for data, you can disable the default polling interval and create your own polling automation.

To add the automation:

  • Go to Settings > Devices & Services , and select your integration.

Disable polling for updates

  • Go to Settings > Automations & Scenes and create a new automation.
  • Define any trigger and condition you like.

Update entity

  • Save your new automation to poll for data.

Help us to improve our documentation

Get tips to file federal and state tax returns, boost tax refunds, avoid IRS penalties and more.

Popular Searches

AARP daily Crossword Puzzle

Hotels with AARP discounts

Life Insurance

AARP Dental Insurance Plans

Suggested Links

Red Membership Card

AARP MEMBERSHIP — $12 FOR YOUR FIRST YEAR WHEN YOU SIGN UP FOR AUTOMATIC RENEWAL

Get instant access to members-only products and hundreds of discounts, a free second membership, and a subscription to AARP the Magazine.

Help icon

  • right_container

Work & Jobs

Social Security

AARP en Español

Help icon

  • Membership & Benefits
  • AARP Rewards
  • AARP Rewards %{points}%

Conditions & Treatments

Drugs & Supplements

Health Care & Coverage

Health Benefits

woman and man working out at a gym

Staying Fit

Your Personalized Guide to Fitness

Hearing Resource Center

AARP Hearing Center

Ways To Improve Your Hearing

An illustration of a constellation in the shape of a brain in the night sky

Brain Health Resources

Tools and Explainers on Brain Health

three vertical images next to each other; on left is a man coughing, center is someone on the phone, and right is woman outside holding cat

How to Save Your Own Life

Scams & Fraud

Personal Finance

Money Benefits

zoomed in map of the united states with map locator pins scattered around

View and Report Scams in Your Area

Tax-Aide Group Illustration

AARP Foundation Tax-Aide

Free Tax Preparation Assistance

a man and woman at home looking at a laptop together

AARP Money Map

Get Your Finances Back on Track

a grouping of white appliances including refrigerator, oven, washing machine, microwave, vacuum, electric tea kettle, radiator

Budget & Savings

Make Your Appliances Last Longer

Small Business

Age Discrimination

illustration of a woman working at her desk

Flexible Work

Freelance Jobs You Can Do From Home

A woman smiling while sitting at a desk

AARP Skills Builder

Online Courses to Boost Your Career

illustration of person in a star surrounded by designs and other people holding briefcases

31 Great Ways to Boost Your Career

a red and white illustration showing a woman in a monitor flanked by a word bubble and a calendar

ON-DEMAND WEBINARS

Tips to Enhance Your Job Search

green arrows pointing up overlaid on a Social Security check and card with two hundred dollar bills

Get More out of Your Benefits

A balanced scale with a clock on one side and a ball of money on the other, is framed by the outline of a Social Security card.

When to Start Taking Social Security

Mature couple smiling and looking at a laptop together

10 Top Social Security FAQs

Social security and calculator

Social Security Benefits Calculator

arrow shaped signs that say original and advantage pointing in opposite directions

Medicare Made Easy

Original vs. Medicare Advantage

illustration of people building a structure from square blocks with the letters a b c and d

Enrollment Guide

Step-by-Step Tool for First-Timers

the words inflation reduction act of 2022 printed on a piece of paper and a calculator and pen nearby

Prescription Drugs

9 Biggest Changes Under New Rx Law

A doctor helps his patient understand Medicare and explains all his questions and addresses his concerns.

Medicare FAQs

Quick Answers to Your Top Questions

Care at Home

Financial & Legal

Life Balance

Long-term care insurance information, form and stethoscope.

LONG-TERM CARE

​Understanding Basics of LTC Insurance​

illustration of a map with an icon of a person helping another person with a cane navigate towards caregiving

State Guides

Assistance and Services in Your Area

a man holding his fathers arm as they walk together outside

Prepare to Care Guides

How to Develop a Caregiving Plan

Close up of a hospice nurse holding the hands of one of her patients

End of Life

How to Cope With Grief, Loss

Recently Played

Word & Trivia

Atari® & Retro

Members Only

Staying Sharp

Mobile Apps

More About Games

AARP Right Again Trivia and AARP Rewards

Right Again! Trivia

AARP Right Again Trivia Sports and AARP Rewards

Right Again! Trivia – Sports

Atari, Centipede, Pong, Breakout, Missile Command Asteroids

Atari® Video Games

Throwback Thursday Crossword and AARP Rewards

Throwback Thursday Crossword

Travel Tips

Vacation Ideas

Destinations

Travel Benefits

a graphic of two surf boards in the sand on a beach in Hawaii.

Beach vacation ideas

Vacations for Sun and Fun

google map api travel time

Plan Ahead for Tourist Taxes

Two images of Seattle - Space Needle and a seafood display in the Pike Place Market - each one is framed in Polaroid style

AARP City Guide

Discover Seattle

cruise ship in body of water with trees and mountains in background

How to Pick the Right Cruise for You

Entertainment & Style

Family & Relationships

Personal Tech

Home & Living

Celebrities

Beauty & Style

A collage of stars from reality TV shows such as "The Voice," "The Great British Baking Show," "Survivor" and "American Idol."

TV for Grownups

Best Reality TV Shows for Grownups

actor robert de niro photographed by a a r p in new york city november twenty twenty three

Robert De Niro Reflects on His Life

cover of james patterson's book chase overlaid on a mysterious-looking illustration of a man in silhouette running past shadowy trees

Free Online Novel

Read 'Chase'

a person in bed giving a thumbs up

Sex & Dating

Spice Up Your Love Life

a woman holding onto a family tree when her branch has been cut off

Navigate All Kinds of Connections

illustration of person exercising in room with bookcase, chair with cat on it, end table, plant, treadmill, weight rack and workout bench

How to Create a Home Gym

a woman looks at her phone while taking her medication

Store Medical Records on Your Phone?

Close-up of Woman's hands plugging a mobile phone into a power bank  in a bar

Maximize the Life of Your Phone Battery

online dating safety tips

Virtual Community Center

Join Free Tech Help Events

a hygge themed living room

Create a Hygge Haven

from left to right cozy winter soups such as white bean and sausage soup then onion soup then lemon coriander soup

Soups to Comfort Your Soul

hand holding a spray bottle that appears to be spraying out flowers; blue background

AARP Smart Guide

Spring Clean All of Your Spaces

Driver Safety

Maintenance & Safety

Trends & Technology

bottom of car, showing one wheel on road near middle yellow lines

How to Keep Your Car Running

Talk

We Need To Talk

Assess Your Loved One's Driving Skills

AARP

AARP Smart Driver Course

A woman using a tablet inside by a window

Building Resilience in Difficult Times

A close-up view of a stack of rocks

Tips for Finding Your Calm

A woman unpacking her groceries at home

Weight Loss After 50 Challenge

AARP Perfect scam podcast

Cautionary Tales of Today's Biggest Scams

Travel stuff on desktop: map, sun glasses, camera, tickets, passport etc.

7 Top Podcasts for Armchair Travelers

jean chatzky smiling in front of city skyline

Jean Chatzky: ‘Closing the Savings Gap’

a woman at home siting at a desk writing

Quick Digest of Today's Top News

A man and woman looking at a guitar in a store

AARP Top Tips for Navigating Life

two women exercising in their living room with their arms raised

Get Moving With Our Workout Series

You are now leaving AARP.org and going to a website that is not operated by AARP. A different privacy policy and terms of service will apply.

Go to Series Main Page

25 Great Ways to Save on Travel

Your guide to saving on epic getaways — without skimping on fun.

Stephanie Vermillion,

illustration of an airplane in the sky sounded by clouds in the shape of dollar signs

Your travel bucket list doesn’t have to break the bank. To help you fulfill your globe-trotting goals — sans the high spending — we talked with travel industry professionals and writers about their favorite cost-saving tips. Here are 25 of the best ways to save on travel, and don’t forget to share your own budget-travel tips in the comments section at the bottom of the page.

1. Try a price prediction tool

Some budget travelers swear by only booking their flights on Tuesdays. Others suggest booking on Saturdays. But according to Nick Ewen, senior editorial director for The Points Guy, “that ‘day to book’ thing is largely a myth.” What could matter? The day of the week, or the time of day, you actually fly. Tuesdays, Wednesdays and Saturdays are often cheaper days to fly than Fridays or Sundays. Because prices fluctuate, Ewen recommends using tools such as Hopper , Google Flights or Kayak to track and monitor when a flight is a good deal and when it’s not. “Price prediction tools will essentially say, ‘Right now, prices on this route are high, but we expect them to drop within the next 30 to 45 days,’” he says, noting it’s not always a guarantee — but “these tools can help you make a more informed decision.”

Image Alt Attribute

AARP Membership — $12 for your first year when you sign up for Automatic Renewal

2. Cash in those airline miles

If you’ve built up miles with a specific airline, use them, says Ewen. “Any opportunity to use your miles to keep cash in your pocket is a good redemption,” he says. “I often see people who are new to the world of loyalty programs, points and miles, and they’re afflicted with analysis paralysis.” Instead of using their perks, they sit on them — but doing so could be costing you. “Points and miles are terrible long-term investments; they only lose value over time,” Ewen says. If you want to double-check the miles-to-money conversion before booking, try online calculators that tabulate this equation, including NerdWallet , Omni Calculator and The Point Calculator .

3. Track and modify your trip

Here’s even more incentive to book: In recent years, a growing number of U.S. airlines, including United, Delta, American and Alaska, have removed change fees. That means if you book a ticket, then see a better flight deal, you can modify your reservation and pocket the difference. This goes for not only flights booked with dollars, but also miles. “Since the pandemic, just about every airline, aside from basic economy status, has made award tickets, generally speaking ... are now fully refundable,” Ewen says. 

4. Keep tabs on your credit card discounts

If your credit card comes with a steep annual price, know that “oftentimes there are many ways to offset that fee,” Ewen says. Many cards offer travel credits, complimentary companion passes and other lifestyle perks. But to benefit, you need to actually use them. “Credit card issuers rely on people to not be informed; that way they can offer a perk that [would] cost them money, but they’re not actually going to have to fork that money over,” he says. To keep tabs on your card’s perks, which include everything from rideshare and TV subscription credits to grocery discounts, Ewen suggests checking your account every month and creating a spreadsheet of all available offers.

illustration of a person relaxing with a drink in an airport lounge, with his tablet plugged into his lounge chair and an airplane visible out the window

5.   Look into living the lounge life 

Airport lounges can help you save on overpriced terminal fare, and typically offer complimentary food and drink (in many cases alcoholic beverages), showers, less-crowded bathrooms, numerous charging ports and comfortable seating. Lounge life can improve the air transit experience, but there is a cost. Many airline lounges require a paid membership or can be accessed by paying annual fees on travel credit cards. These several-hundred-dollar annual fees come with a variety of perks, such as the opportunity to bring one or several guests free of charge. To determine if lounge membership fees are worth it, Ewen suggests crunching the numbers to see how often you plan to travel and how much you and your potential airport lounge guests could save on amenities. Additionally, if you do decide to obtain lounge membership, make sure your home or go-to airport has that specific airline lounge, he says.

6. Don’t shrug off shoulder season

Want to cut spending and dodge congestion? Travel journalist, photographer and founder of the blog Camels & Chocolate Kristin Luna has some advice: “Traveling in [the] off-season, or shoulder season, is my favorite way to travel — not only do you save money, but you avoid the crowds,” she says, noting that, on a November trip to Iceland — well outside the summer high season — she and her family saved big: “We paid roughly half of what we would have had we decided to travel in summer months.” They also saw a fraction of the crowds. Of course, traveling in the shoulder season can come with a downside, like seasonal closures or bad weather. Before booking a shoulder-season adventure, make sure the restaurants, attractions and experiences you hope to enjoy are still available.

7. Skip the gas pump 

Another way to save on rental cars: Go electric. “It may wind up being cheaper than filling up with gas, especially if you’re outside the U.S.,” says Ewen, noting gas in many destinations across Europe can be “incredibly expensive.” That said, an EV isn’t always the best option. “The big thing is going into it knowing exactly how you’re going to charge the car,” Ewen says. If you’re largely in the countryside, where there are minimal EV charging stations, you could end up in trouble. But if you’re mostly traveling between cities or large urban areas, you should be in the clear — although it’s smart to research EV guidelines for specific countries and regions before you book. For that, EV-focused websites like Chargemap , Electromaps and PlugShare can help.

8. Use credit card rental car insurance

If you have a travel credit card, odds are it includes rental car insurance — but you have to follow a few important steps to use it. First, decline all of the rental car company’s protection offerings, Ewen says. This includes roadside assistance, collision damage waiver — any and all protections. If you do have an issue during your trip — say, a cracked windshield — you can submit the claim by contacting your credit card company. Before you rely on this method, it’s important to know what’s included with your card’s insurance. “Coverage on car rentals through credit cards is limited to damage and theft,” Ewen says. If you have questions, call your credit card company (via the phone number on the back of your card) to confirm. When you prefer more coverage than what’s offered through your credit card — or you’d rather avoid dealing with the potential claims process — consider the rental car company’s options, but do your research ahead of time to avoid being pressured into any decisions.

Most Popular

newsletter-naw-tablet

AARP NEWSLETTERS

newsletter-naw-mobile

%{ newsLetterPromoText  }%

%{ description }%

Privacy Policy

ARTICLE CONTINUES AFTER ADVERTISEMENT

9. Take advantage of public transit

In many cities, using public transportation instead of a rental car or rideshare service can keep money in your pocketbook. Katie Holden of the blog Katie’s Travel Tricks suggests using an app, such as Google Maps , to navigate safely. “Just toggle over to the public transportation icon after you enter in your destination,” Holden says. “In some countries it even includes detailed instructions on which [station] exit to use.” To help with comparison, Google Maps will often provide an estimate of what a rideshare price would be for the same trip. Other public transit map options to consider include Moovit and Transit . Additionally, in places with robust train infrastructure, like Europe, you can save (and reduce your carbon emissions) by opting to train between destinations instead of flying.

illustration of a foot kicking a car tire that looks like a gold coin with a dollar sign on it

10.   Check out deals for your wheels 

Before you book a rental car, Ewen recommends checking a website like AutoSlash (alternatives include Expedia or Momondo ) to look for deals. These kinds of services incorporate your memberships, such as a Sam’s Club, AAA or AARP, then make recommendations on the best rental-car deals and saving options. Additionally, if you’re booking a rental car, always join the company’s loyalty program, Ewen says. These memberships, which are typically free, can help you skip the line and expedite the check-in process. Another way to save: Try an alternative transit mode. If you’re visiting only one city, consider renting a bike; many bicycle shops offer e-bike and regular bike rentals for either a few hours or several days — helping you save on not only rental cars and parking, but also gas.

11. Buy one, get one free with a stopover

Several airlines offer stopover programs that let you experience a city for a few days while en route to your final destination. This is a great way to get more bang for your travel buck, says Luna, who has used stopover offerings for a stint in Doha en route to Bangkok, a stop in Iceland while traveling to Germany, and a visit to New Zealand on the way to the Cook Islands. Since you don’t have to purchase additional flights in a stopover program, “it doesn’t cost more money, so it’s basically buy-one-get-one-free flights to see two places instead of one,” she says. 

12. Search for a seasonal deal

End-of-year savings aren’t just for holiday gifts. Many companies in the travel industry offer major discounts timed to Black Friday and Cyber Monday. The cruise industry also extends this savings potential with “wave season” (typically January through March), which is “when cruise lines do big pushes to get sales up,” says writer Mikkel Woodruff of the cruise website Sometimes Sailing. In addition to saving on your cruise booking itself, you may also snag goodies like free internet or discounted airfare. Additionally, during the spring, many car rental services need to move their vehicles in the south back north, which means it’s a great time to grab a deal on a one-way rental car if you’re looking for a spring road trip from, say, Florida to New England. 

13. Stay ahead of cell-service charges

International data charges can add up quickly. That’s why Holden recommends going into your trip armed with connectivity options. For example, apps like WhatsApp , Viber and Signal will help you text or call via Wi-Fi. It’s also helpful for booking dining or inquiring about tours. “Internationally, many businesses will have an option to contact them via WhatsApp,” says Holden. She also uses a cell plan that comes with international data and texting, which you can inquire about with your carrier pre-trip. And, if you know you’ll need faster data service, Holden recommends buying a local eSIM card.

14. Save big with senior passes

Memberships and passes can help you save big on your adventures, whether it’s using your AARP membership to get deals on car rentals, cruises or train travel, or taking advantage of senior discounts for museums. Additionally, if you’re planning a national parks trip, travel writer Emily Pennington shares some advice: “The number one thing to do is get the America the Beautiful Pass ,” she says. America the Beautiful covers the entrance fee for any National Park Service park, as well as lands managed by the U.S. Fish & Wildlife Service and several other federal organizations. Travelers age 62 and older can buy an annual pass for $20, or a lifetime pass for $80 (the price for a standard annual pass alone is $80). For another cost-saving trick, Pennington suggests volunteering with the park service for free park admission. “If people want to spend no money on the park pass, they can do a certain amount of volunteer hours and earn a free park pass that way.”

illustration of a person carrying a bag of groceries while pulling a roll-aboard suitcase behind him

15.   Stock up at a grocery store 

Dining out can take a major bite out of your travel budget. To avoid this — without skimping on the joy of travel cuisine — Luna suggests hitting the grocery for small meals and snacks. “If we’re staying somewhere multiple days in a row, the grocery store will be our first stop. We stock up on yogurt, fruit, other breakfast items, coffee and beverages,” Luna says. This way, you can save by having lunches at home, then splurge on restaurants for dinner. And, to ensure you’re not missing the cultural side of cuisine, skip the big-box grocery stores. “Street food or bodegas can be a great way to try the local flavors while not splurging on expensive meals,” Luna says. 

16. Look for budget-friendly tours

If you want to see a new destination but can’t splurge on a private guide, consider joining a “free” guided walking tour, offered through numerous services, such as Free Tour , Free Tours by Foot and GuruWalk . (Note that while there’s not a set fee for this tour, you should pay or tip what you think is appropriate.) Additionally, consider alternative tours that won’t break the bank but will help you authentically experience the culture. For that, Holden recommends options like Airbnb experiences. “These are experiences run by locals who are an expert in one area,” she says. “We learned to play Japanese card games in Nara, Japan, and dyed silk scarves in a marbled pattern in Florence, Italy.” Other locally led options include Tours by Locals and With Locals .

17. Download a free audio tour

For a more DIY budget-friendly sightseeing option, look to podcasts or audio tours. Well-known travel gurus like Rick Steves offer self-guided walking tours that use narration to immerse you in a new destination, while the app SmartGuide runs digital tours with audio guides, city maps and insider tips. The website VoiceMap also features hundreds of on-your-own audio walks, bike rides and drives, helping you see the highlights without needing to join a group or in-person guided tour.

18. Save on souvenirs

To save on souvenirs, skip the resort or airport gift shop where prices are typically inflated and consider craft markets or even grocery stores instead. According to Holden, it’s wise to go in knowing exactly what you want so you don’t overspend. “Everyone in our family has a certain small item they collect and we buy that — a statue for my daughter, a magnet for my son,” she says. “We also visit thrift stores and the local equivalent of a dollar store.”

19. Consider alternative accommodations

Options abound when it comes to booking overnights. Sure, hotels are great — and can come with great deals if booked using credit card points, says Holden — but alternative options like rental homes, hostels (many offer private rooms) and even couch surfing can help you save. Some may even help you make local connections. “We’ve used the website Couch Surfing to stay with strangers for free,” Holden says. Tripping.com also features couch-surfing rentals. For any sites, especially couch-surfing ones, be sure to read plenty of reviews. “Another budget option would be to watch someone’s pets in exchange for a free stay at their home,” Holden says. Numerous house-sitting options exist around the globe; to try it, join services like Trusted Housesitters , Nomador and Mind My House .

illustration of a person with a backpack in an airport walking past a window with a plane outside

20.   Go   carry-on   only 

Some travel credit cards offer one or two free checked bags. If you have this perk, take advantage of it. If not — or if you want to avoid the hassle of lugging heavy bags — Luna suggests opting for carry-on only. “Nearly every [U.S.] airline charges for checked bags,” she says. “I haven’t checked a bag in more than seven years, mostly because I don’t trust the airline not to lose [it].” Luna also says the carry-on lifestyle is easier than you might think: “Ditch all the unnecessary items like multiple pairs of shoes, purses, accessories, and stick to basics in neutral tones that you can layer.” But, before you pack, make sure to check your airline’s carry-on restrictions. Many airlines — particularly those outside the U.S. — have strict guidelines and will charge you a fee if your bag is overweight or larger than the allowed dimensions.

21. Expand your outbound airport options 

Many Americans live within driving distance of not just one but several airports. If you’re unable to find a budget-friendly flight from your nearest airport, consider looking within a driving radius of a few hours. Even with a drive, this could cut your total transit time — especially if you can nab a direct flight instead of multiple connections — and also save you money. Of course, to ensure you don’t overspend on pricey garage parking, build in plenty of travel time and park away from the main airport lot. Another option is to park nearby and take a shuttle or city transit to the airport. Wally Park has 10 locations in eight cities and allows people to park and shuttle to their airport. Boston’s  Park Shuttle & Fly and The Parking Spot have similar options. Some will even offer a free car wash before you exit. Additionally, you may be able to park a few transit stops away from the airport and save money on parking, too. Always look for coupons on airport parking before you reserve.

22. Invest in travel insurance

Don’t lose your money if you need to cancel a trip; instead, invest in travel insurance. “Travel insurance is important for any kind of travel where you have nonrefundable trip costs at stake that would be subject to you forfeiting money if something disrupted the trip or you had to cancel,” says Stan Sandberg, cofounder of insurance comparison site Travelinsurance.com. “When you’re traveling internationally, it becomes even more important for the traveler because with international travel, you’re going to have a more expensive trip.”

23. Know when to be loyal

When traveling, it can pay to be loyal, whether you get free upgrades on an airline or complimentary internet access with your hotel stay. For airlines, Ewen says determining which brand you’re loyal to should stem from where you live. If your hometown airport is a hub for one specific airline, it’s wiser to prioritize that airline to reap the loyalty rewards — but know that what you’ll get back largely depends on how often you travel. Sometimes, especially for casual travelers, it’s better to keep your options open. “The valuable perks of earning elite status really come for those who travel a ton for work — like once every other week,” Ewen says. So when should you be loyal? “Ask yourself if you would be willing to pay more for a preferred airline flight, or taking a more inconvenient route to be on your preferred airline. If the answer to one or both of those is no, don’t go crazy trying to be loyal.” Additionally, always look for hotel loyalty programs, because even free memberships can come with perks like early check-in, late check-out and the chance to earn rewards for discounted future stays.

24. Rack up points and miles on everyday purchases

You can build your credit card points and miles base not only by flying, but also by strategically spending on everyday purchases, Luna says. Her first rule of thumb: Ditch debit cards. “Use credit cards for everything: home purchases, groceries, renovation and gas,” she says, noting that with many travel credits cards, such as American Express Business Gold, Chase Sapphire Preferred or the Ink Business Preferred Credit, “those small bills can add up to a lot of points.” With these cards, you earn points for your spends, so consider checking to see if you can put your property tax, home insurance, gym membership or phone bill on a card, Luna says.

25. Outsource your travel hacking

Travel hacking can open up a new world of low-cost or free jet-setting opportunities, but you have to know what you’re doing — and it can take a bit of training and time. To help, some travel experts have launched courses on the subject; others offer coaching in travel hacking. But, if you want the travel hacking perks without the time expenditure, Ewen recommends looking into outsourcing, available with companies like I Fly With Miles , Point.Me and Jet Better . “You can basically hire them and pay them a small fee to maximize your points.” 

                                   More Members Only Access

Discover AARP Members Only Access

Already a Member? Login

You Might Also Like

illustration of three people in a row of seats on airplane; middle person has hands behind head and elbows in other passengers' space

Secrets from a Flight Attendant

How to make your trips more comfortable and easy

big cruise ship on water

Smart Guide to Cruises

Everything you need to know for smooth sailing

The full moon rises over mountain with saguaro cacti in front

Be a Citizen Scientist at National Parks

You can help staff identify invasive species and more

AARP Members Only Access

Enjoy special content just for AARP members, including full-length films and books, AARP Smart Guides, celebrity Q&As, quizzes, tutorials and classes

Recommended for You

AARP Value & Member Benefits

chicken parmesan lasagna fettucine alfredo caeser salad bread wine

Carrabba's Italian Grill®

10% off dine-in or curbside carryout orders placed by phone

woman smiling handing man credit card at hotel check in, other man sitting in background

AARP Travel Center Powered by Expedia: Hotels & Resorts

Up to 10% off select hotels

man sitting on couch looking at woman sitting on floor in living room during day time

ADT™ Home Security

Savings on monthly home security monitoring

couple on couch looking at tablet

AARP® Staying Sharp®

Activities, recipes, challenges and more with full access to AARP Staying Sharp®

SAVE MONEY WITH THESE LIMITED-TIME OFFERS

IMAGES

  1. Learn How to Build a Google Maps API using Javascript Travel mode with

    google map api travel time

  2. TravelTime maps API lets users search by time rather than distance

    google map api travel time

  3. Google Maps APIs Predictive Travel Time Feature

    google map api travel time

  4. Excel Google Maps Distance and Travel Time Calculator with Directions

    google map api travel time

  5. Accessing directions, timezones, coordinates and more with the Google

    google map api travel time

  6. What is Google Maps API and How To Use JavaScript SDK?

    google map api travel time

VIDEO

  1. Map Application

  2. lam ban do voi google map API

  3. درس 240 إستخدام خرائط جوجل Google Map API

  4. Android Google Map API Programming

  5. Video Showing Permissions and APIs that Access Sensitive Information policy For Google Review

  6. Calculate Delivery Time & Distance in Airtable using Google Maps API (New Version)

COMMENTS

  1. Distance Matrix API overview

    With the Distance Matrix API, you can provide travel distance and time for a matrix of origins and destinations. You can specify several options, including mode of transportation, such as driving, biking, transit or walking, as well as transit modes, such as bus, subway, train, tram, or rail. The Distance Matrix API provides information based ...

  2. Using Google Maps API to get travel time data

    25. Yep, this is definitely possible using the API. You can construct a GDirections object without a map or directions div. You can do a load request from A to B and then call the getDuration method to get the total travel time. First you need to create a directions object: // no need to pass map or results div since.

  3. Predicting future travel times with the Google Maps APIs

    Predictive travel time is available for both Standard Plan and Premium Plan customers in the Direction and Distance Matrix API, and for Premium Plan customers only in the JavaScript Maps API. To get started with the predictive travel time, visit our documentation on the Directions and Distance Matrix API and try it out by signing up online for ...

  4. Calculating travel time and distance using Google Maps API in R

    Enter the Google Maps API and the gmapsdistance package in R. To do this, we're going to write code that's going to instruct the Google API to give us back the distance and time from one location to another and store it in a useful data frame. ... #create a data frame with travel time and distance IDNYC_results = as.data.frame(gmapsdistance ...

  5. Google Distance Matrix API vs. the TravelTime API: A Comparison

    Both the Google's Distance Matrix API and the Travel Time Matrix API can calculate travel times and distances between locations with different transport modes. However, the TravelTime API is more cost-effective than the Google Distance Matrix API for calculating large matrices of travel times at once. And with a dedicated in-house data team ...

  6. How to Use Google Distance Matrix API on front-end or back-end ...

    Use google-maps-react API on the front-end. Before starting, make sure you perform the following steps: Create an API key via the Google API console. Go to the dashboard in the console and enable ...

  7. Travel Modes in Directions

    Travel Modes in Directions | Maps JavaScript API | Google for Developers. New map styling is coming soon to Google Maps Platform. This update to map styling includes a new default color palette and improvements to map experiences and usability. All map styles will be automatically updated in March 2025.

  8. Getting directions through the Directions API

    Getting directions through the Directions API. For direction calculations that respond in real time to user input (for example, within a user interface element), you can use the Directions API or, if you're using the Maps JavaScript API, use the Directions service . For server-side use, you can use Java Client, Python Client, Go Client and Node ...

  9. Predicting future travel times with the Google Maps APIs

    Today, we're bringing predictive travel time - one of the most powerful features from our consumer Google Maps experience - to the Google Maps APIs so businesses and developers can make their location-based applications even more relevant for their users. Predictive travel time uses historical time-of-day and day-of-week traffic data to ...

  10. google maps

    I want to find a travel time (including traffic) between two addresses. Inputs - origin, destination, arrival time, mode of transportation, traffic model (pessimistic, optimistic, best guess) Output - Travel time. It looks like the Google Distance Matrix API is the API I should be using for this except that I am not able to add an input of arrival time for driving.

  11. Google Maps API v3 Display Travel Time

    Using Google Maps API v3, is it possible to get the travel time to display when the map is opened initially? There's an example at this link of switching between travel modes. I know how to set an addEventListener to listen for an input change and then display the travel time, but I want to display the driving time when the map is first opened / loaded.. I am opening the map in a modal window.

  12. Full article: Estimating O-D travel time matrix by Google Maps API

    Figure 8 shows that travel time by the Google Maps API approach is consistently longer than that by the ArcGIS Network Analyst approach. The estimated travel time by either method correlates well with the (Euclidean) distance from the city center (with a R 2 = 0.91 for both methods). However, the regression model of travel time against ...

  13. Travel Time using Google API

    Google Maps API: Travel time with current traffic. 5. travel time between two locations in Google Map Android API V2. 0. Google Directions API Duration In Traffic. 0. Google maps api departureTime in directionsService. 1. How to show duration trip in google map api. 1.

  14. Getting TravelTime from Google Maps API for Javascript

    I am trying to get travel time with traffic between two locations. I have followed the documentation guide with all details, but I always get a fixed traveltime between two points regardless to ... Getting TravelTime from Google Maps API for Javascript. Ask Question Asked 7 years, 9 months ago. Modified 7 years, 9 months ago. Viewed 711 times

  15. How to calculate distances between points with the Maps JavaScript API

    To call the function and report the distance below the map, add this code below your Polyline in the initMap function: // Calculate and display the distance between markers. var distance = haversine_distance(mk1, mk2); document.getElementById('msg').innerHTML = "Distance between markers: " + distance.toFixed(2) + " mi.";

  16. Google Maps Travel Time

    The Distance Matrix API is billed at US$10 per 1000 requests, however, a US$200 per month credit is applied (20,000 requests). The sensor will update the travel time every 5 minutes, making approximately 288 calls per day. Note that at this rate, more than 2 sensors will likely exceed the free credit amount. While this call frequency can not be ...

  17. Google Maps

    Find local businesses, view maps and get driving directions in Google Maps.

  18. 25 Great Ways to Save on Travel

    In many cities, using public transportation instead of a rental car or rideshare service can keep money in your pocketbook. Katie Holden of the blog Katie's Travel Tricks suggests using an app, such as Google Maps, to navigate safely. "Just toggle over to the public transportation icon after you enter in your destination," Holden says.