# ViewIt Autocomplete API Documentation

Scrappa's `GET /api/viewit/autocomplete` finds the ViewIt cities and rental companies that match a term.

## What you get

`cities` with `city_id`, `name` and `province`, and `companies` with `company_id` and `name`. A term that matches nothing gives two empty lists.

## How to use it

Pass a `city_id` to `GET /api/viewit/search`, for example `14` for Toronto. Pass a `company_id` as `id` to `GET /api/viewit/agency`, for example `2045` for Realstar.

- **Documentation:** [https://scrappa.co/docs/viewit-api/viewit_autocomplete](https://scrappa.co/docs/viewit-api/viewit_autocomplete)
- **API group:** ViewIt API
- **Endpoint:** `GET https://scrappa.co/api/viewit/autocomplete`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | Part of a city or company name, at least 2 characters, for example toronto or realstar. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/viewit/autocomplete?query=toronto"
```

## Example response

```json
{
    "success": true,
    "data": {
        "query": "toronto",
        "cities": [
            {
                "city_id": 14,
                "name": "Toronto",
                "province": "ON"
            },
            {
                "city_id": 399,
                "name": "Toronto - GTA",
                "province": "ON"
            }
        ],
        "companies": []
    },
    "meta": {
        "endpoint_family": "autocomplete",
        "billable": true,
        "attempts": 1
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A query parameter is missing, unknown or unusable. Unknown parameters and unknown values are rejected, never ignored. Non-billable. |
| 503 | Upstream Unavailable | ViewIt could not be reached, refused the request or answered with a page this API could not read (`UPSTREAM_UNAVAILABLE`). Retryable and never billed. Clients are never rate limited. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
