Skip to Content
IntegrationsGeocoding

Geocoding

Address autosuggest needs a geocoder; listings themselves arrive geocoded from Repliers. Two providers exist, each a small axios client with a single GET call and no retry (src/services/mapbox.ts, src/services/google.ts). Where each provider is used:

EndpointMapboxGoogle
GET /api/autosuggestalways (the mapbox block)never
GET /api/autosuggest/addresswhen REPLIERS_AUTOSUGGEST_PROVIDER is anything but googlemapswhen it is googlemaps

The branches, ranking and failure behaviour are on Autosuggest. Because the combined endpoint always calls Mapbox, MAPBOX_ACCESS_TOKEN is needed whichever provider is selected: the server asserts it at start-up (src/config.ts).

Mapbox (default)

MapboxService (src/services/mapbox.ts) calls the Search Box API at MAPBOX_BASEURL (default https://api.mapbox.com/search/searchbox/v1) with access_token from MAPBOX_ACCESS_TOKEN on every request and a timeout of MAPBOX_TIMEOUT ms (30 s). Only GET /suggest is used; the session_token is the request’s searchSession (or the deprecated mapboxSearchSession), with a random UUID as a fallback.

Parameter sentValueSet by
qthe request’s qrequest
proximitylong,lat (request values, defaulting to the proximity settings)request, PROXIMITY_SEARCH_LAT, PROXIMITY_SEARCH_LONG
countrycaPROXIMITY_SEARCH_COUNTRY, preset mapbox.autosuggest.country (the defaults preset: us)
languageenPROXIMITY_SEARCH_LANGUAGE, preset mapbox.autosuggest.language
limit10 (combined endpoint only)REPLIERS_AUTOSUGGEST_MAX_RESULTS, preset mapbox.autosuggest.limit
typesstreet,postcode,address on the combined endpoint, address on /addressmapbox.autosuggest.types (no environment variable; the /address value is fixed in code)

Settings applied by the proxy after the response, none of which is sent to Mapbox:

SettingDefaultEffect
mapbox.autosuggest.max_distancethe proximity radius in metresdrops suggestions whose distance is larger
mapbox.autosuggest.region_codeunset (PROXIMITY_SEARCH_REGION_CODE)keeps only suggestions in that region
mapbox.autosuggest.jaro_winkler_distance0.9 in the environment-built configuration; 0.95 in the defaults presetsimilarity at or above which a combined-endpoint suggestion is dropped as a near duplicate

jaro_winkler_distance and types have no environment variable: they can be changed only in a settings preset, which is merged over the environment-built configuration at start-up (Configuration resolution). The filtering steps are described under Mapbox ranking.

A Mapbox failure is rethrown as ApiError("Mapbox API error") carrying the upstream status and body. Both clients read e.response.status in the handler, so a failure with no HTTP response (a timeout or network error) surfaces as a TypeError, not an ApiError.

Google Maps (alternative)

GoogledService (src/services/google.ts) calls GET /place/autocomplete/json at GOOGLE_MAPS_BASE_URL (default https://maps.googleapis.com/maps/api) with key from GOOGLE_MAPS_API_KEY and a timeout of GOOGLE_MAPS_TIMEOUT_MS (30 s). It is reached only from /autosuggest/address when REPLIERS_AUTOSUGGEST_PROVIDER=googlemaps.

Parameter sentValue
inputthe request’s q
typesaddress
language, components, includedRegionCodesPROXIMITY_SEARCH_LANGUAGE; country: and the country from PROXIMITY_SEARCH_COUNTRY (default ca)
location, radius, locationrestriction, strictboundsthe request’s lat,long and radius; circle:<radius>@<lat>,<long>; true
sessiontokenthe request’s session UUID
includePureServiceAreaBusinessesfalse

status ZERO_RESULTS returns an empty list; a status other than OK throws. The response text is parsed into address parts with the addresser library, and the country falls back to Canada when a prediction has no terms. None of the Mapbox filters applies.

Proximity bias

Both providers bias suggestions toward the instance’s market: PROXIMITY_SEARCH_LAT / PROXIMITY_SEARCH_LONG / PROXIMITY_SEARCH_RADIUS_METERS (preset: repliers.autosuggest.{lat,long,radius}). The values are also the defaults of the lat, long and radius request parameters, so a client that sends none is centred on the instance. The environment defaults are a point in eastern Canada with a radius of 150 000 m; the defaults preset centres on the middle of the United States with an effectively unlimited radius (150000000); a real instance narrows this to its market.

The radius has three roles that do not all follow the request: Mapbox gets only the centre (proximity) and the proxy filters by max_distance; Google gets the request’s radius as a strict circle; the listings branch of the combined endpoint always uses the configured radius.

Verified against portal-backend 997ae3e, 2026-10-20.

Last updated on