Skip to main content
Guides

Search

Estimated reading time: 31 minutes

In this guide you will learn how to search for points of interest (POIs) or addresses.

Setup

First, get an API key token, see the Getting Started guide.

Search entry point

URL: https://search.magiclaneapis.com/v1

EXAMPLE

These are complete working examples in several different languages, showing how to use the REST API search. You can try them right now.

Linux terminal / Windows command prompt:

curl "https://routes.magiclaneapis.com/v1" -X POST -H "Content-Type: application/json" -H "Authorization: YOUR_API_KEY_TOKEN" -d @payload.json

Linux note - do not use @~/payload.json instead of @/home/user/payload.json because ~ does not resolve due to the @ ; use only relative path @payload.json or absolute path @/home/user/payload.json

where

payload.json is a text file containing the following:

complete minimal payload.json file - search type , text to search for (query), target list what to search for, in the case of POIs - also specify POI categories with poi_categs , ref_location a reference location in longitude and latitude around which to search; debug true causes resulting json to be pretty printed;

note that, although the target field and the poi_categs field can be omitted - in that case the search looks only for settlements (villages, towns, cities), regions, countries

{
"text": "rest",
"target": ["pois", "addresses"],
"poi_categs": ["food&drink"],
"ref_location": [4.89352, 52.36597],
"debug": true
}

complete payload.json file - all default values shown explicitly - this json request is equivalent to, and produces the same output as, the previous json request above;

{
"type": "free_text",
"text": "rest",
"target": ["pois", "addresses"],
"poi_categs": ["food&drink"],
"ref_location": [4.89352, 52.36597],
"max_results": 15,
"exact_match": false,
"fuzzy": false,
"estimate_hno": true,
"debug": true,
"locale": "en"
}

In a linux terminal you can also send the request directly from the command line, without a file, like this: (this method does not work on windows)

curl "https://search.magiclaneapis.com/v1" -X POST -H "Content-Type: application/json" -H "Authorization: YOUR_API_KEY_TOKEN" -d \
'{
...
}'

The only difference is the added backslash after -d, and then the filename @/home/user/payload.json is replaced with the contents of the json file, starting with the next line - note that a single quote ‘ is added before the leading curly brace { and after the trailing curly brace } to enclose the file contents in single quotes - no backslashes are needed between the single quotes.

REQUEST PARAMETER DEFINITIONS

Request body schema: application/json

keyvalue
typeSearch type - for “free_text” search, a search string must be provided as value for the “text” key; or, “around_location” - search type, search around given location specified by longitude, latitude coordinates to the “ref_location” key
Type: string
Default value: "free_text"
Possible values - 1 of: “free_text”, “around_location”
text
(conditional
mandatory
parameter)
String to search for - must be specified if search “type” is “free_text”
Type: string
Default value: empty
targetTarget type to search for - if none specified, then the search result will contain only settlements/cities
Type: string array
Default value: none
Possible values - 0 or more of: “pois”, “addresses”
poi_categsIf “pois” was included as value for the “target” key, the POI (point of interest) categories to search for can be specified using “poi_categs”; if no categories are specified, all are selected for the search
Type: string array
Default value: all categories selected for search
Possible values - 0 or more of: “gas_stations”, “parking”, “food&drink”, “accommodation”, “medical_services”, “shopping”, “car_services”, “public_transport”, “wiki”, “education”, “entertainment”, “public_services”, “geographic_area”, “business”, “sightseeing”, “religious_places”, “roadside”, “sports”, “uncategorized”, “hydrants”, “emergency_services_support”, “civil_emergency_infrastructure”
poi_subcategsIf “pois” was included as value for the “target” key, the POI (point of interest) categories to search for can be specified using “poi_categs”; however, when searching for a specific type of POI, “poi_subcategs” offers a higher resolution to the search.
Type: string array
Default value: all subcategories of the specified “poi_categs” parent category are selected for search
As an example, if the category “food&drink” is specified for “poi_categs”, this includes all “poi_subcategs” for “food&drink”; however, if searching specifically for a tea house or coffee shop, then, instead of specifying the entire [“food&drink”] parent category for “poi_categs”, specify the subcategories [“tea_house”,”coffee_shop”] for “poi_subcategs”.
These are the POI subcategories for each of the POI categories shown in “poi_categs” above:

Select a POI category to see its POI subcategories:

petrol_station
charging_station
bicycle_charging_station

Request body schema: application/json (continued from above)

keyvalue
ref_location
(conditional mandatory
parameter)
Longitude, latitude reference location for the search - must be specified if search “type” is “around_location”
Type: array of 2 doubles in format [lon, lat]
max_resultsSpecify maximum number of search results to return
Type: integer
Default value: 15
exact_matchIf true, only exact word matches for the search string filter are returned in the results
Type: bool
Default value: false
fuzzyIf true, enables search string filter corrections using a fuzzy algorithm when no results are found
Type: bool
Default value: true
estimate_hnoIf true, when only start and end house numbers are present on a street, an estimation of the searched house number is made, using an interpolation algorithm
Type: bool
Default value: true
debugIf true, the JSON output is formatted for easy reading
Type: bool
Default value: false
localeThe ISO 639-1 language for the search result
Type: string
Default value: en

RESPONSE

MagicLane header

{
"info": {
"copyrights": [
"MagicLane"
]
},
"results": [

Search results

Each result item is given in a JSON block as shown below.

The coordinates in longitude, latitude (degrees). Location name, description and address components. Location contact details, such as phone number, email and URL, if available. Also wikipedia info and native location name, if available, and distance from reference location, in meters.

{
"coordinates": [
4.8887434374999996223,
52.357778125000002944
],
"name": "Le Restaurant",
"description": "Restaurant",
"address": {
"street name": "Frans Halsstraat",
"street number": "26-H",
"settlement": "Zuid",
"city": "Amsterdam",
"county": "North Holland",
"country": "Netherlands",
"country code": "NLD"
},
"contact": {
"URL": "https://www.le-restaurant.nl"
},
"native_name": "Le Restaurant",
"distance": 966
},