Skip to main content

Single Search Geocoding API

Contents

Our Single Search service allows you to geocode an address that a user submits as a single string of text—similar to a query on a web search engine. It returns an array of locations that match the search text. It can also help provide more relevant search results, giving you the ability to search based on the current location (a longitude/latitude point).

Single Search is our most advanced API for geocoding. It allows you to search for addresses, coordinates, places, and points of interest throughout the world. We recommended it for all new implementations.

We also offer a suite of Geocoding APIs that separately supports forward, reverse, and batch geocoding. These APIs provide similar results as Search, but require a more structured input. They are intended for special cases where the customer requirements and user input are more narrowly defined.

With your API key, you can test out the Single Search service.

Getting Started

The single search service is available through the following URL:

https://singlesearch.alk.com/{region}/api/{endpoint}?authToken={your-api-key}

  1. In order to get a valid URL to the single search service, replace {region} above with one of the supported regions: NA, WW, EU, AS, AF, SA, OC
  2. You will need a valid API key to replace {your-api-key}
  3. Replace {endpoint} with one of the endpoints below

Endpoints

/search is the main geocoding URL and supports the parameters below.

NameDescriptionData TypeRequired
authTokenProvided API KeyYes
queryString indicating the text to search for
string
Yes
maxResultsLimits search results by the specified number. Must be a value between 1 and 100.
Int
No
currentLonLatThe current longitude and latitude, where longitude and latitude are either decimal or integer coordinates.
Complex
No
excludeResultsFor
Replaces excludedSearchTypes, which has been deprecated
A comma-separated list of InterpTypes to exclude from the search.
Available types: Country, State, County, City, ZIP, SPLC, Street, RouteNumber, RouteAlpha, POI, POIStreet, FullPostCode, POIType, CrossStreet, LatLon, and CustomPlace.
string
No
includeOnlyA comma-separated list of InterpTypes to include in the search response. Allowed filters: Country, State, County, City, POBox, Zip, SPLC, Street, RouteNumber, RouteAlpha, POI, POIStreet, FullPostCode, POIType, CrossStreet, LatLon, CustomPlace, and None. (Example: includeOnly=CustomPlace,Street. This will return only custom places and streets that match with the search string.)


To include results from ZIP codes that only apply to post office boxes, the values POBox and Zip must be included in your request.

string
No
poiCategoriesA comma-separated list of Points of Interest (POI) category names by which you want to filter all POI results. A GET call to /search/poiCategories can be used to retrieve the current list of categories available for filtering.
string
No
countriesA comma-separated list of country codes by which you want to filter all results. It defaults to ISO format.
string
No
countryTypeThe standard for country abbreviations: ISO, FIPS, GENC2, and GENC3.
string
No
statesA comma-separated list of state abbreviations by which you want to filter all results.
string
No
includeSet to include=Meta to include additional metadata in your results, such as road grid and link information as well as the confidence level of the search results. (See QueryConfidence in response parameters below.)
string
No
useCustomPlacesIf set to true, returns any custom places in the account where the location’s PlaceId or PlaceName starts with the query string. Those results will be included in the result list before any single search results.
boolean
No
separateHNSets whether the house number should be returned as a separate field from the rest of the street address. Default is false.
boolean
No
getAllHNRangesIf set to true, all potential house number ranges will be returned for a particular street match. Default is false.
boolean
No
includeTrimblePlaceIds (North America Only)Set to true to return the TrimblePlaceId, PlaceName and SiteName for a location, if they exist. Default is false.
boolean
No
langThe language to use in results. U.S. English is the default.
string
No

These additional parameters below are only applicable when performing a reverse geocode search using latitude/longitude coordinates.

NameDescriptionData TypeRequired
matchNamedRoadsOnlyWhen looking up coordinates, this forces reverse geocoding to match named roads only.
boolean
No
maxCleanupMilesWhen looking up coordinates, this sets a maximum radius, in miles, in which to find the closest matching road.
double
No
headingUsed to determine which road link to snap to. For instance, when crossing a highway. Values are:
0 - North
90 - East
180 - South
270 - East
double
No

Ways to Improve Search Speed and Results

