Traffic Service Developer's Guide

The Traffic Service provides real time traffic information related to markets, incidents, cameras, and flow.

The following example demonstrates a simple request to get incidents given a bounding box. The JavaScript code which sends the request and displays the result can be viewed here.

Location:
Input Format: Uses "json=" or "xml=" if appropriate.
Output Format: Default is JSON (Currently only JSON works)
Incident Types: Construction
Incidents


Sample URL for incidents on the current map:

Sample URL for cameras on the current map:


Sample URL for flow image of traffic on the current map:

Common Options

The following table describes the request parameters common to all traffic service requests

Request Parameter Description Required?
inFormat
Specifies the format of the request. If this parameter is not supplied, the input format is assumed to be JSON-formatted text. The JSON-formatted input text must be supplied as either the "json" parameter of an HTTP GET, or as the BODY of an HTTP POST. If this parameter is "xml", the XML-formatted input text must be supplied as either the "xml" parameter of an HTTP GET, or as the BODY of an HTTP POST.

Must be one of the following, if supplied:
  • kvp
  • json
  • xml
Defaults to "json" if not supplied
No
callback
A JavaScript function name. The JSON-formatted response will be wrapped in a call to the supplied callback function name to provide JSONP functionality. This functionality might be needed to do cross-site scripting. See the Wikipedia.org entry for JSON for more details.
No
outFormat Specifies the format of the response. Must be one of the following, if supplied:
  • json
  • xml
Defaults to "json" if not supplied
No

Traffic Incidents

The Traffic Incidents request returns a structured list of traffic incidents for a specified bounding box in JSON or XML formats, e.g., road construction, traffic collisions.

Incidents URL Parameters

The following table describes the request parameters that may be included to make an incident request

Request Parameter Description Required?
filters A list of incident types to return. Possible values are:
  • incidents
  • construction

Default: incidents,construction
No
boundingBox The area in which to search for incidents. Yes

Incidents response

Sample JSON Response Sample XML Response
{incidents: [
   {impacting: false,
    eventCode: 0,
    iconURL: "http://...",
    lat: 38.743999,
    shortDesc: "Exit ramp closed on I 95...",
    type: 1,
    severity: 0,
    fullDesc: "In NEWINGTON exit ramp closed on I-95 ...",
    startTime: "2010-02-21T00:14:07",
    lng: -77.188004,
    id: "368598263",
    endTime: "2010-02-27T05:04:19"
   },
   ...
   ],
   info: {
     statuscode: 0,
     copyright: {
     },
     messages: []
  },
  mqURL : "http://www.mapquest.com/...."
  
}
<IncidentsResponse>
   <Incidents>
      <Incident>
         <id>368598263</id>
         <type>1</type> 
         <severity>0</severity>
         <eventCode>0</eventCode>
         <lat>38.743999</lat> 
         <lng>-77.188004</lng> 
         <startTime>2010-02-21T00:14:07.000-05:00</startTime> 
         <endTime>2010-02-27T05:04:19.000-05:00</endTime> 
         <shortDesc>ramp closed on I 95 ...</shortDesc> 
         <fullDesc>.......</fullDesc> 
         <iconURL>http://...</iconURL>
      </Incident>
      .....
    </Incidents>
    <info>
       <statusCode>0</statusCode> 
       <messages />
       <copyright>
          <imageUrl>http://...</imageUrl> 
          <imageAltText>...</imageAltText> 
          <text>...</text> 
       </copyright>
    </info>
    <mqURL>http://www.mapquest.com...</mqURL>
</IncidentsResponse>
Note: mqURL contains a link back to mapquest.com that would show all the incidents on a mapquest map.

Traffic Cameras

The Traffic Cameras request returns a list of traffic camera objects.

Cameras URL Parameters

The following table describes the request parameters that may be included to make a camera request

Request Parameter Description Required?
boundingBox The area in which to search for cameras. Note that coverage might be different for cameras than for incidents/flow/markets. Yes

Cameras response

