> For the complete documentation index, see [llms.txt](https://help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.firstline.cc/developer/api/country-city.md).

# 國家、縣市及區域

## 國家

```javascript
GET https://{API_DOMAIN}/api/v1/state
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    "https://{API_HOST}/api/v1/country?per_page=3"
```

### Parameters

| PARAMETER     | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ------------- | -------- | ------- | ------ | ----------- |
| **page**      | false    | 1       | Number | 目前在第幾頁      |
| **per\_page** | false    | 15      | Number | 每頁呈現多少筆     |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                               |
| -------- | ---------------- | --------------------------------------------------------- |
| **data** | Array of objects | [國家陣列](/developer/api/response-object.md#guo-jia-country) |
| **meta** | Object           | Pagination meta                                           |

```javascript
{
    "data": [
        {
            "id": 1,
            "name": "台灣",
            "abbrev": null
        }
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "per_page": "3",
        "to": 1,
        "total": 1
    }
}
```

## 縣市

```javascript
GET https://{API_DOMAIN}/api/v1/state‌
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    "https://{API_HOST}/api/v1/state?per_page=3"
```

### Parameters

| PARAMETER     | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ------------- | -------- | ------- | ------ | ----------- |
| **page**      | false    | 1       | Number | 目前在第幾頁      |
| **per\_page** | false    | 15      | Number | 每頁呈現多少筆     |
| **name**      | false    | NULL    | String | 縣市名稱        |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                               |
| -------- | ---------------- | --------------------------------------------------------- |
| **data** | Array of objects | [縣市陣列](/developer/api/response-object.md#guo-jia-country) |
| **meta** | Object           | Pagination meta                                           |

```javascript
{
    "data": [
        {
            "id": 2,
            "country_id": 1,
            "name": "基隆市",
            "country": {
                "id": 1,
                "name": "台灣",
                "abbrev": null
            }
        },
        {
            "id": 3,
            "country_id": 1,
            "name": "台北市",
            "country": {
                "id": 1,
                "name": "台灣",
                "abbrev": null
            }
        },
        {
            "id": 4,
            "country_id": 1,
            "name": "新北市",
            "country": {
                "id": 1,
                "name": "台灣",
                "abbrev": null
            }
        }
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 8,
        "per_page": "3",
        "to": 3,
        "total": 23
    }
}
```

## 區域

```javascript
GET https://{API_DOMAIN}/api/v1/city
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    "https://{API_HOST}/api/v1/city?per_page=3"
```

### Parameters

| PARAMETER     | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                 |
| ------------- | -------- | ------- | ------ | ----------------------------------------------------------- |
| **page**      | false    | 1       | Number | 目前在第幾頁                                                      |
| **per\_page** | false    | 15      | Number | 每頁呈現多少筆                                                     |
| **state\_id** | false    | NULL    | Number | [縣市](/developer/api/response-object.md#cheng-shi-state)的 id |
| **zipcode**   | false    | NULL    | Number | 郵遞區號                                                        |
| **name**      | false    | NULL    | String | 郵遞區名                                                        |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                       |
| -------- | ---------------- | ------------------------------------------------- |
| **data** | Array of objects | [區域陣列](/developer/api/response-object.md#ou-city) |
| **meta** | Object           | Pagination meta                                   |

```javascript
{
    "data": [
        {
            "id": 1,
            "state_id": 2,
            "state": {
                "id": 2,
                "country_id": 1,
                "name": "基隆市"
            },
            "name": "仁愛區",
            "zipcode": "200"
        },
        {
            "id": 2,
            "state_id": 2,
            "state": {
                "id": 2,
                "country_id": 1,
                "name": "基隆市"
            },
            "name": "信義區",
            "zipcode": "201"
        },
        {
            "id": 3,
            "state_id": 2,
            "state": {
                "id": 2,
                "country_id": 1,
                "name": "基隆市"
            },
            "name": "中正區",
            "zipcode": "202"
        }
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 124,
        "per_page": "3",
        "to": 3,
        "total": 371
    }
}
```