The Search service aims to return at least 90 percent of responses in less than 200 milliseconds, with the majority of responses in 31 milliseconds or less. The response speed of any particular query can vary depending on your input and other factors. Please follow the tips below to ensure you get the fastest possible response times:

  • Search queries that contain ZIP or postal codes narrow the search and generally perform better than those without postal codes. Only 5-digit ZIP codes are supported in the U.S. (No ZIP+4 codes.)
  • Queries with a comma between street address, city, county, state, country, and postal code improve performance and may improve the accuracy of results.
  • Queries with accurate spellings and complete addresses generally perform better than those where the service has to fill in or correct details.
  • Queries with extraneous information like parking instructions or phone numbers generally take longer to process.
  • If you have structured data, using our field labels can speed up your search.
  • Transmission time may vary depending on your internet connection and location.

GET /search/types

/search/types returns the list of search’s known InterpTypes (See list above under includeOnly parameter). These are independent of the region.

GET /search/poiCategories

/search/poiCategories returns the list of search’s acceptable POI categories for filtering. These are dependent on the region.

GET /search/countries

/search/countries returns the list of search’s acceptable countries for filtering. These are dependent on the region.

GET /search/states

/search/states returns the list of search’s acceptable states for filtering. These are dependent on the region.

Example Queries

  • /search?query=1 independence way, princeton, nj, 08540&countries=US&states=NJ, NM
  • /search?query=1 independence way, princeton, nj, 08540&​currentLonLat=-74600291,40360869
  • /search?query=1 independence way, princeton, nj, 08540&excludeResultsFor=POI,POItype
  • /search?query=1 independence way, princeton, nj, 08540&poiCategories=Airport, bank, CAT scales
  • /search?query=1 independence way, princeton, nj, 08540&countries=US
  • /search?query=1 independence way, princeton, nj, 08540&countries=US&countryType=ISO
  • /search?query=1 independence way, princeton, nj, 08540&states=NJ
  • /search?query=40.3559242765905,-74.451975067144&includeTrimblePlaceIds=true

You can also use keywords within a search string to help narrow your results. The keywords available are: housenumber (or hn), route (or rt), street, county, city, zip, splc, fullpostcode, fpc, poi, state, and country.

Example

/search?query=49 Easton Ave New Brunswick state:NJ

Adding the keyword “state” forces “NJ” to be interpreted as a state, and it ensures no other term in the string can be interpreted as a state.

By adding quotation marks, multiple search terms can be grouped together with a keyword.

Example

/search?query=49 street:"Easton Ave" New Brunswick state:NJ

This forces “Easton Ave” to be the only street match.

Single Search Response

The response will include a list of resulting locations. Below are descriptions of response parameters and error codes, as well as a sample request and response.

Response Parameters

NameDescriptionType
AddressThe details about the location.
Complex
CoordsThe details about the longitude/latitude, offset to side of street when possible. For Addresses without a house number or where side of street is ambiguous the Coords and StreetCoords will be the same.
Complex
StreetCoordsThe details about the longitude/latitude along the centerline of the street.
Complex
RegionIndicates the region of the location.
Enum
POITypeIDThe type of POI based on data defines.
Ex: TypeID_TruckService = 144 or TypeID_MajorAirport = 101
Int
PersistentPOIIDA persistent ID between different versions of map data.
Complex
ResultTypeIndicates the type of match with the search string.
Int

0 = Country
1 = State
2 = County
3 = City
4 = Zip
5 = SPLC
6 = Street
7 = RouteNumber
8 = RouteAlpha
9 = POI
10 = POIStreet
11 = FullPostCode
12 = POIType
13 = CrossStreet
14 = LatLon
15 = CustomPlace
16 = None
17 = TrimblePlaces
ShortStringComplete address that matches with the query string.
string
PlaceIdUnique custom place or company id.
Alphanumeric
ErrRefer the section on error codes.
Int
QueryConfidenceThe confidence level of the search results. Included in response only if request has include=Meta
Int
TrimblePlaceIdThe identifier for a location in the Trimble Maps Places database, which includes tens of thousands of commercial locations across North America that serve the transportation industry. This ID can be used to call additional information about the Place using our Places API.
String
PlaceNameThe name of the Place in the Trimble Maps database.
String
SiteNameThe name of the Site in the Trimble Maps database.
String

Address

NameDescriptionType
StreetAddressThe house number and street name.
Ex: 1 Independence Way
string
CityThe name of the city.
Ex: Princeton
string
StateThe two letter state abbreviation.
Ex: NJ
string
ZipThe postal code or ZIP.
Ex: 08540
string
CountyThe county or jurisdiction.
Ex: Mercer
string
CountryThe code for the country.
string
CountryFullNameThe full name of the country.
string
SPLCThe Standard Point Location code to use in place of street/city/state/zip.
string

