Is there a way I can access traffic data that Google provides through a web service?
Annual Traffic Data ACI’s Annual Traffic Data provides a comprehensive overview of passenger, cargo and traffic movements for the most recent year. Passengers Cargo Aircraft Movements More information on ACI’s Annual Traffic Data can be found in the ACI Annual World Airport Traffic Report (WATR). A summary of the latest WATR is contained in the following press release.
There seems to be a
GTrafficOverlay
that puts traffic on top of a route on an embedded google map, but no direct web service that I can consume to, say, give the source and the destination and find the traffic between them?![Free Foot Traffic Data Free Foot Traffic Data](/uploads/1/2/4/8/124867511/770229459.jpg)
Is there any other source I can get this data from?
ramiramilu15k55 gold badges4141 silver badges6060 bronze badges
Tejaswi YerukalapudiTejaswi Yerukalapudi4,8461212 gold badges5454 silver badges9797 bronze badges
9 Answers
There is no way (or at least no reasonably easy and convenient way) to get the raw traffic data from Google Maps Javascript API v3. Even if you could do it, doing so is likely to violate some clause in the Terms Of Service for Google Maps. You would have to get this information from another service. I doubt there is a free service that provides this information at the current time, but I would love it if someone proved me wrong on that.
As @crdzoba points out, Bing Maps API exposes some traffic data. Perhaps that can fill your needs. It's not clear from the documentation how much traffic data that exposes as it's only data about 'incidents'. Slow traffic due to construction would be in there, but it's not obvious to me whether slow traffic due simply to volume would be.
UPDATE (March 2016): A lot has happened since this answer was written in 2011, but the core points appear to hold up: You won't find raw traffic data in free API services (at least not for the U.S., and probably not most other places). But if you don't mind paying a bit and/or if you just need things like 'travel time for a specific route taking traffic into consideration' you have options. @Anto's answer, for example, points to Google's Maps For Work as a paid API service that allows you to get travel times taking traffic into consideration.
Community♦
TrottTrott39.2k1919 gold badges105105 silver badges155155 bronze badges
Apparently the information is available using the Google Directions API in its professional edition Maps for work. According to the API's documentation:
Note: Maps for Work users must include client and signature parameters with their requests instead of a key.
[...]
duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned if all of the following are true:
[...]
duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned if all of the following are true:
- The directions request includes a departure_time parameter set to a value within a few minutes of the current time.
- The request includes a valid Google Maps API for Work client and signature parameter.
- Traffic conditions are available for the requested route.
- The directions request does not include stopover waypoints.
3,22666 gold badges3030 silver badges6060 bronze badges
Bing Maps API has a REST service that returns traffic info
crdzobacrdzoba34011 gold badge44 silver badges1818 bronze badges
In India we are using http://www.itrafficnews.com. But the data is posted by the users. I dont think google will provide the data.
KaifiKaifi
Rather than trying to pull the raw traffic data, you can try a different approach.The Google Directions API allows you to query the api with a particular route and returns a JSON string or XML element as a result. This result includes the element - ' duration_in_traffic 'This indicates the total duration of the particular leg of the journey, taking into account current traffic conditions. (for information on 'leg' and other elements of the JSON string returned by the Directions API refer link below)
https://developers.google.com/maps/documentation/directions/#JSONI haven't tried this myself but just something I came across in the documentation.
BetelgueseBetelguese
You might want to take a look at HERE MAP SERVICE. They have direct traffic data you can use, which is exactly what you need: https://developer.here.com/api-explorer/rest/traffic/traffic-flow-bounding-box
For example, by querying an area of interest, you might get something like this:
Where the interpretation can be found here Interpreting HERE Maps real-time traffic tags:
- 'RWS' - A list of Roadway (RW) items
- 'RW' = This is the composite item for flow across an entire roadway. A roadway item will be present for each roadway with traffic flow information available
- 'FIS' = A list of Flow Item (FI) elements
- 'FI' = A single flow item
- 'TMC' = An ordered collection of TMC locations
- 'PC' = Point TMC Location Code
- 'DE' = Text description of the road
- 'QD' = Queuing direction. '+' or '-'. Note this is the opposite of the travel direction in the fully qualified ID, For example for location 107+03021 the QD would be '-'
- 'LE' = Length of the stretch of road. The units are defined in the file header
- 'CF' = Current Flow. This element contains details about speed and Jam Factor information for the given flow item.
- 'CN' = Confidence, an indication of how the speed was determined. -1.0 road closed. 1.0=100% 0.7-100% Historical Usually a value between .7 and 1.0 'FF' = The free flow speed on this
stretch of road. - 'JF' = The number between 0.0 and 10.0 indicating the expected quality of travel. When there is a road closure, the Jam Factor will be 10. As the number approaches 10.0 the quality of travel is getting worse. -1.0 indicates that a Jam Factor could not be calculated
- 'SP' = Speed (based on UNITS) capped by speed limit
- 'SU' = Speed (based on UNITS) not capped by speed limit
- 'TY' = Type information for the given Location Referencing container. This may be freely defined string
Also the source comes from https://developer.here.com/rest-apis/documentation/traffic/topics/additional-parameters.html
Costa HuangCosta Huang
![High foot traffic High foot traffic](/uploads/1/2/4/8/124867511/680905587.jpg)
Maybe you should have a look at Mapquests Traffic API: http://www.mapquestapi.com/traffic/
The webservice is unfortunately only available for some citys in the US, I think. But probably it solves your problem.
SebSeb
I don't think Google will provide this API. And traffic data not only contains the incident data.
Today many online maps show city traffic, but they have not provide the API for the developer. We even don't know where they get the traffic data. Maybe the government has the data.
So I think you could think about it from another direction. For example, there are many social network website out there. Everybody could post the traffic information on the website. We can collection these information to get the traffic status. Or maybe we can create a this type website.
But that type traffic data (talked about above) is not accurate. Even the information provided by human will be wrong.
Luckily I found that my city now provides an Mobile App called 'Real-time Bus Information'. It could tell the citizen where the bus is now, and when will arrive at the bus station. And I sniff the REST API in this App.The data from REST API give the important data, for example the lat and lon, and also the bus speed. And it's real-time data! So I think we could compute the traffic status from these data (by some programming).Here is some sample data : https://github.com/sp-chenyang/bus/blob/master/sample_data/bjgj_aibang_com_8899_bjgj_php_city_linename_stationno_datatype_type.json
Even the bus data will not enough to compute the accurate real-time traffic status. Incidents, traffic light and other things will affect the traffic status. But I think this is the beginning.
At the end, I think you could try to find whether your city provides these data.
PS: I am always thinking that life will be better for people in the future , but not now.
Chen YangChen Yang
It is possible to get traffic data.Below is my implementation in python. The API has some quota & is not fully free, but good enough for small projects
Response is :-
You need to pass
'departure_time':str(int(time.time()))
is a required query string parameter for traffic information. Your traffic information would be present in
duration_in_traffic
.Refer this documentation for more info.
pentapenta1,30922 gold badges99 silver badges3333 bronze badges
protected by Community♦May 19 '15 at 19:28
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?