Complete guide to using the Map API for geocoding and location services
All geo API requests require authentication using your API key and secret key. Include these headers with every request:
You can generate API keys from your API Keys page after logging in.
Each API call costs credits. All endpoints cost 1 credit per request:
All accounts start with 5,000 free credits. Monitor your usage on the dashboard.
Search for places and addresses
GET /api/map/autocompleteq (required): Search query (address, place name, etc.)const url = 'https://your-api.com/api/map/autocomplete';
const params = {
q: 'New York'
};
const fullUrl = url + '?' + new URLSearchParams(params).toString();
const response = await fetch(fullUrl, {
headers: {
'X-API-Key': 'ak_your_api_key',
'X-Secret-Key': 'sk_your_secret_key'
}
});
const data = await response.json();
console.log(data);{
"source": "cache",
"count": 5,
"places": [
{
"name": "New York",
"display_name": "New York, New York, USA",
"place_rank": 12,
"latlng": "40.7127753,-74.0059728"
}
],
"credits_used": 1
}Calculate distances and routes between locations
GET /api/map/distance-matrixorigin (required): Origin coordinates in "lat,lng" formatdestination (required): Destination coordinates in "lat,lng" formatconst url = 'https://your-api.com/api/map/distance-matrix';
const params = {
origin: '40.7128,-74.0060',
destination: '34.0522,-118.2437'
};
const fullUrl = url + '?' + new URLSearchParams(params).toString();
const response = await fetch(fullUrl, {
headers: {
'X-API-Key': 'ak_your_api_key',
'X-Secret-Key': 'sk_your_secret_key'
}
});
const data = await response.json();
console.log(data);{
"source": "cache",
"data": {
"distance": 3944577.3,
"duration": 14724.5
},
"credits_used": 1
}Get detailed information about a place
GET /api/map/place-detailsplace_id (optional): Place ID from autocomplete resultsaddress (optional): Full address stringEither place_id or address is required
const url = 'https://your-api.com/api/map/place-details';
const params = {
place_id: '123456'
};
const fullUrl = url + '?' + new URLSearchParams(params).toString();
const response = await fetch(fullUrl, {
headers: {
'X-API-Key': 'ak_your_api_key',
'X-Secret-Key': 'sk_your_secret_key'
}
});
const data = await response.json();
console.log(data);| Status Code | Error Code | Description |
|---|---|---|
| 401 | INVALID_CREDENTIALS | Invalid API key or secret key |
| 402 | INSUFFICIENT_CREDITS | Account has insufficient credits |
| 400 | MISSING_QUERY | Required 'q' parameter missing |
| 400 | MISSING_PARAMETERS | Required parameters missing |
| 400 | INVALID_COORDINATES | Invalid latitude/longitude format |
| 404 | ROUTE_NOT_FOUND | No route found between the points |
| 500 | INTERNAL_ERROR | Internal server error |
{
"error": {
"message": "Error description",
"code": "ERROR_CODE",
"timestamp": "2024-01-01T00:00:00.000Z"
}
}If you have questions about the API or need assistance with integration, check out your dashboard for usage statistics and API call logs.