# Aqar Autocomplete API Documentation

<p><strong>Aqar Autocomplete API</strong> resolves a city or district name to the ids the search route needs. Without <code>city_id</code> the query matches cities. With <code>city_id</code> it matches the districts of that city, with the number of active ads for the chosen <code>category_id</code>. Arabic spelling variants match each other, and English names work too. Each result has <code>city_id</code> and <code>district_id</code> to pass into search unchanged. A query with no match returns an empty list. Failed requests are not billed.</p>

- **Documentation:** [https://scrappa.co/docs/aqar-api/aqar_autocomplete](https://scrappa.co/docs/aqar-api/aqar_autocomplete)
- **API group:** Aqar API
- **Endpoint:** `GET https://scrappa.co/api/aqar/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 | Search text in Arabic or English, 2 to 100 characters. Example: الر. |
| `city_id` | integer | No | City id from a city result. With it the query matches the districts of that city. |
| `category_id` | integer | No | Category for the district listing counts (default 6, apartments for sale). Only used with city_id. |
| `limit` | integer | No | Number of results, 1 to 25 (default 10). |

## Example response

```json
{
    "data": {
        "query": "\u0627\u0644\u0631",
        "results": [
            {
                "id": 21,
                "name": "\u0627\u0644\u0631\u064a\u0627\u0636",
                "path": "https://sa.aqar.fm/%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6",
                "type": "city",
                "city_id": 21,
                "name_en": "Riyadh",
                "district_id": null,
                "listing_count": null
            }
        ]
    },
    "meta": {
        "billable": true,
        "endpoint_family": "autocomplete"
    },
    "success": true
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A required parameter or a range is invalid. This response is not billable. |
| 503 | Upstream Unavailable | Aqar could not be reached or returned data that does not match the request. This response is not billable and is retryable. |

## 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)
