# Address search

> Street addresses from Google, to fill in an address form. Answers 503 where address search isn't set up: then let the address be typed.

Street addresses from Google, to fill in an address form. Answers 503 where address search isn't set up: then let the address be typed. Generated from the [OpenAPI spec](https://dev.mongrl.com/openapi.json). Each endpoint says which key it needs; see [Authentication](https://dev.mongrl.com/guides/authentication.md).

| Method | Path | What it does |
|---|---|---|
| GET | [`/v1/places/autocomplete`](#suggest-addresses-for-whats-been-typed) | Suggest addresses for what's been typed |
| GET | [`/v1/places/{id}`](#a-suggested-address-in-full) | A suggested address in full |

## Suggest addresses for what's been typed

`GET /v1/places/autocomplete` · operation `searchPlaces`

Street addresses matching q, from Google. Use the same session for every keystroke of one search and for the GET /v1/places/{id} that ends it (Google bills a search once). 503 when address search isn't set up.

**Auth:** a secret or publishable key (`Authorization: Bearer sk_…` or `pk_…`)

**Parameters**

| Name | In | Type | Notes |
|---|---|---|---|
| `q` | query | string | What's been typed. max 200 chars |
| `session` | query | string | A random token for this search, e.g. a UUID. max 100 chars |
| `language` | query | string | Answer in this language (default: the marketplace's). max 35 chars |
| `country` | query | string[] | Only these countries (ISO codes) |

**Responses:** `200` [SearchPlacesResponse](#searchplacesresponse) · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## A suggested address in full

`GET /v1/places/{id}` · operation `getPlace`

The street, postal code, city, country and coordinates of a place from GET /v1/places/autocomplete.

**Auth:** a secret or publishable key (`Authorization: Bearer sk_…` or `pk_…`)

**Parameters**

| Name | In | Type | Notes |
|---|---|---|---|
| `id` * | path | string | max 300 chars |
| `session` | query | string | The search's session, to end it. max 100 chars |
| `language` | query | string | max 35 chars |

**Responses:** `200` [AddressBody](#addressbody) · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## Schemas

Fields marked * are always present in responses and required in requests.

### SearchPlacesResponse

| Field | Type | Notes |
|---|---|---|
| `items` * | [SuggestionBody](#suggestionbody)[] |  |

### AddressBody

| Field | Type | Notes |
|---|---|---|
| `city` * | string |  |
| `country` * | string | ISO 3166-1 alpha-2 |
| `formatted` * | string | The address on one line |
| `latitude` * | number (double) |  |
| `line1` * | string |  |
| `line2` | string |  |
| `longitude` * | number (double) |  |
| `place_id` * | string |  |
| `postal_code` * | string |  |

### SuggestionBody

| Field | Type | Notes |
|---|---|---|
| `main` * | string | The street part, e.g. Hallvägen 29 |
| `place_id` * | string | Pass to GET /v1/places/{id} for the full address |
| `secondary` * | string | The rest, e.g. Johanneshov, Sweden |
| `text` * | string | The whole suggestion, on one line |
