# Goplaceit Locations API Documentation

Scrappa's `GET /api/goplaceit/locations` lists places that the search accepts. With only `country` it returns the regions. With `region` it returns the communes, or the provinces with `children=provinces`. With `province` it returns communes. With `commune` it returns neighborhoods.

## What you get

Each place has `id`, `name`, `level`, `latitude` and `longitude` (when Goplaceit has them). Use `region`, `commune` or `neighborhood` ids as search filters. Province ids are listed for navigation only, because search does not filter by province.

## Caching

Lists are cached for 24 hours. A cached answer costs no source lookup (`meta.cached` is `true`). Mexican regions can hold thousands of communes.

- **Documentation:** [https://scrappa.co/docs/goplaceit-api/goplaceit_locations](https://scrappa.co/docs/goplaceit-api/goplaceit_locations)
- **API group:** Goplaceit API
- **Endpoint:** `GET https://scrappa.co/api/goplaceit/locations`

## 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 |
| --- | --- | --- | --- |
| `country` | string | No | cl, mx or co. Required unless a parent is given. |
| `region` | integer | No | Region id: lists its communes, or provinces with children=provinces. |
| `province` | integer | No | Province id: lists its communes. |
| `commune` | integer | No | Commune id: lists its neighborhoods. |
| `children` | string | No | communes (default) or provinces. Only with region. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/goplaceit/locations?country=cl"
```

## Example response

```json
{
    "success": true,
    "level": "region",
    "parent": null,
    "total_results": 15,
    "locations": [
        {
            "id": 13,
            "name": "Region Metropolitana",
            "level": "region",
            "latitude": -33.4372,
            "longitude": -70.6506
        }
    ],
    "meta": {
        "endpoint_family": "locations",
        "billable": true,
        "cached": false,
        "attempts": 1
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 404 | Not Found | The parent id does not exist (`not_found`). Non-billable. |
| 422 | Validation Error | A query parameter is missing, unknown or unusable. Unknown parameters and unknown sort or type values are rejected, never ignored. Non-billable. |
| 503 | Source Unavailable | Goplaceit could not be reached in time, refused the request, or its answer changed shape (`upstream_unavailable`, `request_blocked`, `deadline_exhausted`, `parser_drift`). 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)
