Skip to content

Geocoding API

POST Geocode Address

The geocoding service enables you to take an address and get the associated latitude and longitude.

Resource URL

https://www.mapquestapi.com/geocoding/v1/address

Resource Information

Response FormatsJSON, XML, CSV
AuthenticationYes (Requires Key)
Rate LimitedYes

Request Parameters

Request ParameterDescriptionRequired
keyThe API Key, which is needed to make requests to MapQuest services.Yes
outFormatSpecifies the format of the response. Must be one of the following, if supplied:
  • json
  • xml
  • csv (character delimited)
Example: XML response
outFormat=xml
optional, defaults to json
callbackA 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.

Example: Callback
callback=geocodeResult
optional

Request Body

Request ParameterDescriptionRequired
locationThe location to geocode.

Example: Single Line Location
"location": "Washington,DC"
Yes

Options Object

Request ParameterDescriptionRequired
boundingBoxWhen ambiguous results are returned, any results within the provided bounding box will be moved to the top of the results list. Bounding box format is: upper left latitude, upper left longitude, lower right latitude, lower right longitude.

Example: Bounding Box
"boundingBox": {"ul": { "lng": -77.085411, "lat": 38.893276 }, "lr": { "lng": -77.071159, "lat": 38.848869 }}
optional
ignoreLatLngInputThis option tells the service whether it should fail when given a latitude/longitude pair in an address or batch geocode call, or if it should ignore that and try and geocode what it can.
  • true: The geocoder will ignore the LatLng specified in the location, and use the address info to perform geocode
  • false : The geocoder will return a geoaddress object containing the LatLng passed in and write a warning message to Info block
Example: Ignore Lat Lng Input
"ignoreLatLngInput": true
optional, defaults to false
thumbMapsThis parameter tells the service whether it should return a URL to a static map thumbnail image for a location being geocoded.
  • true: The response will include a URL to a static map image of the geocoded location.
  • false : The response will not include a static map image URL.
Example: Disable Static Map Response
"thumbMaps": false
optional, defaults to true
maxResultsThe max number of locations to return from the geocode

This option will only have an effect on the second location because it is ambiguous

Example: Five Results Max
"maxResults": 5
optional
delimiterSpecifies the delimiter used in the csv response
  • ,
  • |
  • ;
Example: Pipe Delimiter
"delimiter": "|"


optional, defaults to none, only in effect if outFormat=csv
intlModeAllows users of the International Geocoder to tell MapQuest how to handle a 5-box geocode.
  • 5BOX: Keeps the query as a 5-box and sends it to the TomTom International Geocoder as a 5-box.
  • 1BOX: Converts the 5-box query into a 1-box query and sends it to the TomTom International Geocoder.
  • AUTO: Handles the query in a way deemed most optimal by MapQuest. Currently, this converts a 5-box query to a 1-box query across the board.
Example: 1BOX International Mode
"intlMode": "1BOX"
optional, defaults to auto

Response Object

providedLocationThe provided location properties passed in the geocode request.
latLngReturns the latitude/longitude for routing and is the nearest point on a road for the entrance.
streetStreet address.
adminArea6Neighborhood name.
adminArea5City name.
adminArea4County name.
adminArea3State name.
adminArea1Country name.
postalCodePostal code.
typeType of location.
  • 's'
  • 'v'
dragPointIs location a drag point? This option only applies when making a dragroute call.
  • true = location is a drag point
  • false = location is not a drag point (default)
displayLatLngA lat/lng pair that can be helpful when showing this address as a Point of Interest.
geocodeQualityThe precision of the geocoded location.

Refer to the Geocode Quality reference page for more information.
geocodeQualityCodeThe five character quality code for the precision of the geocoded location.

Refer to the Geocode Quality reference page for more information.
linkIdString that identifies the closest road to the address for routing purposes.
sideOfStreetSpecifies the side of street.
  • 'L' = left
  • 'R' = right
  • 'M' = mixed
  • 'N' = none (default)
infoThis field contains information about the response.

The statuscode subfield is an integer return value. Refer to the status codes page for more details about our status codes and error messages.

The messages subfield is an array of error messages that describe the status

