# Swiftcomplete Address Autocomplete API

Suggest addresses as users type a street, postcode or full address, then retrieve the structured address they select.

Topics: SwiftComplete, Server and Scripting

Section: [Postal Addresses via Swiftcomplete](https://developer.what3words.com/docs/postal-addresses-via-swiftcomplete.md) > [Address Autocomplete](https://developer.what3words.com/docs/postal-addresses-via-swiftcomplete/address-autocomplete.md)

Source: https://developer.what3words.com/tutorial/swiftcomplete-address-autocomplete-api

Updated: 2026-11-30

> [!TIP]
> For support getting set up, contact us via the [Swiftcomplete webpage](https://what3words.com/swiftcomplete).

## 1. Overview

Send the user's search text to Swiftcomplete and display the suggestions it returns. If the user picks an individual address, retrieve its full details. If they pick a container, such as a postcode or street, open it and let them choose an address from the results.

A populated result includes address lines and a display label. It can also include structured address components and coordinates.

## 2. Base endpoint

**Endpoint**

```http
https://api.swiftcomplete.com/v1/swiftlookup/
```

Use HTTPS `GET` requests with the parameters in the query string.

## 3. Request parameters

| Query parameter | Description |
| --- | --- |
| `key` | Your Swiftcomplete API key. |
| `text` | The search text entered by the user. |
| `biasTowards` | Optional coordinates in `lat,lon` format. Favours results near that location. |
| `populateIndex` | The selected item's zero-based index in the response array. Requests the full address for that item. |
| `countries` | Comma-separated country codes that limit where the API searches. |
| `container` | The value returned with a container suggestion. Send it to fetch the addresses it contains. |
| `maxResults` | The maximum number of child results to return in a container request, up to 100. |
| `pageFrom` | The offset at which to start the next page of child results. |

## 4. Standard autocomplete flow

### Search on every keystroke

As the user types, send the current contents of the address field in `text`.

**Request**

```http
GET https://api.swiftcomplete.com/v1/swiftlookup/?key=INSERT_KEY_HERE&text=what3
```

The example response below shows the first two suggestions.

**Response**

```json
[
  {
    "primary": { "text": "What3words, Alfred Rd", "highlights": [0, 4] },
    "secondary": { "text": "London", "highlights": [] },
    "type": "address.business",
    "isContainer": false,
    "countryCode": "GB"
  },
  {
    "primary": { "text": "Sew What, 34 Caledonian Rd", "highlights": [4, 7, 10, 10] },
    "secondary": { "text": "Wishaw", "highlights": [] },
    "type": "address.business",
    "isContainer": false,
    "countryCode": "GB"
  }
]
```

### Display the suggestion list

| Response field | How to use it |
| --- | --- |
| `primary.text` | Display as the main text for the suggestion. |
| `secondary.text` | Display as supporting text. |
| `primary.highlights`, `secondary.highlights` | Highlight the matching character ranges in each display string. |
| `type` | Identify the kind of result. |
| `isContainer` | Decide whether to open a container or populate the selected result directly. |
| `countryCode` | Identify the country associated with the suggestion. |

### Populate a selected result

When the user chooses a suggestion with `isContainer` set to `false`, repeat the exact request that returned it and add `populateIndex` with its position in the array. The first result has index `0`.

**Request**

```http
GET https://api.swiftcomplete.com/v1/swiftlookup/?key=INSERT_KEY_HERE&text=what3&populateIndex=0
```

**Response**

```json
[
  {
    "primary": { "text": "What3words, Alfred Rd", "highlights": [0, 4] },
    "secondary": { "text": "London", "highlights": [] },
    "isContainer": false,
    "geometry": {
      "centre": {
        "lat": 51.521198,
        "lon": -0.196334
      }
    },
    "populatedRecord": {
      "lines": [
        "What3words Ltd",
        "65 Alfred Road",
        "LONDON",
        "W2 5EU",
        "United Kingdom"
      ],
      "label": "What3words Ltd\n65 Alfred Road\nLONDON\nW2 5EU\nUnited Kingdom"
    }
  }
]
```

### Use the populated record

- Use `populatedRecord.lines` for the individual address lines.
- Use `populatedRecord.label` for a display label with line breaks.
- Read structured address components from `populatedRecord.data` when present.
- Read latitude and longitude from `geometry.centre.lat` and `geometry.centre.lon` when available.

## 5. Container flow

If a suggestion has `isContainer` set to `true`, open it first. Apply `populateIndex` to the request that returned the chosen child address.

### Search for a container

In this example, a postcode search returns one suggestion with a `container` value.

**Request**

```http
GET https://api.swiftcomplete.com/v1/swiftlookup/?key=INSERT_KEY_HERE&text=ng97bs
```

**Response**

```json
[
  {
    "primary": { "text": "NG9 7BS", "highlights": [0, 2, 4, 6] },
    "secondary": { "text": "Brookhill St", "highlights": [] },
    "type": "place.area.postcode",
    "isContainer": true,
    "container": "V1;NG9 7BS;52.923435;-1.279735",
    "countryCode": "GB"
  }
]
```

### Open the container

Start a new request using the returned `container` value. This example uses `maxResults=100` and encodes the space in the postcode as `%20`.

**Request**

```http
GET https://api.swiftcomplete.com/v1/swiftlookup/?key=INSERT_KEY_HERE&container=V1;NG9%207BS;52.923435;-1.279735&maxResults=100
```

The example response below shows the first two child results.

**Response**

```json
[
  {
    "primary": { "text": "2 Brookhill St" },
    "secondary": { "text": "Stapleford, NG9 7BS" },
    "isContainer": false
  },
  {
    "primary": { "text": "2a Brookhill St" },
    "secondary": { "text": "Stapleford, NG9 7BS" },
    "isContainer": false
  }
]
```

### Let the user choose a child result

Display the child addresses as a second list of suggestions.

### Populate the selected child result

Repeat the container request that returned the chosen address. Keep its existing parameters, including `pageFrom` if the result came from a later page, and add `populateIndex` with the child's index in that response.

## 6. Container pagination

If the response contains exactly `maxResults` items, another page may be available. Use `pageFrom` to fetch it. For example, to fetch the next page after the first 10 results, set `pageFrom=10`.

**Request**

```http
GET https://api.swiftcomplete.com/v1/swiftlookup/?key=INSERT_KEY_HERE&container=V1;NG9%207BS;52.923435;-1.279735&maxResults=10&pageFrom=10
```

Advance `pageFrom` by the page size after each full page. Stop when the response contains fewer items than `maxResults`.

## 7. Recommended UI flow

### Typing

Call `swiftlookup` with the current `text` after each keystroke and display the results as suggestions.

### Selecting a non-container result

Repeat the search request with the selected index in `populateIndex`. Use the returned `populatedRecord` to fill the address fields.

### Selecting a container result

Open the container and show its child addresses. When the user picks one, repeat the request for that list or page with the chosen index in `populateIndex`.

## 8. Important implementation rules

- Send the current search text after each keystroke.
- For a population request, keep the original query parameters and add only `populateIndex`.
- Open a container before populating any of its child addresses.
- Use `pageFrom` for container pagination and stop after a response with fewer than `maxResults` items.

## 9. Integration logic

**Pseudocode**

```
suggestions = lookup(key, text)

When the user selects a suggestion:
  If isContainer is false:
    Repeat the search request with populateIndex set to the selected index
    Use populatedRecord

  If isContainer is true:
    Request the child results with key, container and maxResults
    If a page is full, fetch the next page with pageFrom as needed
    When the user selects a child, repeat the request for its page
      with populateIndex set to the child's index on that page
    Use populatedRecord
```

## 10. Response fields to store

| Field | Value |
| --- | --- |
| `populatedRecord.label` | Address formatted as a multiline label. |
| `populatedRecord.lines` | Individual address lines in an array. |
| `populatedRecord.data` | Structured address components, when present. |
| `geometry.centre.lat` | Latitude, when available. |
| `geometry.centre.lon` | Longitude, when available. |
| `countryCode` | Country code. |

## 11. Summary

Search with `text` as the user types. To retrieve a direct address, repeat the search with `populateIndex`. For a container, fetch its child results, page through them with `pageFrom` if needed, and use `populateIndex` on the request that returned the chosen child.

### Find out more

[Explore the Swiftcomplete website](https://what3words.com/swiftcomplete)

Can’t find what you’re looking for, or want to report an issue? [Get in touch here](https://share.hsforms.com/1gonG2sDNQhWIqB3BhKVK7A1p3ix).
