Use the Travel Time HTTP API to make server-side requests for travel times between an origin and a set of destinations.
Sample Code
Calls to the Travel Time HTTP API must be made from a server-side script. View sample code.
To make client-side requests, see the Travel Time JavaScript API.
Calling the Travel Time API
The API accepts GET and POST requests at https://api2.walkscore.com/api/v1/traveltime/json and returns a set of routing times from the specified origin to the specified destinations.
Example:
To get the walk time from origin (47.649677,-122.357569) to two destinations (47.646757,-122.361152) and (47.6517,-122.3545), make the following call:
https://api2.walkscore.com/api/v1/traveltime/json?wsapikey=YOUR_API_KEY_HERE&
mode=walk&origin=47.649677,-122.357569&destination=47.646757,-122.361152&
destination=47.6517,-122.3545
The Travel Time API will return the following:
{
"status": "OK",
"response": {
"results": [
{
"origin": "47.649677,-122.357569",
"mode": "walk",
"travel_times": [
{
"seconds": 390,
"destination": "47.646757,-122.361152"
},
{
"seconds": 1151,
"destination": "47.6517,-122.3545"
}
]
}
]
}
}
The Travel Time API takes the following parameters:
| Parameter | Description | Required |
|---|---|---|
| mode | 'walk', 'bike', 'drive', or 'transit'. | Yes |
| origin | Comma-separated lat,lng. | Yes |
| destination | Comma-separated lat,lng. Can include multiple (repeat "destination=" as in the example above). | Yes |
| wsapikey | Your Walk Score API Key. Contact us to get one. | Yes |
| congestion | Any non-empty value causes 'drive' times to be calculated as if it were peak rush hour. | No |
The Travel Time API returns a JSON response containing:
| Result | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| status | Status code (string, see below). | ||||||||||||
| error | May be present if 'status' is not 'OK'. Contains details about the error, such as expected data type for invalid parameter values. |
||||||||||||
| response | An array of objects with the following properties (only present if status is 'OK').
|
The travel time API can only route trips taking less than 60 minutes. Longer trips will report as "unroutable".
Travel Time Polygon API
An API that generates a polygon showing the 'commute shed' from a given point for any mode of transit.
Example:
To get the polygon for 'commute shed' from origin (47.649677,-122.357569) by transit in 60 minutes, make the following call:
https://api2.walkscore.com/api/v1/traveltime_polygon/json
?wsapikey=YOUR-WSAPIKEY-HERE&origin=47.6062095%2C-122.3320708
&mode=transit&time=60
The Travel Time Polygon API will return the following:
{
"status": "OK",
"response": {
"origin": "47.6062095,-122.3320708",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-122.3054057440653,
47.78722139458381
],
[ etc. ],
]
]
]
},
"mode": "transit",
"precision": 3,
"time": 60
}
}
The Travel Time Polygon API accepts GET and POST requests at https://api2.walkscore.com/api/v1/traveltime_polygon/json.
The Travel Time Polygon API takes the following parameters:
| Parameter | Description | Required |
|---|---|---|
| wsid/wsapikey | One or the other is required. | Yes |
| origin | Comma-separated lat,lng. | Yes |
| mode | 'walk', 'bike', 'drive', or 'transit'. | Yes |
| time | In minutes, up to 60. | Yes |
| congestion | Any non-empty value causes 'drive' times to be calculated as if it were peak rush hour. | No |
| precision | 1 to 5. Defaults to 3. Higher value will result in a bigger (slower) response. | No |
The Travel Time Polygon API returns a JSON response containing:
| Result | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| status | Status code (string, see below). | ||||||||||
| error | May be present if 'status' is not 'OK'. Contains details about the error, such as expected data type for invalid parameter values. |
||||||||||
| response | An array of objects with the following properties (only present if status is 'OK').
|
Status codes and HTTP Responses
Status responses for both the Travel Time HTTP API and the Travel Time Polygon API.
| HTTP Response | Status code (string sent as 'status' in API response) |
|---|---|
| 200 | OK |
| 403 | MISSING_REQUIRED_PARAMETER |
| 403 | INVALID_PARAMETER_VALUE |
| 500 | INTERNAL_ERROR |
Contact us for tech support.
