# Mubawab Autocomplete API Documentation

<p><strong>Mubawab Autocomplete API</strong> finds city slugs by name. Pass the <code>slug</code> to the <code>location</code> filter of the search route. Names that start with your text come first. The answer comes from a list of cities that was checked against the site, so it costs no upstream request and does not list every district. A query with no match returns an empty list. Failed requests are not billed.</p>

- **Documentation:** [https://scrappa.co/docs/mubawab-api/mubawab_autocomplete](https://scrappa.co/docs/mubawab-api/mubawab_autocomplete)
- **API group:** Mubawab API
- **Endpoint:** `GET https://scrappa.co/api/mubawab/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, 2 to 60 characters. Example: rab. |
| `country` | string | No | ma or tn. Default: both. |
| `limit` | integer | No | Maximum results, 1 to 25 (default 10). |

## Example response

```json
{
    "data": {
        "items": [
            {
                "kind": "city",
                "name": "Rabat",
                "slug": "rabat",
                "country": "ma"
            }
        ],
        "query": "rab"
    },
    "meta": {
        "country": null,
        "billable": true,
        "endpoint_family": "autocomplete"
    },
    "success": true
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A parameter is missing or invalid. This response is not billable. |
| 503 | Upstream Unavailable | Mubawab 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)
