# `client.FindPlace()`

Find Place

Returns place suggestions for a query, ranked by relevance. Places cover countries, administrative areas, capitals and other administrative seats.

## Implementing Place Autocomplete

Retrieving a full place takes two requests:

1. Fetch suggestions from `/places`
2. Fetch the place using the `id` on a suggestion

A query returns at most 10 suggestions. An empty query returns an empty result set. Show users the `descriptive_name`. The API drops suggestions that share one, so each name in a response identifies a single place.

## Rate Limiting and Cost

The rate limit is 3,000 requests per 5 minutes.

`/places` does not decrement your lookup balance, but resolving a suggestion to a full place does. We rate limit and then suspend integrations that repeatedly call `/places` without resolving.

## Endpoint

`GET /places`

See the [API reference](/docs/api/find-place.md) for this endpoint.

## Signature

```go
func (c *Client) FindPlace(ctx context.Context, params *FindPlaceParams) (*PlaceResponse, error)
```

## Arguments

| Name     | Type               | Required | Description                                                                            |
| -------- | ------------------ | -------- | -------------------------------------------------------------------------------------- |
| `ctx`    | `context.Context`  | yes      | Cancels the request and sets its deadline.                                             |
| `params` | `*FindPlaceParams` | no       | Optional query parameters, or nil. Fields under [Query Parameters](#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                                                                                                                                                        |
| ------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `query`            | `string` | no       | Specifies the place to query. Can be shortened to `q=`                                                                                                             |
| `country_iso`      | `string` | no       | Filter by Country                                                                                                                                                  |
| `bias_country_iso` | `string` | no       | Bias by Country Bias by country ISO code. Uses 3 letter country code (ISO 3166-1) standard. Bias by multiple countries with a comma separated list. E.g. `GBR,IRL` |
| `bias_lonlat`      | `string` | no       | Bias by Geolocation                                                                                                                                                |
| `bias_ip`          | `string` | no       | Bias by Geolocation of IP                                                                                                                                          |

## Response

`*idealpostcodes.PlaceResponse`. Fields the API may leave out or send as null are pointers. `RawJSON()` returns the body as received. See [responses](/docs/sdks/go/responses.md).

## Errors

An HTTP error returns `*idealpostcodes.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](/docs/sdks/go/errors.md).

## Example

find-place/main.gogo

```go
package main

import (
	"context"
	"fmt"
	"log"

	idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
	client := idealpostcodes.NewClient("ak_test")
	res, err := client.FindPlace(context.Background(), &idealpostcodes.FindPlaceParams{
		Query:      "Strumpshaw",
		CountryISO: "GBR",
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, hit := range res.Result.Hits {
		if place := hit.AsPlaceSuggestion(); place != nil {
			fmt.Printf("%s: %s\n", place.ID, place.DescriptiveName)
		}
	}
}
```
