Using the Geocoding API
Learn how to make a geocoding request using the Geocoding API. This document provides detailed instructions on making a POST request to the Geocoding endpoint, including necessary address details in the request body. The API will respond with a JSON conta
Making a Request
To geocode an address, make a POST request to the Geocoding endpoint with the address details in the request body.
Request body:
The request body should contain the data object with the following fields:
| Field | Required/Optional | Type | Description |
|---|---|---|---|
| address | Required | string | The street address which you want to geocode. |
| pincode | Optional | string | Pincode associated with the provided address. |
| city | Optional | string | City associated with the provided address. |
| state | Optional | string | State associated with the provided address. |
Example Request:
{
"data": {
"address": "Delhivery Corporate Office, Sector 44, Gurugram",
"pincode": "122003",
"city": "Gurgaon",
"state": "Haryana"
}
}
Understanding the Response
The Geocoding API will return a JSON response with the geocoded coordinates of the address.
Response Schema:
| Field | Type | Description |
|---|---|---|
| success | boolean | Indicates if the request was successful. true if successful, false if there was an error. |
| status_code | number | Status code of the request. |
| message | string | Information about the processed request. |
| request_id | string | A unique id for the request. |
| result | object | Contains the geocoded coordinates and the confidence radius. |
| result.lat | number | The latitude part of the geographical coordinates. |
| result.lng | number | The longitude part of the geographical coordinates. |
| result.confidence_radius | number | It is a measure of horizontal accuracy that indicates the actual address will be within the radius of x meters around the predicted geocode. |
Example Response:
{
"success": true,
"status_code": 200,
"message": "Request has been processed",
"request_id": "AX34687667877689",
"result": {
"geocode": {
"lat": 28.454736,
"lng": 77.070171
},
"confidence_radius": 24 // Unit is in meters
}
}
In the result object, you'll find the geocoded coordinates (lat and lng) and the confidence_radius, which indicates the accuracy of the geocoded location.