# Sinyi Location Tree API Documentation

Scrappa's `GET /api/sinyi/locations` lists the cities of Taiwan with their districts and zip codes.

## What you get

Each city has `id`, `name`, `rent_search` (whether the rent search covers the city) and `districts` with `zip_code`, `name` and coordinates. Use a `zip_code` or a city `id` as `location` in the search. Pass `city_id` to read one city.

- **Documentation:** [https://scrappa.co/docs/sinyi-api/sinyi_locations](https://scrappa.co/docs/sinyi-api/sinyi_locations)
- **API group:** Sinyi API
- **Endpoint:** `GET https://scrappa.co/api/sinyi/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 |
| --- | --- | --- | --- |
| `city_id` | integer | No | Return only this city (1 to 22). |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/sinyi/locations?city_id=1"
```

## Example response

```json
{
    "success": true,
    "data": {
        "items": [
            {
                "id": 1,
                "name": "\u53f0\u5317\u5e02",
                "rent_search": true,
                "districts": [
                    {
                        "zip_code": "100",
                        "name": "\u4e2d\u6b63\u5340",
                        "latitude": 25.042141,
                        "longitude": 121.519872
                    },
                    {
                        "zip_code": "103",
                        "name": "\u5927\u540c\u5340",
                        "latitude": 25.062724,
                        "longitude": 121.511306
                    }
                ]
            }
        ]
    },
    "meta": {
        "endpoint_family": "locations",
        "billable": true
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 404 | Not Found | Sinyi has no city with that id. (`NOT_FOUND`). Non-billable. |
| 422 | Validation Error | A query parameter is missing, unknown or unusable. Unknown parameters and unknown values are rejected before any lookup, never ignored. Non-billable. |
| 503 | Upstream Unavailable | Sinyi could not be reached after one retry, answered with an error or changed its format (`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)
