Geocoding is optimized for nearly-complete addresses. If you have a partial name or fuzzy query, use Search or Autocomplete instead.
Forward geocoding
Pass an address string toGeocodeInput.builder() and call api.geocode(). The result is a PlaceResults containing a list of Place objects.
Builder options
GeocodeInput.builder(address) returns a fluent builder with the following optional methods:
| Method | Type | Description |
|---|---|---|
.language(String) | BCP 47 tag | Response language, e.g. "de-DE". Defaults to en-US. |
.userLocation(UserLocation) | UserLocation | Hint the user’s current position for better result ordering. |
.searchLocation(SearchLocation) | SearchLocation | Bias results toward a specific coordinate. |
.searchRegion(SearchRegion) | SearchRegion | Constrain results to a bounding region. |
.limitToCountries(List<String>) | ISO 3166-1 alpha-2 codes | Restrict results to one or more countries, e.g. List.of("US", "CA"). |
Reverse geocoding
Callapi.reverseGeocode(latitude, longitude) to resolve a coordinate pair into a PlaceResults. The default response language is en-US.
null or a blank string, the SDK falls back to en-US.
Response structure
Both methods returnPlaceResults, whose results() field is a List<Place>. Each Place record exposes:
| Field | Type | Description |
|---|---|---|
coordinate() | Location | Latitude and longitude. |
name() | String | Place name or street address. |
formattedAddressLines() | List<String> | Display-ready address lines. |
structuredAddress() | Optional<StructuredAddress> | Parsed address components. |
id() | Optional<String> | Place identifier (usable with Place Lookup). |
country() | String | Country name. |
countryCode() | String | ISO country code, e.g. "US". |
StructuredAddress breaks the address into components:
| Field | Type | Description |
|---|---|---|
thoroughfare() | Optional<String> | Street name, e.g. "Harrison St" |
subThoroughfare() | Optional<String> | Street number, e.g. "880" |
fullThoroughfare() | Optional<String> | Combined street number and name |
locality() | Optional<String> | City, e.g. "San Francisco" |
subLocality() | Optional<String> | Neighborhood, e.g. "Yerba Buena" |
administrativeArea() | Optional<String> | State or province, e.g. "California" |
administrativeAreaCode() | Optional<String> | State code, e.g. "CA" |
subAdministrativeArea() | Optional<String> | County or district, if available |
postCode() | Optional<String> | Postal code, e.g. "94107" |
areasOfInterest() | List<String> | Named areas of interest at this location. |
dependentLocalities() | List<String> | Sub-locality names (e.g. ["Yerba Buena"]). |
Example JSON response
When to use geocoding vs. search
Use Geocode
You have a complete or nearly-complete street address:
"880 Harrison St, San Francisco, CA 94107".Use Search or Autocomplete
You have a business name, partial address, or fuzzy query:
"Stripe SF" or "coffee near me".