Example Request

POST https://www.mapquestapi.com/geocoding/v1/address?key=KEY

Example Request Body

JSON
{
  "location": "Washington,DC",
  "options": {
    "thumbMaps": false
  }
}
XML
<address>
  <location>
    <city>Washington, DC</city>
  </location>
  <options>
    <thumbMaps>false</thumbMaps>
  </options>
</address>

Example Response

JSON
  {
    "info": {
        "statuscode": 0,
        "copyright": {
        "text": "© 2023 MapQuest, Inc.",
        "imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
        "imageAltText": "© 2023 MapQuest, Inc."
        },
        "messages": []
    },
    "options": {
        "maxResults": -1,
        "thumbMaps": true,
        "ignoreLatLngInput": false
    },
    "results": [
     {
        "providedLocation": {
            "location": "Washington,DC"
        },
        "locations": [
            {
            "street": "",
            "adminArea6": "",
            "adminArea6Type": "Neighborhood",
            "adminArea5": "Washington",
            "adminArea5Type": "City",
            "adminArea4": "District of Columbia",
            "adminArea4Type": "County",
            "adminArea3": "DC",
            "adminArea3Type": "State",
            "adminArea1": "US",
            "adminArea1Type": "Country",
            "postalCode": "",
            "geocodeQualityCode": "A5XAX",
            "geocodeQuality": "CITY",
            "dragPoint": false,
            "sideOfStreet": "N",
            "linkId": "282772166",
            "unknownInput": "",
            "type": "s",
            "latLng": {
                "lat": 38.892062,
                "lng": -77.019912
            },
            "displayLatLng": {
                "lat": 38.892062,
                "lng": -77.019912
            },
            "mapUrl": "https://www.mapquestapi.com/staticmap/v5/getmap?key=KEY&type=map&size=225,160&pois=purple-1,38.892062,-77.019912,0,0,|&center=38.892062,-77.019912&zoom=12&rand=306744981"
            }
        ]
      }
    ]
  }
XML
<?xml version='1.0' encoding='utf-8'?>
<response>
  <info>
    <statusCode>0</statusCode>
    <messages/>
    <copyright>
      <imageUrl>https://api.mqcdn.com/res/mqlogo.gif</imageUrl>
      <imageAltText>&#169; 2023 MapQuest, Inc.</imageAltText>
      <text>&#169; 2023 MapQuest, Inc.</text>
    </copyright>
  </info>
  <results>
    <result>
      <providedLocation>
        <street>Washington,DC</street>
      </providedLocation>
      <locations>
        <location>
          <street/>
          <adminArea6 type='Neighborhood'/>
          <adminArea5 type='City'>Washington</adminArea5>
          <adminArea3 type='State'>DC</adminArea3>
          <adminArea4 type='County'>District of Columbia</adminArea4>
          <postalCode/>
          <adminArea1 type='Country'>US</adminArea1>
          <geocodeQuality>CITY</geocodeQuality>
          <geocodeQualityCode>A5XAX</geocodeQualityCode>
          <dragPoint>false</dragPoint>
          <sideOfStreet>N</sideOfStreet>
          <displayLatLng>
            <latLng>
              <lat>38.892062</lat>
              <lng>-77.019912</lng>
            </latLng>
          </displayLatLng>
          <linkId>282772166</linkId>
          <unknownInput/>
          <type>s</type>
          <latLng>
            <lat>38.892062</lat>
            <lng>-77.019912</lng>
          </latLng>
        </location>
      </locations>
    </result>
  </results>
  <options>
    <maxResults>-1</maxResults>
    <thumbMaps>false</thumbMaps>
    <ignoreLatLngInput>false</ignoreLatLngInput>
    <boundingBox/>
  </options>
</response>
CSV
"Country","State","County","City","PostalCode","Street","Lat","Lng","DragPoint","LinkId","Type","GeocodeQualityCode","GeocodeQuality","SideOfStreet","DisplayLat","DisplayLng"
"US","DC","District of Columbia","Washington","","","38.892062","-77.019912","false","282772166","s","A5XAX","CITY","N","38.892062","-77.019912"