Sample JSON Response
{"cameras": [
   { "id": "7", 
     "sublicenseProhibited": false, 
     "copyrightNotice": "",
     "outOfService": false,
     "name": "Park Avenue West",
     "feeToEndUserProhibited": false,
     "lat": 39.758804,
     "lng": -104.9929,
     "view": "West",
     "useWhileDrivingProhibited": false,
     "updateFrequency": 598871
   },
   ...
]}

Traffic Cameras Image

The Traffic Camera Image request returns a JPG image from a specific traffic camera.

Camera Image URL Parameters

The following table describes the request parameters that may be included to make a camera image request

Request Parameter Description Required?
id The id of the camera for which you want to retrieve the most recent image. Yes

Cameras Image Response

The response from this request is a JPG image

Traffic Markets

The Traffic Markets Request returns a structured list of regions, or "markets", for which MapQuest provides Traffic data. The list is available in JSON or XML formats.

This function takes no parameters other than a valid key.

Sample Markets request


Sample JSON Response Sample XML Response
{markets: [
  {state: "OH", 
   lng: -81.519202, 
   lat: 41.081401,
   iconURL: "http://...",
   city: "Akron / Canton"
   zoom: 10,
   mqURL: "http://www.mapquest.com...",
   boundingBox: {
     ul: {
       lng: -82.110762
       lat: 41.359286
     },
     lr: {
       lng: -80.926346
       lat: 40.803517
     }
   }
  },
  ...
 ],
 info: {
    copyright: {
    },
    statuscode: 0,
    messages: []
 }
}
<MarketsResponse>
   <markets>
      <market>
         <city>Akron / Canton</city>
         <state>OH</state>
         <lng>-81.519202</lng>
         <lat>41.081401</lat>
         <iconURL>http://...</iconURL>
         <zoom>10</zoom>
         <mqURL>http://www.mapquest.com...</mqURL>
         <boundingBox>
            <ul>
               <latLng>
                  <lat>41.359286</lat>
                  <lng>-82.110762</lng>
               </latLng>
            </ul>
            <lr>
               <latLng>
                  <lat>40.803517</lat>
                  <lng>-80.926346</lng>
               </latLng>
            </lr>
         </boundingBox>
      </market>
      ...   
   </markets>
   <info>
      <statusCode>
         0
      </statusCode>
      <messages/>
   </info>
   <copyright>
      ...
   </copyright>
</MarketsResponse>
Note: mqURL contains a link back to viewing that specific market on mapquest.com

Flow Image

The Flow Request returns an image of the current traffic for a particular area.

The following table describes the request parameters that may be included in a Flow request

Request Parameter Description Required?
mapState
A valid mapState for this image.

This parameter must contain the following information:
  • width (pixels)
  • height (pixels)
  • center (lat/lng of map center)
  • scale (map scale)
To descibe a mapState object using Key/Value pair input, supply the following query parameters:
  • mapWidth
  • mapHeight
  • mapLat
  • mapLng
  • mapScale
mapLat and mapLng represent the latitude and longitude of the center of the map.


Note: As of January 2010, the scale factor / zoom of this mapState must be one of the values in the following table.
Equirectangular ZoomEquirectangular Scale
7324767
8154950
974999
1036000
1118000
129000
134700
142500
151500
161000



Note: When using Mercator, the scale factor / zoom of this mapState must be one of the values in the following table.
Mercator ZoomMercator Scale
10433343
11216671
12108335
1354167
1427083
1513541
166770
173385
181692
Yes
projection
Specifies the projection used for the rendered map.
  • equi (Mapquest Equirectangular)
  • merc (Spherical/Web Mercator)
Default is "equi" for non-Mercator output, when using 7.0 version of the MapQuest JS toolkit you must specify "merc" since the map tiles are Mercator.
Yes

Sample Flow Image request

The following sample returns a 400x400 pixel image centered on Arlington, VA, with a Mercator scale of 108336 (zoom level of 10 on a MapQuest map.)

  © MapQuest, Inc. All rights reserved.    Privacy Policy | Terms of Use