Skip to content
GuidesPlaygroundDashboard

Autocomplete a partial address

client.Geocode.Autocomplete(ctx, query) (*AutocompleteResult, error)
GET/api/v1/geocode/autocomplete

Autocomplete a partial address

ParametersExpand Collapse
query GeocodeAutocompleteParams
Q param.Field[string]

Partial address query

CountryCode param.Field[string]optional

ISO 3166-1 alpha-2 country code filter

Lang param.Field[string]optional

Language code for localized names (e.g. en, de, fr)

Lat param.Field[float64]optional

Focus latitude

Layer param.Field[string]optional

Filter by layer: address, poi, or admin

Limit param.Field[int64]optional

Maximum results (default 10, max 20)

Lng param.Field[float64]optional

Focus longitude

ReturnsExpand Collapse
type AutocompleteResult struct{…}

GeoJSON FeatureCollection of autocomplete suggestions

Features []GeocodingFeature
Coordinates GeoJsonGeometryCoordinatesUnion

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
type GeoJsonGeometryCoordinatesArray []float64
type GeoJsonGeometryCoordinatesArray [][]float64
type GeoJsonGeometryCoordinatesArray [][][]float64
type GeoJsonGeometryCoordinatesArray [][][][]float64
Type GeoJsonGeometryType
One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties GeocodingFeatureProperties
CountryCode stringoptional

ISO 3166-1 alpha-2 country code

DisplayName stringoptional

Formatted address or place name

DistanceM float64optional

Distance in meters

OsmID int64optional

OpenStreetMap ID

OsmType stringoptional

OSM element type

Score float64optional

Match confidence score

Source stringoptional

Result source (address, place, interpolation)

Type GeocodingFeatureType
Type AutocompleteResultType

Autocomplete a partial address

package main

import (
  "context"
  "fmt"

  "github.com/plazafyi/plaza-go"
  "github.com/plazafyi/plaza-go/option"
)

func main() {
  client := githubcomplazafyiplazago.NewClient(
    option.WithAPIKey("My API Key"),
  )
  autocompleteResult, err := client.Geocode.Autocomplete(context.TODO(), githubcomplazafyiplazago.GeocodeAutocompleteParams{
    Q: githubcomplazafyiplazago.F("q"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", autocompleteResult.Features)
}
Returns Examples