Coords

NameDescriptionType
LatLatitude
string
LonLongitude
string

Error Codes

Error CodeError
0OK
1NoGlobals
2GeoGlobals
3GridGlobals
4POIGlobals
5InvalidID
6NotImplemented
7NoQuery
8NoQueryAfterFormatting
9NoAllowedInterps
10InvalidNumResultsRequested
11NoDataLoaded
12DataLoad
13BadData
14FileMissing
15FolderIndexOOB
16CityFileClientOOB
17OOB
18FileIO
19Memory
20NoPreviousSearch
21ThreadStart
22ThreadEnqueue
23ObjectNotInitialized
24POIData
25Internal
26QueryIsNotUTF8
27InvalidQuery
28InvalidInterpRankingSettings
29InvalidParameters
30SynonymVersionMismatch
31SynonymAmbiguityMismatch
32FrequenciesDisabled
33TimeOut
34InvalidInputCountry
35InvalidInputState
36StateIsNotPartOfCountry
37IndexVersionMismatch
38InvalidLatLonForRegion
39Unknown

Sample Request

Here is an example for the query “1 Independence Way”.

The URL for the request is:
https://singlesearch.alk.com/na/api/search?authToken=<APIKEY>&query=1%20independence%20way

Sample Response

The full response for the above request is:

{
      "Err": 0,
    "Locations": [
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Jersey City",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "07305",
                "County": "Hudson",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.688199",
                "Lon": "-74.074366"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Jersey City, NJ, US, Hudson 07305",
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Cranston",
                "State": "RI",
                "StateName": "Rhode Island",
                "Zip": "02921",
                "County": "Providence",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "41.78962",
                "Lon": "-71.500717"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Cranston, RI, US, Providence 02921",
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Princeton",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "08540",
                "County": "Mercer",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.360723",
                "Lon": "-74.599963"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Princeton, NJ, US, Mercer 08540",
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Brenham",
                "State": "TX",
                "StateName": "Texas",
                "Zip": "77833",
                "County": "Washington",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "30.249221",
                "Lon": "-96.363437"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Brenham, TX, US, Washington 77833",
            "TimeZone": "CST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Doylestown",
                "State": "PA",
                "StateName": "Pennsylvania",
                "Zip": "18901",
                "County": "Bucks",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.312962",
                "Lon": "-75.149676"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Doylestown, PA, US, Bucks 18901",
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Edgewater",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "07020",
                "County": "Bergen",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.810277",
                "Lon": "-73.987319"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Edgewater, NJ, US, Bergen 07020",
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Falmouth",
                "State": "ME",
                "StateName": "Maine",
                "Zip": "04105",
                "County": "Cumberland",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "43.761429",
                "Lon": "-70.325684"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Falmouth, ME, US, Cumberland 04105",
            "TimeZone": "EST"
        }
    ]
}

Sample Request with Metadata

Here is an example for the query “1 Independence Way”.

The URL for the request is:
https://singlesearch.alk.com/na/api/search?authToken=<APIKEY>&query=1%20independence%20way&include=Meta

Sample Response with Metadata

