index.phpindex.phpindex.phpindex.phpindex.phpindexindexindexindexindex Autosuggest API | REST API using longitude & latitude

Autosuggest API

The Autosuggest API helps users to complete queries faster by adding intelligent search capabilities to your web or mobile app. This API returns a list of results as well as suggested queries as the user types in the search field.

API URL

  1. Basic URL structure:
    http://apis.mapmyindia.com/advancedmaps/v1/<licence key>/autosuggest?q=<query string>
  2. Output:
    The output format would be JSON.
  3. HTTP Request Method: GET

Request Parameters

The following input parameters will be supported in the Autosuggest API request –

  1. q: The query string (mmi000, India Gate, Coffee)
    a. mmi000: an eLoc, this would return a collection with 1 item.
    b. India Gate: a POI, this would return a collection with multiple items associated to India
    Gate.
    c. Coffee: a location search, returns all shops that have coffee in their name.

    Please Note:
    The query string can be http encoded or simple although preferably encoded to provide flexibility for special characters.
  2. Licence key: the REST API licence key allocated to you by signing into our services and
    registering yourself as a developer (28 Char Alphanumeric).

Response Parameters

The API returns an enveloped response with the autosuggested data in the results object.

  1. responseCode (int): The response code of the operation.The 400 series is for client side (yours) error while 500 series for server side (ours) error, 200 for success.
  2. Version (string): The version of the API you’re connected to.
  3. results (object[ ]): A collection of autosuggested response data sorted in the order of the best match to the input query, each consisting of the following parameters
    • type (string): defines the type of location matched (HOUSE_NUMBER, HOUSE_NAME, POI, STREET, SUB_LOCALITY, LOCALITY, VILLAGE, DISTRICT, SUB_DISTRICT, CITY, STATE, SUBSUBLOCALITY, PINCODE)
    • addr (string): formatted address based on the best matches of query item
    • y (double): latitude of the location.
    • x (double): longitude of the location.
    • place_id (string):The eLoc or placeId assigned for a place in map database. An eLoc is the digital identity for an address or business to identify its unique location. For more information on eLoc, click  here.
Please Note: The Latitude and Longitude will be a part of only the first Item of the result collection as it’s the best matched result. To get the data about the other search responses, pass in the eLoc of the location to the Place Details API. Max number of results that will be received is 5.

Performance

The Autosuggest API must respond within 100 Ms under all circumstances on a stable internet connection although on an unstable one, response times may vary.

Transaction Information

One request using the API link will be considered as one transaction. For any string in the input, the output will be list of address matching with that string. This is considered as one transaction. So, if the autosuggest response does not contain any data it won’t be counted.

Use Cases

  • In a simple textbox to provide location related information.
  • In a routing case scenario where you want to provide and verify with address.
  • To quickly verify a provided location/eLoc

Example

Input:
http://apis.mapmyindia.com/advancedmaps/v1/<licence_key>/autosuggest?q=new%20delhi

Output:

{  "responseCode": 200,  "version": "130.11",  "results": [  {  "type": "CITY",  "addr": "New Delhi, Delhi",  "x": 77.21966,  "y": 28.632694,  "place_id": "TAVI5S"  },  {  "type": "DISTRICT",  "addr": "New Delhi District, Delhi",  "place_id": "DIXUU2"  },  {  "type": "LOCALITY",  "addr": "New Delhi Colony, Dhanbad, Jharkhand",  "place_id": "KHEB4Q"  },  {  "type": "POI",  "addr": "New Delhi Domestic Airport Parking, Igi Airport Area, New Delhi, Delhi",  "place_id": "C7E25S"  },  {  "type": "POI",  "addr": "New Delhi Tours, Block 11, Rehgarpura, Karol Bagh, New Delhi, Delhi",  "place_id": "4JNJCK"  }