How do I make Geocoding API request to MapQuest API? [Node.js Code]

To make a geocoding API request to the MapQuest API, you need to make an HTTP POST request to the mapquestapi geocoding API endpoint and provide JSON with the location data and the MapQuest API key in the URL parameter. The MapQuest API will return JSON with latitude and longitude for the given address. The Node.js code was automatically generated for the Geocoding API example.
How do I make Geocoding API request to MapQuest API? [Node.js Code] Send
POST /geocoding/v1/address?key={mapquest_apikey} HTTP/1.1
Host: www.mapquestapi.com
Content-Type: application/json
Content-Length: 80

{
  "location": "Broadway, New York",
  "options": {
    "thumbMaps": true
  }
}
Updated: Viewed: 13507 times
Node.js code for Geocoding API example

Node.js code for Geocoding API Example

This Node.js code snippet was generated automatically for the Geocoding API example.
<< Back to the Geocoding API example

What is MapQuest?

MapQuest is a free online mapping service. It provides features such as street detailing and projection and driving directions for selected countries. MapQuest supports voice navigation and real-time traffic information. Besides maps, it also maintains various travel blogs and information on many attractive travel destinations through MapQuest Discover.

How to use MapQuest Geocoding API?

To use the MapQuest Geocoding API in your application, you need to register with the MapQuest website and obtain a free API key for your application. After that, you can make geocoding API requests to MapQuest and get the associated latitude and longitude of the address, calculate optimized routes, or search within the radius of the origin point.

MapQuest Geocoding API Request Example

An example of sending a geocoding API request to a MapQuest API endpoint.

MapQuest Geocoding Request
POST /geocoding/v1/address?key={mapquest_apikey} HTTP/1.1
Host: www.mapquestapi.com
Content-Type: application/json
Content-Length: 80

{
  "location": "Broadway, New York",
  "options": {
    "thumbMaps": true
  }
}

Server response to our geocoding request.

MapQuest Server Response to Geocoding Request
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1736

{
   ...
    "results": [{
		"adminArea3": "NY",
		"adminArea1": "US",
		"geocodeQuality": "CITY",
		"latLng": {
			"lat": 42.3661,
			"lng": -78.544701
		}
    }]
   ...
}

Generate code snippets for Node.js and other programming languages

Convert your Geocoding API request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the Node.js code generator.