Introduction
Welcome to the Latlong API documentation. User can use our API endpoints, which can get information on various location based services like driving distance, geocode/geosearch, reverse geocode, locality based driving directions, locality based auto-complete and many more related to maps.
We have language bindings in Shell, Ruby, javascript, java and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Authentication
Users need to have access_token
to
access all latlong API.
How to get your
access_token
?
-
If you are signed up with latlong we would have provided you your
access_tokens.
- In case you are not yet signed up, you can visit our official page and fill up the contact form.
Your access token will look like thisaccess_token=a70bf52c9d649675152485e2c9b15cf9b2fc3ebb54628944ebd52e293813fbdc
Elemental
Auto complete
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/autocomplete.json", {
params: {:query => 'beng'}
}
curl https://api.latlong.ai/v3/autocomplete.json?query=beng -H 'Authorization: Bearer <ACCESS_TOKEN>'
https://api.latlong.in/v2/autocomplete.json?query=beng
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status": "Success"
"data": [
{
"name": "Bengalur,Karnataka",
"geo": 510000021
},
{
"name": "Bengaluru Urban District,Karnataka",
"geo": 440000004
},
{
"name": "Bengaluru Rural District,Karnataka",
"geo": 480000015
},
{
"name": "Bengre,Mangaluru,Karnataka",
"geo": 890001390
},
{
"name": "Bengali Square,Indore,Indore",
"geo": 1860001967
},
{
"name": "Bengaluru Jalamandali,Gandhi Nagar:Central Bangalore:Central Bengaluru,Bengaluru Urban District,Karnataka",
"geo": 240036855
},
{
"name": "Bengalmattam,Ooty,Tamil Nadu",
"geo": 680005109
}
]
}
This endpoint returns matched location suggestion along with their unique identity number, latitude and longitude based on entered characters. If the browser location is ON then the API initially tries to match entered text within user’s state else the API matches any results within country(India) level. The results are populated based on their popularity.
HTTP Request
GET https://api.latlong.ai/v3/autocomplete.json
example
GET https://api.latlong.ai/v3/autocomplete.json?query=beng
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
query | string | must | name to be searched |
Geo
Driving Distance
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/driving_distance.json", {
params: {:origin => 12.8810313,77.5806633, :destination => 12.930660,77.582572|12.9261023,77.5686565}
}
curl https://api.latlong.ai/v3/driving_distance.json?origin=12.8810313,77.6806633&destination=12.930660,77.582572|12.9261023,77.5686565 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https:https://api.latlong.ai/v3/driving_distance.json?origin=12.8810313,77.6806633&destination=12.930660,77.582572|12.9261023,77.5686565
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status": "Success",
"data": [
{
"origin": "12.8810313,77.6806633",
"destinations": "12.930660,77.582572",
"distance": "15.89 km",
},
{
"origin": "12.8810313,77.6806633",
"destinations": "12.9261023,77.5686565",
"distance": "16.78 km",
},
]
}
This endpoint returns the driving distance between origin and destination. You can supply maximum 5 sets of destination seprated by |.
HTTP Request
https://api.latlong.ai/v3/driving_distance.json
example
GET https://api.latlong.ai/v3/driving_distance.json?origin=12.8810313,77.6806633&destination=12.930660,77.582572|12.9261023,77.5686565
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
origin | integer/float | must | Origin location in the form of latitude and longitude coordinates |
destination | integer/float | must | Destination location in the form of latitude and longitude coordinates |
NOTE : One destination is must among the 5 set and multiple values can be added using |
Driving Direction
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/directions.json", {
params: {:origin => 12.9307248,77.5761579, :destination => 12.9261023,77.5686565}
}
curl https://api.latlong.ai/v3/directions.json?origin=12.9307248,77.5761579&destination=12.9261023,77.5686565 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https:https://api.latlong.ai/v3/directions.json?origin=12.9307248,77.5761579&destination=12.9261023,77.5686565
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status": "Success",
"data": {
"origin": "12.9307248,77.5761579",
"destination": "12.9261023,77.5686565",
"route": [
"Start",
"continue uturn onto Kanakapura Road",
"turn right onto 13th Cross Road",
"continue straight onto 23rd Cross Road",
"end of road right onto 9th Main Road",
"turn left onto 22nd Cross Road",
"turn right onto 13th Cross Road",
"Arrive at Destination"
]
}
}
This endpoint returns the driving direction between origin and destination.
HTTP Request
https://api.latlong.ai/v3/directions.json
example
GET https://api.latlong.ai/v3/directions.json?origin=12.9307248,77.5761579&destination=12.9261023,77.5686565
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
origin | integer/float | must | Origin location in the form of latitude and longitude coordinates |
destination | integer/float | must | Destination location in the form of latitude and longitude coordinates |
NOTE : One destination is must among the 5 set and multiple values can be added using |
Distance Matrix
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/distancematrix.json", {
params: {:origins => 12.93072,77.578215|12.928409,77.584114|12.928279,77.577529,:destinations => 12.935703,77.575709|12.920336,77.573421|12.926102,77.568657
}
}
curl https://api.latlong.ai/v3/distancematrix.json?origins=12.93072,77.578215|12.928409,77.584114|12.928279,77.577529&destinations=12.935703,77.575709|12.920336,77.573421|12.926102,77.568657 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https://api.latlong.in/v2/distancematrix.json?rigins=12.93072,77.578215|12.928409,77.584114|12.928279,77.577529&destinations=12.935703,77.575709|12.920336,77.573421|12.926102,77.568657
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status":"Success",
"data": [
{
"origin": "12.93072,77.578215",
"destination": "12.935703,77.575709",
"distance": "0.83 km"
},
{
"origin": "12.93072,77.578215",
"destination": "12.920336,77.573421",
"distance": "1.8 km"
},
{
"origin": "12.93072,77.578215",
"destination": "12.926102,77.568657",
"distance": "2.12 km"
},
{
"origin": "12.928409,77.584114",
"destination": "12.935703,77.575709",
"distance": "1.69 km"
},
{
"origin": "12.928409,77.584114",
"destination": "12.920336,77.573421",
"distance": "2 km"
},
{
"origin": "12.928409,77.584114",
"destination": "12.926102,77.568657",
"distance": "2.47 km"
},
{
"origin": "12.928279,77.577529",
"destination": "12.935703,77.575709",
"distance": "1.18 km"
},
{
"origin": "12.928279,77.577529",
"destination": "12.920336,77.573421",
"distance": "1.35 km"
},
{
"origin": "12.928279,77.577529",
"destination": "12.926102,77.568657",
"distance": "1.67 km"
}
]
}
This endpoint provides driving distance for a set of origins and destinations in a matrix form. The API returns the distance based on the recommended route between origin and destination points, as calculated by API, and consists of rows containing distance values for each pair.This API takes maximum of 3x3 matrix as input.You can supply maximum 3 sets of origins or destination seprated by |.
HTTP Request
https://api.latlong.ai/v3/distancematrix.json
example
GET https://api.latlong.ai/v3/distancematrix.json?rigins=12.93072,77.578215|12.928409,77.584114|12.928279,77.577529&destinations=12.935703,77.575709|12.920336,77.573421|12.926102,77.568657
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
origins | integer/float | must | Origin location in the form of latitude and longitude coordinates |
destinations | integer/float | must | Destinations location in the form of latitude and longitude coordinates |
NOTE : One origin/destination is must among the 3x3 set and multiple values can be added using |
Geocode
Geocode
The above API returns JSON structured like this:
{
"status":"Success",
"data":{
"address": "a1106,Purva Heights, Banerghatta Road, Bangalore 560076",
"latitude": "12.904466",
"longitude": "77.602404"
}
}
This endpoint returns the reverse geocoded address along with zipcode and nearest landmark for reference for the given geo point.
HTTP Request
GET https://api.latlong.ai/v3/
example
GET
https://api.latlong.ai/v3/geocode.json?access_token=WCafiZcmbm-seV_bNpxlcgkV0W2JbU1lg-CWJ0QfrPA&address=a1106,Purva%20Heights,%20Banerghatta%20Road,%20Bangalore%20560076
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
address | string | must | Address to geocode |
Reverse Geocode
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/reverse_geocode.json", {
params: {:latitude => '12.9306361', :longitude => '77.5783206'}
}
curl https://api.latlong.ai/v3/reverse_geocode.json?latitude=12.9306361&longitude=77.5783206 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https://api.latlong.ai/v3/reverse_geocode.json?latitude=12.9306361&longitude=77.5783206&details=false
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status":"Success",
"data":{
"address": "7th block ,Jayanagar ,Bengaluru,Karnataka",
"pincode": "560070",
"landmark": "< 0.5 km from Nanda Talkies Road-Ganesha Temple Signal, ~ 0.5 km from Yediyur Maternity Hospital Junction"
}
}
This endpoint returns the reverse geocoded address along with zipcode and nearest landmark for reference for the given geo point.
HTTP Request
GET https://api.latlong.ai/v3/reverse_geocode.json
example
GET
https://api.latlong.ai/v3/reverse_geocode.json?latitude=12.9306361&longitude=77.5783206&details=false
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
latitude | integer/float | must | Latitude of the location |
longitude | integer/float | must | Longitude of the location |
details | boolean | must | true/false. By default this is set to false and returns the response with address, pincode, landmark else if true is supplied then we get address,locality(deatils of each locality), pincode,landmark |
Pincode Details
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/pincode.json", {
params: {:pincode => 643001}
}
curl https://api.latlong.ai/v3/pincode.json?pincode=643001 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https:https://api.latlong.ai/v3/pincode.json?pincode=643001
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status": "Success",
"data": {
"pincode": 643001,
"state": "Tamil Nadu",
"city": "Ooty"
}
}
This endpoint returns the state and city for a given pincode
HTTP Request
https://api.latlong.ai/v3/pincode.json
example
GET https://api.latlong.ai/v3/pincode.json?pincode=643001
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
pincode | integer | must | Pincode of a location |
Compound
Landmark
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/landmarks.json", {
params: {:latitude => 12.9307248, :longitude => 77.5761579}
}
curl landmarks.json?latitude=12.9307248&longitude=77.5761579 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https://api.latlong.ai/v3/landmarks.json?latitude=12.9307248&longitude=77.5761579
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status": "Success"
"data": [
{
"name": "Orthopaedic Centre and Hospital",
"geo": 401027,
"geoproperty": "POINT (77.576276 12.930106)"
},
{
"name": "Oxford Hospital",
"geo": 401474,
"geoproperty": "POINT (77.575797 12.931699)"
},
{
"name": "BMP Maternity Hospital, Yediyur ",
"geo": 381071,
"geoproperty": "POINT (77.576139 12.927272)"
},{
"name": "Government Veterinary Hospital",
"geo": 381044,
"geoproperty": "POINT (77.580268 12.931968)"
}
]
}
This endpoint returns 4 landmark in each direction.You can supply an address or latitude and longitude. When an address is supplied we use our Geocoding api to get latitude and longitude respectively.
HTTP Request
GET https://api.latlong.ai/v3/landmarks.json
example
GET https://api.latlong.ai/v3/landmarks.json?latitude=12.9307248&longitude=77.5761579
Coming Soon...!
GET https://api.latlong.ai/v3/landmarks.json?address=beng
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
address | string | must | Name to be searched |
or | |||
latitude | integer/float | must | Latitude of the location |
longitude | integer/float | must | Longitude of the location |
Geovalidation
require 'rest-client'
response = RestClient.get "https://api.latlong.ai/v3/geovalidation.json", {
params: {:address =>'3/80, IH Colony, MG Road, Goregaon West, Mumbai 400104',:latitude => '19.163051', :longitude => '72.839485'}
}
curl https://api.latlong.ai/v3/geovalidation.json?address=3/80, IH Colony, MG Road, Goregaon West, Mumbai 400104&latitude=19.163051&longitude=72.839485 -H 'Authorization: Bearer <ACCESS_TOKEN>'
https://api.latlong.ai/v3/geovalidation.json?address=3/80, IH Colony, MG Road, Goregaon West, Mumbai 400104&latitude=19.163051&longitude=72.839485
// Java code goes here
// Use any of the http client library for fetching rest service data
okhttp //(http://square.github.io/okhttp/)
retrofit //(http://square.github.io/retrofit/)
// Or Use Standard java libraries like
JAX-RS //(http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html)
jersey //(https://jersey.java.net/documentation/latest/client.html)
The above API returns JSON structured like this:
{
"status":"Success",
"data":{
"address": "3/80, IH Colony, MG Road, Goregaon West, Mumbai 400104",
"latitude": "19.163051",
"longitude": "72.839485"
"geocode_latitude": "19.1638",
"geocode_longitude": "72.842907",
"distance":{
"aerial": "0.369 km",
"driving": "0.43 km"
}
"result":[
"Colony : YES",
"Locality : YES",
"City : YES",
"District : YES",
"State : YES",
"Pincode : YES"
]
}
}
This endpoint returns geocode of given address,geo distance between given address with given latitude-longitude.It also validates locality level information for the given data. For every locality if there is a matche then it is denoted with "Yes" else "No".
HTTP Request
GET https://api.latlong.ai/v3/geovalidation.json
example
GET
https://api.latlong.ai/v3/geovalidation.json?address=3/80, IH Colony, MG Road, Goregaon West, Mumbai 400104&latitude=19.163051&longitude=72.839485
Query Parameters
Parameter | Type | Presence | Description |
---|---|---|---|
address | string | must | Address of a location |
latitude | integer/float | must | Latitude of the location |
longitude | integer/float | must | Longitude of the location |
Errors
Latlong API gives below specified error codes depending on the criteria:
Error Code | Meaning |
---|---|
400 | Bad Request – Your request sucks |
401 |
Unauthorized –
|
403 | Forbidden – The api requested is hidden for administrators only |
404 | Not Found – The specified resource could not be found |
500 | Internal Server Error – We had a problem with our server. Try again later. |
503 | Service Unavailable – We’re temporarially offline for maintanance. Please try again later. |