This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Suggest API

Comprehensive documentation for integrating Cercalia’s Suggest API into your applications.

Web Services

Documentation about the Suggest functionality available through the HTTP-JSON web service of the CERCALIA platform.

Request Methods
  • GET: Parameters are sent in the URL.
  • POST: Parameters are sent in the body of the request.
Response Format
  • Responses are returned in JSON format.

Introduction to the Cercalia Suggest API

The Suggest web service provides functionality for querying addresses, localities, and points of interest. This service allows you to:

  • Suggestion Requests:

    • Includes addresses, localities, and points of interest (POIs).
    • Does not include precise coordinates for addresses. A subsequent geocoding request is required to obtain detailed address coordinates.
  • Geocoding Requests:

    • Retrieve the X and Y (longitude and latitude) coordinates of a specific address.

Key Details

  • Suggestion requests already include the coordinates for each candidate, except for addresses, which only return the default street coordinate.
  • For detailed portal coordinates, an additional geocoding request to the web service is required.

Web Service URL

https://lb.cercalia.com/suggest/SuggestServlet?

1 - Suggest Requests

Comprehensive documentation for integrating Cercalia’s Suggest API into your applications.

Request

Request Methods
  • Both GET and POST methods are supported.
  • All parameters must be UTF-8 encoded.
Request Parameters
ParameterDescriptionRequiredValues/Notes
keySecurity key.YesFor web applications, use the same key as the Cercalia Maps API.
For other applications (server, app, etc.), request a key from Nexus.
tText to search. Can include street, number, locality, postal code, etc. The postal code acts as a limiter; if no matches are found, the search expands to the entire municipality associated with the postal code.YesExample: t=Carrer+de+Mallorca
Optional Parameters
ParameterDescriptionValues/Notes
stnumAddress number to search.If provided, numeric values in t will be interpreted as part of the street/locality name, not as an address number.
alllikeUse like for all words.Accepted values: Yes, Y, or 1.
nofuzzyDisable fuzzy search (search for similar words).Accepted values: Yes, Y, or 1.
getypeFilter results by element type.Comma-separated list of values:
- st: Streets
- ct: Localities
- all: Returns all types (default if not specified).
Example: getype=st,ct.

This structure provides a clear and professional overview of the parameters required for Suggest API requests. Let me know if further refinements are needed!

Optional Filters
ParameterDescriptionExample / Notes
ctrycCountry code.Example: ESP, FRA.
regcRegion code (community).Example: ESPMAD, ESPCAT.
subregcSubregion code (province).Example: ESP08, ESP28.
muncMunicipality code.Example: ESP080193, ESP280796.
rscCode for municipality/region/subregion/country (replaces munc, subregc, regc, and ctryc).Example: ESP, ESPMAD, ESP08, ESP410917.
rscpPreferred code for municipality/region/subregion/country. Prioritizes results in specified regions but does not exclude others. Can be combined with rsc for broader results.Example: ESPVAL. Supports multiple levels of priority (rscp1, rscp2, etc.).
rsclpSimilar to rscp but with softer prioritization. Retrieves up to 3 top-scoring candidates from specified regions without excluding others.Example: ESPVAL. Supports multiple levels of priority (rsclp1, rsclp2, etc.).
excluderegionsBoolean parameter to exclude region names from the search. Recommended when using radius filtering or when applying rsc or rscp filters.Possible values: 1 to exclude region filters.
stcStreet code.Example: ESP280796000099043.
hnrtApplies tolerance to the house number search, prioritizing addresses containing the searched number within a tolerance margin (default is 50 numbers for most locations).Default value: 1 (apply tolerance). Set to 0 to disable.
excluderegions=1Prevents the inclusion of region name filters in the search.Optional. Useful when filtering by radius or using rsc/rscp parameters.
langPreferred language codes. Specifies the languages in which suggestions should be returned, if available (ISO 3-digit codes).Example: lang=baq,spa (prioritizes Basque, then Spanish).
ptSpecifies the latitude and longitude coordinates to be used as a reference point for distance calculations.Example: 37.416217,-122.085905
dDefines the radius in kilometers used for selecting locations within this distance from the reference point pt. The minimum allowed value is 5 kilometers.Example: 50 (Radius of 50 km)