{
    "Err": 0,
    "ErrString": "OK",
    "QueryConfidence": 3,
    "TimeInMilliseconds": 141,
    "GridDataVersion": "GRD_ALK.NA.2021.04.17.9.1.1",
    "CommitID": "pcmws-24.0.0.0-603-g8bd268659a1: 01/25/2022 20:35",
    "Locations": [
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Jersey City",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "07305",
                "County": "Hudson",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.688199",
                "Lon": "-74.074366"
            },
            "StreetCoords": {
                "Lat": "40.688243",
                "Lon": "-74.074401"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Jersey City, NJ, US, Hudson 07305",
            "GridID": 10008076,
            "LinkID": 217,
            "Percent": 4313,
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Cranston",
                "State": "RI",
                "StateName": "Rhode Island",
                "Zip": "02921",
                "County": "Providence",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "41.78962",
                "Lon": "-71.500717"
            },
            "StreetCoords": {
                "Lat": "41.789651",
                "Lon": "-71.50067"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Cranston, RI, US, Providence 02921",
            "GridID": 6393356,
            "LinkID": 420,
            "Percent": 2126,
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Princeton",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "08540",
                "County": "Mercer",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.360723",
                "Lon": "-74.599963"
            },
            "StreetCoords": {
                "Lat": "40.360684",
                "Lon": "-74.600003"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Princeton, NJ, US, Mercer 08540",
            "GridID": 15414796,
            "LinkID": 926,
            "Percent": 5215,
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Brenham",
                "State": "TX",
                "StateName": "Texas",
                "Zip": "77833",
                "County": "Washington",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "30.249221",
                "Lon": "-96.363437"
            },
            "StreetCoords": {
                "Lat": "30.249173",
                "Lon": "-96.363447"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Brenham, TX, US, Washington 77833",
            "GridID": 16623332,
            "LinkID": 257,
            "Percent": 2033,
            "TimeZone": "CST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Doylestown",
                "State": "PA",
                "StateName": "Pennsylvania",
                "Zip": "18901",
                "County": "Bucks",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.312962",
                "Lon": "-75.149676"
            },
            "StreetCoords": {
                "Lat": "40.313006",
                "Lon": "-75.14971"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Doylestown, PA, US, Bucks 18901",
            "GridID": 1259020,
            "LinkID": 461,
            "Percent": 2705,
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Edgewater",
                "State": "NJ",
                "StateName": "New Jersey",
                "Zip": "07020",
                "County": "Bergen",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "40.810277",
                "Lon": "-73.987319"
            },
            "StreetCoords": {
                "Lat": "40.810305",
                "Lon": "-73.987367"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Edgewater, NJ, US, Bergen 07020",
            "GridID": 8250892,
            "LinkID": 414,
            "Percent": 6588,
            "TimeZone": "EST"
        },
        {
            "Address": {
                "StreetAddress": "1 Independence Way",
                "City": "Falmouth",
                "State": "ME",
                "StateName": "Maine",
                "Zip": "04105",
                "County": "Cumberland",
                "Country": "US",
                "CountryFullName": "United States",
                "SPLC": null
            },
            "Coords": {
                "Lat": "43.761429",
                "Lon": "-70.325684"
            },
            "StreetCoords": {
                "Lat": "43.76137",
                "Lon": "-70.325677"
            },
            "Region": 4,
            "POITypeID": 0,
            "PersistentPOIID": -1,
            "SiteID": -1,
            "ResultType": 6,
            "ShortString": "1 Independence Way, Falmouth, ME, US, Cumberland 04105",
            "GridID": 11520524,
            "LinkID": 131,
            "Percent": 838,
            "TimeZone": "EST"
        }
    ]
}

Sample Request with includeTrimblePlaceIds=true

Here is an example query using coordinates for a Costco distribution center in New Jersey.

The URL for the request is:

https://singlesearch.alk.com/na/api/search?authToken=<APIKEY>&query=40.3559242765905,-74.451975067144&includeTrimblePlaceIds=true

Sample Response with includeTrimblePlaceIds=true

{
  "Err": 0,
  "Locations": [
    {
      "Address": {
        "StreetAddress": "",
        "City": "Monroe Township",
        "State": "NJ",
        "StateName": "New Jersey",
        "Zip": "08831",
        "County": "Middlesex",
        "Country": "US",
        "CountryFullName": "United States",
        "SPLC": null
      },
      "Coords": {
        "Lat": "40.355924",
        "Lon": "-74.451975"
      },
      "Region": 4,
      "POITypeID": 0,
      "PersistentPOIID": -1,
      "SiteID": -1,
      "ResultType": 14,
      "ShortString": "Monroe Township, NJ, US, Middlesex 08831"
    },
    {
      "POITypeID": 0,
      "PersistentPOIID": -1,
      "SiteID": -1,
      "ResultType": 17,
      "ShortString": "0xztR_iLMWM0eZWyV3GACigA, Costco #175",
      "TrimblePlaceId": "0xztR_iLMWM0eZWyV3GACigA",
      "PlaceName": "Costco #175",
      "SiteName": "Costco #175"
    },
    {
      "POITypeID": 0,
      "PersistentPOIID": -1,
      "SiteID": -1,
      "ResultType": 17,
      "ShortString": "0x4Y4CTmYr6kauPugLT9k4zg, Costco #265",
      "TrimblePlaceId": "0x4Y4CTmYr6kauPugLT9k4zg",
      "PlaceName": "Costco #265",
      "SiteName": "Costco #175"
    }
  ]
}
Last updated September 1, 2022.