Traffic Service Developer's Guide

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

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.

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 flow image of traffic on the current map:

Incidents URL Parameters

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

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
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
outFormat Specifies the format of the response. Must be one of the following, if supplied:
  • json
  • xml
Defaults to "json" if not supplied
No

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 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: 7,
   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>7</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?
inFormat Specifies the format of the request. No
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.
ZoomScale
7324767
8154950
974999
1036000
1118000
129000
134700
142500
151500
161000
Yes

Sample Flow Image request

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

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