# Suggest locations

Source: https://help.ruuster.com/idx/suggest

> Turn what a visitor typed into locations they can pick, each with a ready-made where object to search with.

```http
GET https://idx.ruuster.com/v1/suggest
```

publishable or secret key · 1 unit · cached 3600 s

Type-ahead for your search box. It answers rows in groups (city, ZIP code, neighborhood, county,
school, subdivision, place and others), each with a `label` to show and a `where` object to pass to
search, market and similar homes exactly as it came.

## What to know

- **Debounce it.** Wait for three characters and a 300 ms pause, and cancel the call in flight when the
  visitor types again. `SearchBox` does this.
- `groups` picks the groups as a comma list. The `listing` group (MLS numbers) is added only when you
  ask for it. `limit` is per group, up to 10.
- On your server, use it with the secret key to look up each area once and store its `where` object.
- [Locations](https://help.ruuster.com/idx/guide-locations) explains each group and how to combine locations.

## Query parameters

| Name | Type | Description |
|---|---|---|
| `q` | string | What the person typed: an address, city, ZIP, neighborhood, school, MLS number, … (at least 2 to 3 characters). At most 80 characters. Required. |
| `limit` | integer 1 to 10, default 7 | Suggestions per group (1 to 10). |
| `groups` | enum, comma list | Which suggestion groups to answer (a comma list). Default: address, city, zip, neighborhood, county, countyOrParish, school, subdivision, area, community, place. place = named places with an outline (cities and towns, ZIP areas, counties, neighborhoods, subdivisions, school districts) in the states the account's boards cover. listing (MLS numbers) is opt-in. mlsArea, agent and office are accepted but answer nothing: search by agent, office or ownListings instead. Values: `address`, `listing`, `city`, `zip`, `neighborhood`, `county`, `countyOrParish`, `school`, `subdivision`, `area`, `community`, `mlsArea`, `agent`, `office`, `place`. |
| `format` | enum, default json | json = the public API shapes; widget = the shapes the Ruuster widget reads (for the widget and its adapters). Values: `json`, `widget`. |

## Response

The answer is `{ ok: true, data, meta }`. These are the fields of `data`; `meta` carries `brokerageId`, `freshness.asOf`, `mls` (each board's display rules) and `canonical`.

| Field | Type | Description |
|---|---|---|
| `[].group` | string (enum) | One of `address`, `listing`, `city`, `zip`, `neighborhood`, `county`, `countyOrParish`, `school`, `subdivision`, `area`, `community`, `mlsArea`, `agent`, `office`, `place`. |
| `[].label` | string |  |
| `[].where` | object | Pass back to /v1/listings as where=<this JSON>, unchanged. |
| `[].where.label` | string |  |
| `[].where.value` | string |  |
| `[].where.source` | string (enum) | One of `googleAutocomplete`, `school`, `neighborhood`, `county`, `subdivision`, `area`, `community`, `crm-system`, `subdivisionAndCity`, `addressByOpenSearch`, `listingId`, `countyOrParish`, `customPolygon`, `library`. |
| `[].where.data` | object |  |
| `[].where.data.type` | string or number or boolean |  |
| `[].where.data.state` | string or number or boolean |  |
| `[].where.data.city` | string or number or boolean |  |
| `[].where.data.postalCode` | string or number or boolean |  |
| `[].where.data.country` | string or number or boolean |  |
| `[].where.data.mlsId` | string or number or boolean |  |
| `[].where.data.address` | string or number or boolean |  |
| `[].where.data.kind` | string or number or boolean |  |
| `[].where.city` | string | crm-system: the city name. |
| `[].where.state` | string | crm-system: the state code. |
| `[].where.postalCode` | string | crm-system: the ZIP or postal code. |

## Errors

These are the error codes this endpoint can answer. Every error has the same body; [Errors](https://help.ruuster.com/idx/reference-errors) explains each code and what to show.

`invalid_parameter`, `secret_key_in_url`, `invalid_credentials`, `missing_credentials`, `payment_required`, `access_revoked`, `brokerage_not_enabled`, `origin_not_allowed`, `origin_required`, `secret_key_in_browser`, `daily_quota_exceeded`, `rate_limited`, `internal_error`, `api_paused`, `source_unavailable`

## Example request

cURL:

```bash
curl -s -G "https://idx.ruuster.com/v1/suggest" \
  --data-urlencode q=Atlanta \
  --data-urlencode limit=5 \
  -H "Authorization: Bearer $IDX_SECRET_KEY"
```

TypeScript:

```typescript
import { createClient } from "@ruuster/idx";

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });

const r = await idx.suggest({
  q: "Atlanta",
  limit: 5,
});
if (!r.ok) throw new Error(`${r.error.code}: ${r.error.message}`);
console.log(r.data);
```

Python:

```python
import os

import requests

res = requests.get(
    "https://idx.ruuster.com/v1/suggest",
    params={
        "q": "Atlanta",
        "limit": "5",
    },
    headers={"Authorization": "Bearer " + os.environ["IDX_SECRET_KEY"]},
    timeout=30,
)
body = res.json()
if not body["ok"]:
    raise RuntimeError(body["error"]["code"] + ": " + body["error"]["message"])
print(body["data"])
```

PHP:

```php
<?php

$query = http_build_query([
    'q' => 'Atlanta',
    'limit' => '5',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/suggest' . '?' . $query);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('IDX_SECRET_KEY')],
    CURLOPT_TIMEOUT => 30,
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$body['ok']) {
    throw new RuntimeException($body['error']['code'] . ': ' . $body['error']['message']);
}
print_r($body['data']);
```

## Example response

```json
{
  "ok": true,
  "data": [
    {
      "group": "city",
      "label": "Atlanta, GA",
      "where": {
        "label": "Atlanta, GA",
        "value": "Atlanta",
        "source": "crm-system",
        "data": {
          "state": "GA",
          "city": "Atlanta"
        },
        "city": "Atlanta",
        "state": "GA"
      }
    },
    {
      "group": "county",
      "label": "Fulton County, GA",
      "where": {
        "label": "Fulton County, GA",
        "value": "a0000000-0000-4000-8000-000000000002",
        "source": "county",
        "data": {
          "state": "GA"
        }
      }
    },
    {
      "group": "neighborhood",
      "label": "Atlanta, GA Midtown",
      "where": {
        "label": "Atlanta, GA Midtown",
        "value": "a0000000-0000-4000-8000-000000000001",
        "source": "neighborhood",
        "data": {
          "state": "GA"
        }
      }
    },
    {
      "group": "school",
      "label": "Midtown High School",
      "where": {
        "label": "Midtown High School",
        "value": "b0000000-0000-4000-8000-000000000001",
        "source": "school",
        "data": {
          "type": "high",
          "state": "GA",
          "city": "Atlanta"
        }
      }
    },
    {
      "group": "place",
      "label": "Atlanta Heights, Atlanta, GA",
      "where": {
        "label": "Atlanta Heights, Atlanta, GA",
        "value": "c0000000-0000-4000-8000-000000000005",
        "source": "library",
        "data": {
          "state": "GA",
          "kind": "neighborhood"
        }
      }
    }
  ],
  "meta": {
    "brokerageId": "bbbbbbbb-0000-4000-8000-000000000001",
    "freshness": {
      "asOf": "2026-10-22T15:00:00.000Z"
    },
    "mls": [
      {
        "mlsId": "11111111-1111-4111-8111-111111111111",
        "mlsName": "Fixture MLS",
        "displayType": "IDX",
        "disclaimer": {
          "text": "Fixture MLS data is deemed reliable but not guaranteed. CLIENTOK-disclaimer",
          "html": null
        },
        "logo": {
          "url": "https://ruuster-public.s3.amazonaws.com/mls-logo/fixture.png",
          "width": 80,
          "height": 40,
          "alt": "Fixture MLS logo"
        },
        "attributionTemplate": null,
        "required": [
          {
            "element": "listing_office",
            "placement": "card"
          },
          {
            "element": "disclaimer",
            "placement": "page"
          }
        ],
        "notices": [
          {
            "kind": "dmca",
            "text": "To report content that you believe infringes your copyright, write to the MLS's designated copyright agent.",
            "html": null
          }
        ],
        "draft": true
      },
      {
        "mlsId": "43c8a0ee-4ac7-48e3-b684-72f1770ccb58",
        "mlsName": "NWMLS",
        "displayType": "IDX",
        "disclaimer": {
          "text": "NWMLS data is deemed reliable but not guaranteed. CLIENTOK-disclaimer",
          "html": null
        },
        "logo": {
          "url": "https://ruuster-public.s3.amazonaws.com/mls-logo/fixture.png",
          "width": 80,
          "height": 40,
          "alt": "NWMLS logo"
        },
        "attributionTemplate": null,
        "required": [
          {
            "element": "listing_office",
            "placement": "card"
          },
          {
            "element": "disclaimer",
            "placement": "page"
          }
        ],
        "notices": [],
        "draft": true
      },
      {
        "mlsId": "33333333-3333-4333-8333-333333333333",
        "mlsName": "No-Map MLS",
        "displayType": "IDX",
        "disclaimer": {
          "text": "No-Map MLS data is deemed reliable but not guaranteed. CLIENTOK-disclaimer",
          "html": null
        },
        "logo": {
          "url": "https://ruuster-public.s3.amazonaws.com/mls-logo/fixture.png",
          "width": 80,
          "height": 40,
          "alt": "No-Map MLS logo"
        },
        "attributionTemplate": null,
        "required": [
          {
            "element": "listing_office",
            "placement": "card"
          },
          {
            "element": "disclaimer",
            "placement": "page"
          }
        ],
        "notices": [],
        "draft": true
      },
      {
        "mlsId": "44444444-4444-4444-8444-444444444444",
        "mlsName": "Contact MLS",
        "displayType": "IDX",
        "disclaimer": {
          "text": "Contact MLS data is deemed reliable but not guaranteed. CLIENTOK-disclaimer",
          "html": null
        },
        "logo": {
          "url": "https://ruuster-public.s3.amazonaws.com/mls-logo/fixture.png",
          "width": 80,
          "height": 40,
          "alt": "Contact MLS logo"
        },
        "attributionTemplate": "Listed by {listAgentName}, {agentPhone}, {agentEmail}, {listOfficeName}",
        "required": [
          {
            "element": "listing_agent",
            "placement": "detail"
          },
          {
            "element": "agent_contact",
            "placement": "detail"
          },
          {
            "element": "courtesy_line",
            "placement": "card"
          }
        ],
        "notices": [],
        "draft": true
      },
      {
        "mlsId": "802219ea-d7ac-46cf-b3e2-83e78ef13f68",
        "mlsName": "Maine Listings",
        "displayType": "IDX",
        "disclaimer": {
          "text": "Maine Listings data is deemed reliable but not guaranteed. CLIENTOK-disclaimer",
          "html": null
        },
        "logo": {
          "url": "https://ruuster-public.s3.amazonaws.com/mls-logo/fixture.png",
          "width": 80,
          "height": 40,
          "alt": "Maine Listings logo"
        },
        "attributionTemplate": null,
        "required": [
          {
            "element": "listing_office",
            "placement": "card"
          },
          {
            "element": "disclaimer",
            "placement": "page"
          }
        ],
        "notices": [],
        "draft": true
      }
    ],
    "canonical": null,
    "audience": "display"
  }
}
```
