Stay organized with collections Save and categorize content based on your preferences.
This demo shows you how to use the Directions API to get a set of driving directions from one location to another. You may run this demo at no charge. Running this demo alone does not exceed your monthly quota.
To use the Directions API, complete the required setup steps by clicking through the following tabs:
Step 1 ConsoleIn the Google Cloud console, on the project selector page, click Create Project to begin creating a new Cloud project.
Make sure that billing is enabled for your Cloud project. Confirm that billing is enabled for your project.
Google Cloud offers a $0.00 charge trial. The trial expires at either end of 90 days or after the account has accrued $300 worth of charges, whichever comes first. Cancel anytime. For more information, see Billing account credits and Billing.
gcloud projects create "PROJECT"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
Note: If you don't plan to keep the resources that you create in a learning exercise, create a project instead of selecting an existing project. After you finish the exercise, you can delete the project, removing all resources associated with the project. Step 2To use Google Maps Platform, you must enable the APIs or SDKs you plan to use with your project.
Console Cloud SDKgcloud services enable \ --project "PROJECT" \ "directions-backend.googleapis.com"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
Step 3This step only goes through the API Key creation process. If you use your API Key in production, we strongly recommend that you restrict your API key. You can find more information in the product-specific Using API Keys page.
The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.
To create an API key:
ConsoleGo to the Google Maps Platform > Credentials page.
gcloud services api-keys create \ --project "PROJECT" \ --display-name "DISPLAY_NAME"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
Getting directionsTo receive driving directions from Disneyland to Universal Studios, Hollywood in JSON format, enter the URL into your web browser, and replace YOUR_API_KEY with your API Key:
https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood&key=YOUR_API_KEY
You should receive the following JSON response:
{ "geocoded_waypoints" : [ { "geocoder_status" : "OK", "place_id" : "ChIJRVY_etDX3IARGYLVpoq7f68", "types" : [ "bus_station", "transit_station", "point_of_interest", "establishment" ] }, { "geocoder_status" : "OK", "partial_match" : true, "place_id" : "ChIJp2Mn4E2-woARQS2FILlxUzk", "types" : [ "route" ] } ], "routes" : [ { "bounds" : { "northeast" : { "lat" : 34.1330949, "lng" : -117.9143879 }, "southwest" : { "lat" : 33.8068768, "lng" : -118.3527671 } }, "copyrights" : "Map data ©2016 Google", "legs" : [ { "distance" : { "text" : "35.9 mi", "value" : 57824 }, "duration" : { "text" : "51 mins", "value" : 3062 }, "end_address" : "Universal Studios Blvd, Los Angeles, CA 90068, USA", "end_location" : { "lat" : 34.1330949, "lng" : -118.3524442 }, "start_address" : "Disneyland (Harbor Blvd.), S Harbor Blvd, Anaheim, CA 92802, USA", "start_location" : { "lat" : 33.8098177, "lng" : -117.9154353 }, ... Additional results shortened in this example[] ... "overview_polyline" : { "points" : "knjmEnjunUbKCfEA?_@]@kMBeE@qIIoF@wH@eFFk@WOUI_@?u@j@k@`@EXLTZHh@Y`AgApAaCrCUd@cDpDuAtAoApA{YlZiBdBaIhGkFrDeCtBuFxFmIdJmOjPaChDeBlDiAdD}ApGcDxU}@hEmAxD}[tt@yNb\\yBdEqFnJqB~DeFxMgK~VsMr[uKzVoCxEsEtG}BzCkHhKWh@]t@{AxEcClLkCjLi@`CwBfHaEzJuBdEyEhIaBnCiF|K_Oz\\ {MdZwAbDaKbUiB|CgCnDkDbEiE|FqBlDsLdXqQra@kX|m@aF|KcHtLm@pAaE~JcTxh@w\\`v@gQv`@}F`MqK`PeGzIyGfJiG~GeLhLgIpIcE~FsDrHcFfLqDzH{CxEwAbBgC|B}F|DiQzKsbBdeA{k@~\\oc@bWoKjGaEzCoEzEwDxFsUh^wJfOySx[uBnCgCbCoFlDmDvAiCr@eRzDuNxC_EvAiFpCaC|AqGpEwHzFoQnQoTrTqBlCyDnGmCfEmDpDyGzGsIzHuZzYwBpBsC`CqBlAsBbAqCxAoBrAqDdDcNfMgHbHiPtReBtCkD|GqAhBwBzBsG~FoAhAaCbDeBvD_BlEyM``@uBvKiA~DmAlCkA|B}@lBcChHoJnXcB`GoAnIS~CIjFDd]A|QMlD{@jH[vAk@`CoGxRgPzf@aBbHoB~HeMx^eDtJ}BnG{DhJU`@mBzCoCjDaAx@mAnAgCnBmAp@uAj@{Cr@wBPkB@kBSsEW{GV}BEeCWyAWwHs@qH? cIHkDXuDn@mCt@mE`BsH|CyAp@}AdAaAtAy@lBg@pCa@jE]fEcBhRq@pJKlCk@hLFrB@lD_@xCeA`DoBxDaHvM_FzImDzFeCpDeC|CkExDiJrHcBtAkDpDwObVuCpFeCdHoIl\\uBjIuClJsEvMyDbMqAhEoDlJ{C|J}FlZuBfLyDlXwB~QkArG_AnDiAxC{G|OgEdLaE`LkBbEwG~KgHnLoEjGgDxCaC`BuJdFkFtCgCnBuClD_HdMqEzHcBpB_C|BuEzCmPlIuE|B_EtDeBhCgAdCw@rCi@|DSfECrCAdCS~Di@jDYhA_AlC{AxCcL`U{GvM_DjFkBzBsB`BqDhBaEfAsTvEmEr@iCr@qDrAiFnCcEzCaE~D_@JmFdGQDwBvCeErEoD|BcFjC}DbEuD~D`@Zr@h@?d@Wr@}@vAgCbEaHfMqA`Cy@dAg@bAO`@gCi@w@W" }, "summary" : "I-5 N and US-101 N", "warnings" : [], "waypoint_order" : [] } ], "status" : "OK" }
Congratulations! You've successfully set up and called the Directions API to receive directions.
Cleaning upYou can delete your Google Cloud project to stop billing for all the resources used within that project.
Caution: Deleting a project has the following effects:Start developing with the Directions API by setting up your Google Cloud project:
For a list of all parameters when building your Directions API HTTP request:
Learn how to code with our client libraries that provide simple, native implementations of common tasks such as authentication, request throttling and automatic retry. The Directions API (Legacy) is available in the Java Client, Python Client, Go Client and Node.js Client for Google Maps Services.
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 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This demo guides you through using the Directions API to obtain driving directions between two locations, without exceeding your monthly quota."],["Setup involves creating a Google Cloud project, enabling the Directions API, and generating an API key."],["Directions are retrieved by making a request to the API with your API key, specifying the origin and destination."],["After completing the demo, you can delete your Google Cloud project to prevent further billing."],["Explore further development by setting up your Google Cloud project, reviewing API parameters, and utilizing client libraries for streamlined coding."]]],["To use the Directions API, first, create a new Google Cloud project and enable billing. Next, enable the Directions API within the project. Then, generate an API key, which authenticates requests, and restrict it for production. With setup complete, send a request to the API in the browser by constructing a URL with the origin, destination, and your API key, to receive driving directions, like Disneyland to Universal Studios, in JSON format. Once finished, the project can be deleted.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4