# Quickstart: your first search in three calls

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

> Your first search in three calls, turning a place name into a location, searching it, and showing the results with the two things every page needs.

This quickstart takes about ten minutes. You need a secret key. A free sandbox key works: press
**Get API keys** at the top of these docs, sign in with your email and copy the secret key the page
shows once. Sandbox keys answer from sample listings in Atlanta and Dallas, which is what the calls
below search. Every call below runs from a terminal or a
server with the secret key (`idx_sk_…`) sent as `Authorization: Bearer`. Your web pages carry no key:
they call your own listings route, which adds the secret key on your server, or (on a site builder
with no server) the Listings API with no key at all. [Keys, domains and environment
names](https://help.ruuster.com/idx/keys-and-domains) explains both ways.

Before you start, put your secret key in your shell. On macOS or Linux run
`export IDX_SECRET_KEY=idx_sk_your_key`. In Windows PowerShell run
`$env:IDX_SECRET_KEY = "idx_sk_your_key"`. Never paste the secret key into a web page, a chat or a
prompt.

Your pages show listings without anything else. To show the **map** as well, get your free Google
Maps key and Map ID first: [Get your Google Maps key](https://help.ruuster.com/idx/google-maps-key)
walks you through it in about 15 minutes, step by step, with no coding.

## 1. Turn a place name into a location

Ask `/v1/suggest` for what a visitor typed. Each row it returns carries a `where` object: a ready-made
location. You pass it back to search exactly as you got it and never build one by hand.

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']);
```

Rows come in groups (city, ZIP code, neighborhood, county, school, subdivision, place and others).
Show the row's `label` in your search box and keep its `where` for the next call.

## 2. Search it

Send the `where` object as JSON in the `where` parameter, with any filters. This search asks for
active homes in Atlanta with at least three bedrooms under $900,000, highest price first, twelve to a
page.

cURL:

```bash
curl -s -G "https://idx.ruuster.com/v1/listings" \
  --data-urlencode 'where={"label":"Atlanta, GA","value":"Atlanta","source":"crm-system","city":"Atlanta","state":"GA"}' \
  --data-urlencode status=active \
  --data-urlencode bedsMin=3 \
  --data-urlencode priceMax=900000 \
  --data-urlencode sort=price_desc \
  --data-urlencode limit=12 \
  -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.search({
  where: {
    label: "Atlanta, GA",
    value: "Atlanta",
    source: "crm-system",
    city: "Atlanta",
    state: "GA",
  },
  status: "active",
  bedsMin: 3,
  priceMax: 900000,
  sort: "price_desc",
  limit: 12,
});
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/listings",
    params={
        "where": "{\"label\":\"Atlanta, GA\",\"value\":\"Atlanta\",\"source\":\"crm-system\",\"city\":\"Atlanta\",\"state\":\"GA\"}",
        "status": "active",
        "bedsMin": "3",
        "priceMax": "900000",
        "sort": "price_desc",
        "limit": "12",
    },
    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([
    'where' => '{"label":"Atlanta, GA","value":"Atlanta","source":"crm-system","city":"Atlanta","state":"GA"}',
    'status' => 'active',
    'bedsMin' => '3',
    'priceMax' => '900000',
    'sort' => 'price_desc',
    'limit' => '12',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/listings' . '?' . $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']);
```

The answer has `data.listings` (the cards), `data.total`, `data.page` and `data.pages`, the map box
in `data.viewport`, and the page's head tags and JSON-LD in `data.head` and `data.jsonLd`. Every
answer also carries `meta.mls`: one compliance block for each board in the results.

You can also search a ZIP code, a city or a state directly, without suggest:
`/v1/listings?zip=30308`, `/v1/listings?city=Atlanta&state=GA`. [Locations](https://help.ruuster.com/idx/guide-locations)
covers every kind of location.

## 3. Show it, with the two things every page needs

Render the cards however you like. Two things are required on every page that shows listings:

1. **Each card shows its attribution.** Print `listing.attribution.line` on the card when it is not
   null. It is the exact text the board requires, such as the listing office's name.
2. **The page shows the disclaimer of every board in the results.** For each block in `meta.mls`,
   print its `disclaimer` and, when it has one, its `logo`, with the date the data was last updated.

The [recipe components](https://help.ruuster.com/idx/recipe-components) do both for you:
`ListingGrid` prints each card's attribution and `MlsDisclaimers` prints every board's disclaimer.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-card-1440.png" alt="Listing card with photos and the attribution its board requires on cards, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>A listing card. The attribution line sits under the address.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-card-375.png" alt="Listing card with photos and the attribution its board requires on cards, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>A listing card. The attribution line sits under the address.</figcaption></figure>

The markup is `static/html/listing-card.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

## What else is in every answer

- **Caching.** Answers to calls from your pages are cached at the edge for a short time, so repeat
  calls are fast and cost nothing. [Caching](https://help.ruuster.com/idx/caching) has the time for
  each endpoint.
- **Rate limits.** Every answer carries `x-ratelimit-limit`, `x-ratelimit-remaining`,
  `x-ratelimit-reset` and `x-ratelimit-window`. Over a limit you get 429 with `Retry-After`.
  [Limits, units and plans](https://help.ruuster.com/idx/limits) has the numbers.
- **Errors** have one shape: `{ "ok": false, "error": { "code", "message", "retryable" }, "requestId" }`.
  [Errors and what to show](https://help.ruuster.com/idx/errors) says what to do with each.

## Next

- [Quickstart: a server-rendered Next.js page](https://help.ruuster.com/idx/quickstart-nextjs) builds
  a real page from these calls.
- [Recipes](https://help.ruuster.com/idx/recipes) have a complete page for every page type.
- [Search listings](https://help.ruuster.com/idx/listings-search) lists every parameter, with a Try it
  console that runs against your own account.
