# MagicBricks Location Autocomplete API Documentation

Resolve free text into localities and projects. Each item returns the name, the type (locality or project), the locality id or project id as an integer, the city name and id, and for projects a cover image. These ids are what every other endpoint takes, so they are always returned as integers and never in the packed form. An empty suggestion list for a valid query is a successful response.

- **Documentation:** [https://scrappa.co/docs/magicbricks-api/magicbricks_autocomplete](https://scrappa.co/docs/magicbricks-api/magicbricks_autocomplete)
- **API group:** MagicBricks API
- **Endpoint:** `GET https://scrappa.co/api/magicbricks/v1/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 | Free text, 2 to 80 characters. Example: andheri. |
| `city` | string | No | City ref-no or name to scope the suggestions, for example Mumbai. Without it the suggest is nationwide. |
| `type` | string | No | all, locality or project. Defaults to all. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/magicbricks/v1/autocomplete?query=andheri&city=Mumbai"
```

## Example response

```json
{
    "success": true,
    "data": {
        "query": "andheri",
        "type": "all",
        "items": [
            {
                "name": "Andheri East, Mumbai",
                "type": "locality",
                "locality_id": 184906,
                "city": "Mumbai",
                "city_id": 4320
            },
            {
                "name": "Lodha Elliora, Sarjapur Road, Bangalore",
                "type": "project",
                "project_id": 5429269,
                "locality": "Sarjapur Road",
                "city": "Bangalore",
                "city_id": 3327,
                "image": "https://img.staticmb.com/mbimages/project/Photo_h300_w450/2025/08/01/Project-Photo-1-Lodha-Elliora-Bangalore-5429269_400_900_300_450.jpg"
            }
        ]
    },
    "meta": {
        "endpoint_family": "autocomplete",
        "billable": true
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A public parameter is missing or invalid, or a city, locality or property type cannot be resolved. No upstream call is made and the response is not billable. |
| 404 | Resource Not Found | The requested MagicBricks resource does not exist. The response is not billable. |
| 503 | Unexpected Upstream Response | MagicBricks answered with a body that is not the documented shape. The response is not billable. |
| 503 | Upstream Unavailable | The upstream service is temporarily unavailable. Please retry shortly. |

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