Notes on Language Codes

  • Use ISO 3-digit language codes to specify your preference.
  • Example: lang=baq,spa will prioritize Basque and fallback to Spanish if unavailable.
  • Table with available languages: languages

Response

The response is always returned in JSON format with UTF-8 encoding.

Types of elements returned by the Suggest API:

  • Locality: If the “id” field starts with ‘CT’, it is a locality.
  • Addresses: If the “id” field starts with ‘ST’, it is a street. The street may also have optional fields such as “portal_min”, “portal_max”, “portal”, “portal_disponible”, and/or “portal_en”.
    • “portal”: Indicates the house number when separated from the rest of the address.
    • “portal_disponible”: Indicates the available house number when separated and adjusted to the available numbers for each address.
    • “portal_en”: Indicates if the user has written the address in English format [true/false].
    • “codigo_postal”: Indicates the postal code of the address, provided it is available and a complete address (street and number) has been specified.

Important: The coordinates returned for each candidate are the default for the street. To obtain the exact coordinates of a specified house number, a geocoding request is necessary.

Example Response:

{
  "responseHeader": {
    "status": 0,
    "QTime": 88,
    "params": {
      "ctryc": "ESP",
      "getype": "st,ct",
      "key": "YOUR_API_KEY",
      "t": "paseo de la castellana 300, madrid"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "maxScore": 2134.202,
    "docs": [
      {
        "id": "STESP215604",
        "calle_id": "ESP280796000091443",
        "calle_descripcion": "Paseo de la Castellana",
        "calle_nombre": "Castellana",
        "calle_tipo": "Paseo",
        "calle_articulo": "de la",
        "localidad_id": "ESP17240001236707",
        "localidad_nombre": "Madrid",
        "municipio_id": "ESP280796",
        "municipio_nombre": "Madrid",
        "provincia_id": "ESP28",
        "provincia_nombre": "Madrid",
        "comunidad_id": "ESPMAD",
        "comunidad_nombre": "Comunidad de Madrid",
        "pais_id": "ESP",
        "pais_nombre": "España",
        "oficial": "Y",
        "portal_min": 1,
        "portal_max": 308,
        "puntuacio": 2,
        "coord": "40.482803,-3.682507",
        "_version_": 1645646022384287700,
        "portal": 300,
        "portal_disponible": 300,
        "portal_en": false,
        "score": 2134.202,
        "codigo_postal": "28046"
      }
    ]
  }
}

Street Intersections & Addresses with Reference to a Second Street:

The response is similar to that for addresses but includes information about the second street in the intersection, along with an intersection element in each candidate. This element contains information about the first street, with the coord field representing the intersection point.

This allows for searching/geocoding two types of addresses:

  • Street Intersections: e.g., Calle de Diego de León / Velázquez, Madrid (Spain)
  • Exact Address Referencing a Cross Street: Common in countries like Turkey or Colombia. e.g., Namik Kemal Sokak & Kocayol Caddesi 12, Bostanci (Turkey) or Carrera 69P & calle 70-63, Bogotá (Colombia)

To separate the first street from the second, use the separator & or /, including spaces.

2 - Geocoding Address Requests

Detailed documentation on how to perform geocoding address requests using Cercalia’s Suggest API.

Geocoding Address Requests

To obtain the exact coordinates of a specific address (including house number), you need to use the parameters returned from the selected candidate in the suggestions response and make a geocoding request with these parameters:

Request Parameters

ParameterDescriptionExample
cmdFixed value candcand
adrStreet name (including house number)avinguda diagonal 200
ctnLocalitybarcelona
pcodePostal code08018
ctrycCountry code (ISO 3 characters)ESP
detcandFixed value 11
priorityfilterFixed value 11

Example Request:

https://lb.cercalia.com/services/json?key=YOUR_API_KEY&cmd=cand&adr=avinguda diagonal 200&ctn=barcelona&ctryc=ESP&detcand=1&priorityfilter=1

Response

The service returns a JSON object containing the geocoded address with its exact coordinates.

Example Response:

{
  "cercalia": {
    "cmd": "cand",
    "version": "1",
    "candidates": {
      "num": "1",
      "pos": "0",
      "total": "1",
      "candidate": {
        "desc": "Avinguda Diagonal, 200 (Barcelona)",
        "name": "Avinguda Diagonal",
        "source": "cercalia",
        "ge": {
          "id": "ESP080193000092155",
          "name": "Avinguda Diagonal",
          "prefix": "Avinguda",
          "sname": "Diagonal",
          "type": "adr1",
          "name": "Avinguda Diagonal, 200",
          "housenumber": "200",
          "postalcode": {
            "country_id": "ESP",
            "id": "08018"
          },
          "city": {
            "id": "ESP17240008430951",
            "value": "Barcelona"
          },
          "municipality": {
            "id": "ESP080193",
            "value": "Barcelona"
          },
          "subregion": {
            "id": "ESP08",
            "value": "Barcelona"
          },
          "region": {
            "id": "ESPCAT",
            "value": "Catalunya"
          },
          "country": {
            "id": "ESP",
            "value": "Spain"
          },
          "coord": {
            "x": "2.165638",
            "y": "41.387917"
          }
        }
      }
    },
    "server": "http://cercalia-tomcat-lbs-instance3:8080"
  }
}

3 - POI Requests

Detailed documentation on how to perform POI suggestion requests using Cercalia’s Suggest API.

Requests

To obtain suggestions for Points of Interest (POIs), you can use the following parameters in your request:

Request Parameters

ParameterDescriptionExample
keySecurity key: For web applications, use the same KEY as for the Cercalia Maps API. For other applications (server, APP, …), request a KEY from Nexus.your_api_key
tText to search. Can contain street, number, locality, postal code, etc. The postal code acts as a limiter: if no matches are found, it expands the search to the entire municipality belonging to the postal code.restaurant near central park
getypeFilter by element types. Comma-separated list. Possible values: st for Streets, ct for Localities, poi for Points of Interest, all returns all types (equivalent to not sending the parameter).poi
nofuzzyEnables exact matches only. Avoids “fuzzy” matching algorithms for more precise results.true

Optional Filters

ParameterDescriptionExample
ctrycCountry codeESP
regcRegion code - communityESPMAD
subregcSubregion code - provinceESP08
muncMunicipality codeESP080193
rscCode for municipality/region/subregion/country (replaces munc, subregc, regc, and ctryc).ESP,ESP08,ESPCAT
rscpPreferred code for municipality/region/subregion/country. Prioritizes results in specified regions over others. Can be combined with rsc for broader filtering.``
rsclpPreferred code for municipality/region/subregion/country. Prioritizes results in specified regions more softly than rscp. Can be combined with rsc for broader filtering.``
ptCoordinate “lat,lon” for proximity filtering.40.7128,-74.0060
dRadial distance in kilometers for proximity filtering. Default is 25 km; minimum is 5 km.10
poicatFilters POIs by category. Uses category codes, which will be detailed in a separate table.C005,C043

Example Requests

Response

The response is returned in JSON format with UTF-8 encoding. It includes a list of POI suggestions matching the search criteria.

Example response

{
   responseHeader:{
      status:0,
      QTime:23,
      params:{
         ctryc:"ESP",
         key:"YOUR_API_KEY",
         pois:"1",
         t:"Museo del Prado Madrid"
      }
   },
   response:{
      numFound:3,
      start:0,
      maxScore:26.154898,
      docs:[
         {
            id:"PESP724009001959912",
            categoria_id:"C037",
            poi_nombre:"Museo Nacional del Prado",
            codigo_postal:"28014",
            localidad_nombre:"Madrid",
            municipio_id:"ESP280796",
            municipio_nombre:"Madrid",
            provincia_id:"ESP28",
            provincia_nombre:"Madrid",
            comunidad_id:"ESPMAD",
            comunidad_nombre:"Comunidad de Madrid",
            pais_id:"ESP",
            pais_nombre:"España",
            direccion:"Paseo del Prado, 28014 Madrid",
            calle_descripcion:"Paseo del Prado",
            puntuacio:1,
            coord:"40.414856,-3.6925297",
            lang:"SPA",
            _version_:1645647790034911200,
            score:26.154898
         },
         {
            id:"PESP724009000642061",
            categoria_id:"C030",
            poi_nombre:"Museo del Prado",
            codigo_postal:"28014",
            localidad_nombre:"Madrid",
            municipio_id:"ESP280796",
            municipio_nombre:"Madrid",
            provincia_id:"ESP28",
            provincia_nombre:"Madrid",
            comunidad_id:"ESPMAD",
            comunidad_nombre:"Comunidad de Madrid",
            pais_id:"ESP",
            pais_nombre:"España",
            direccion:"Paseo del Prado, 28014 Madrid",
            calle_descripcion:"Paseo del Prado",
            tel:"+(34)-(913)-302800",
            mail:"museo.nacional@museodelprado.es",
            web:"www.museoprado.mcu.es",
            puntuacio:0.9,
            coord:"40.413776,-3.6924677",
            lang:"SPA",
            _version_:1645647790035959800,
            score:23.539408
         },
         {
            id:"PESPLU01N2945",
            categoria_id:"LU01",
            poi_nombre:"Jardines del Museo del Prado",
            localidad_nombre:"Madrid",
            municipio_id:"ESP280796",
            municipio_nombre:"Madrid",
            provincia_id:"ESP28",
            provincia_nombre:"Madrid",
            comunidad_id:"ESPMAD",
            comunidad_nombre:"Comunidad de Madrid",
            pais_id:"ESP",
            pais_nombre:"España",
            puntuacio:0.8,
            coord:"40.414196,-3.6926923",
            _version_:1645647795570344000,
            score:20.923918
         }
      ]
   }
}

List of POI Categories (*)

(*) poicat: If no POI categories are specified, the system will only search for suggestions within the default categories marked in the category table. If you want to search in all categories or specific ones, you must indicate them using this parameter.

CodeDescriptionIncluded in Default Search
C012Public AdministrationYes
C005AirportYes
C037Major Tourist AttractionYes
C023CampingYes
C036CasinoYes
C010Shopping CenterYes
C043Convention CenterYes
D00ESCSchoolYes
C004Train StationYes
C015Stadium / Sports CenterYes
C046Golf CourseYes
C009Hospital / ClinicYes
C013HotelYes
C030MuseumYes
C112Public Transport Stop (Uncategorized)Yes
C045Amusement ParkYes
C044MarinaYes
C031TheaterYes
C016Airport AccessYes
C006Ferry TerminalYes
C027UniversityYes
C048ZooYes
C076Bed & BreakfastYes
C047LibraryYes
D00CAPPrimary Care Center (Spain only)Yes
C032Sports CenterYes
C025CinemaYes
C070Ski StationYes
C110IndustryYes
C035Place of WorshipYes
C107MarketYes
C041OperaYes
C074Water ParkYes
C072Botanical GardenYes
C075Wildlife ParkYes
C039Park and Recreational AreaYes
C038Ice RinkYes
C022BeachYes
C050Industrial ZoneYes
C077Resort HotelYes
C042Concert HallYes
C079Military AirportNo
C105Vehicle RentalNo
C007Parking LotNo
C108Truck ParkingNo
C002Rest AreaNo
C003Service AreaNo
C106BankNo
C080AirfieldNo
C029Tourist Information CenterNo
C033Police StationNo
C018EmbassyNo
C026PharmacyNo
C001Gas StationNo
D00GUANursery (Spain)No
C109Car WashNo
C049SubwayNo
C040CourthouseNo
C083Bus StopNo
C081Intercity Bus StopNo
C051Tram StopNo
D00BUSUrban Bus StopsNo
C111Vehicle Rental ParkingNo
C019Border CrossingNo
C020Mountain PeakNo
C034Swimming PoolNo
C017Mountain PassNo
D104EV Charging PointsNo
C014RestaurantNo
C078Supermarket & HypermarketNo
C028Mechanical WorkshopNo
D00TRATrams (Spain)No
C056Car SalesNo

4 - Bracket locality

Explanation on how to use brackets in the “t” parameter to differentiate the locality when searching with Cercalia’s Suggest API.

Optional: Using Brackets to Differentiate the Locality from the Rest of the Address

Request

Request Parameters:

ParameterDescription
tText to search. It can contain the address (street, number, postal code). The locality name is enclosed in square brackets at the end of the text. Any part of the text after the locality will be ignored.

It is important to note that when using this search method, you must include only the address and the locality, as it matches exclusively against the street and locality fields.

Examples:

  • Input: Calle de Barcelona 16 [Madrid]
    Formatted Parameter: &t=Calle+de+Barcelona+16,%20%5BMadrid%5D

  • Input: Calle de Barcelona 16, 28012 [Madrid]
    Formatted Parameter: &t=Calle+de+Barcelona+16,%2028012%20%5BMadrid%5D

The rest of the parameters are the same as in previous suggestion requests.


Response

The response format is identical to previous suggestion requests.

5 - Examples requests

Detailed and explained requests

Example Requests

Here are two examples of how to use the t parameter with locality enclosed in square brackets, explained step by step.

Example 1: Searching for an Address with a Locality

Scenario:

You want to search for “Calle de Barcelona 16” in the locality “Madrid”. Using brackets ensures the locality is properly recognized.

Request

https://lb.cercalia.com/suggest/SuggestServlet?key=your_api_key&t=Calle de Barcelona 16, [Madrid]

Explanation

  • t: Calle de Barcelona 16 [Madrid]
    • The street name is “Calle de Barcelona 16”.
    • The locality is specified as Madrid, enclosed in square brackets [Madrid].
  • The brackets ensure that the locality is matched, and anything after [Madrid] is ignored.

Example 2: Searching for an Address with a Postal Code and Locality

Scenario:

You want to search for “Calle de Barcelona 16, 28012” in the locality Madrid, while including the postal code.

Request

https://lb.cercalia.com/suggest/SuggestServlet?key=your_api_key&t=Calle de Barcelona 16, Madrid

Explanation

  • t: Calle de Barcelona 16, 28012 [Madrid]
    • The street name is “Calle de Barcelona 16”.
    • The postal code is 28012, and it’s included in the text.
    • The locality is Madrid, enclosed in square brackets [Madrid].

Notes:

  • Replace your_api_key with the actual API key provided by Cercalia.

This format breaks down each request into an easily digestible explanation, making it clear what each parameter does and how it works.

6 - Languages

Suggest languages

Supported Language Codes

LanguageCode
ArabicARA
BasqueBAQ
CatalanCAT
CroatianSCR
CzechCZE
DanishDAN
DutchDUT
EnglishENG
EstonianEST
FinnishFIN
FrenchFRE
GalicianGLG
GermanGER
GreekGRE
HebrewHEB
HindiHIN
HungarianHUN
IcelandicICE
ItalianITA
LatvianLAV
LithuanianLIT
NorwegianNOR
PolishPOL
PortuguesePOR
RomanianRUM
RussianRUS
SlovakSLO
SlovenianSLV
SwedishSWE
TurkishTUR
ValencianVAL

7 - Errors

Detailed documentation when error is returned

If status is 0, the response is correct.

Error response: when status is different from 0.

{
   "responseHeader":{
      "QTime":0,
      "params":{
         "key":"______",
         "ctryc":"esp",
         "ctc":"ESP17240205556728",
         "stc":"ESP170792000090959",
         "stnum":"17"
      },
      "status":1
   },
   "error":{
      "code":1,
      "msg":"FileNotFoundException: https://lb.cercalia.com/cercalia_lbs/server?cmd=cand&detcand=1&clientid=___&ctc=ESP17240205556728&ctryc=esp&stc=ESP170792000090959&stnum=17"
   }
}