client.ResolvePlace()
Resolve Place
Returns the full place for a place ID taken from a /places suggestion.
On top of the fields carried by the suggestion, the response adds coordinates, language and the underlying dataset record.
Each request decrements your lookup balance. An unknown ID returns 404.
Endpoint
GET /places/{place}
See the API reference for this endpoint.
Signature
func (c *Client) ResolvePlace(ctx context.Context, place string, params *ResolvePlaceParams) (*ResolvePlaceResponse, error)Arguments
| Name | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | yes | Cancels the request and sets its deadline. |
place | string | yes | ID of place suggestion |
params | *ResolvePlaceParams | no | Optional query parameters, or nil. Fields under Query Parameters. |
Query Parameters
A required parameter is a method argument. Set the rest as fields of params, named in Studly case (post_town is PostTown); a field left at its zero value is not sent.
| Name | Type | Required | Description |
|---|---|---|---|
tags | string | no | Tags |
Response
*addresszen.ResolvePlaceResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.
Errors
An HTTP error returns *addresszen.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.
Example
package main
import (
"context"
"fmt"
"log"
addresszen "go.addresszen.com/sdk"
)
func main() {
client := addresszen.NewClient("ak_test")
res, err := client.ResolvePlace(context.Background(), "geonames_5454627", nil)
if err != nil {
log.Fatal(err)
}
place := res.Result
fmt.Printf("%s (%s)\n", place.DescriptiveName, place.CountryISO)
fmt.Printf("%s, %s\n", place.Latitude, place.Longitude)
}