# tw-address

> TW road list by gov open data

Latest version **1.0.7** (published 2022-12-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install tw-address
pnpm add tw-address
yarn add tw-address
bun add tw-address
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-12-25 |
| First published | 2021-07-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.22.7 |
| Dependencies | 0 |
| Unpacked size | 44.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hqiasjehrlb@gmail.com |
| Maintainers | hqiasjehrlb |

## Links

- npm: https://www.npmjs.com/package/tw-address
- Repository: https://gitlab.com/hqiasjehrlb/tw-address
- Homepage: https://gitlab.com/hqiasjehrlb/tw-address.git
- Issues: https://gitlab.com/hqiasjehrlb/tw-address/issues
- npm.io page: https://npm.io/package/tw-address

## Recent versions

- 1.0.7 (latest) — 2022-12-25
- 1.0.6 — 2022-12-25
- 1.0.5 — 2021-09-30
- 1.0.4 — 2021-07-25
- 1.0.3 — 2021-07-25
- 1.0.2 — 2021-07-22
- 1.0.1 — 2021-07-22
- 1.0.0 — 2021-07-22

## README

# tw-address
Get TW road list by open data API.

# Install
```
npm i tw-address
```
# Usage
```javascript
const TWAddress = require('tw-address');

/**
 * Create new instance.
 * First argument is ROC year. Available values are 107, 108, 109, 110, optional, default value: CURRENT_ROC_YEAR
 * Second argument is API base url, optional, default: https://www.ris.gov.tw/rs-opendata/api/v1/datastore/ODRP049
 */
const twAddress = new TWAddress(110);

/**
 * To get road list.
 * First argument is county, required.
 * Second argument is town, required.
 * @type {Promise}
 */
twAddress.getRoadList('臺北市', '中正區')
  .then(roads => {
    /**
     * Return data type is {string[]}
     */
    roads.forEach((road) => {
      console.log(road);
    });
  });

/**
 * To get roads data.
 * First argument is county, optional.
 * Second argument is town, optional.
 * Third argument is page, optional, default: 1.
 * @type {Promise}
 */
twAddress.getAPI('臺北市', '中正區', 1)
  .then(resp => {
    /**
     * Response schema:
     * https://github.com/hqiasjehrlb/tw-address/blob/aaba0978da90f43e3af1855050546325fef2a448/lib/roadsAPI.js#L76
     */
    console.log(resp);
  });

/**
 * To get county list.
 * @type {string[]}
 */
const counties = TWAddress.getCountyList();

/**
 * To get town list.
 * Argument <county> is required.
 * @type {string[]}
 */
const towns = TWAddress.getTownList(county);
```

# References
[Taiwan District Data](https://gist.githubusercontent.com/abc873693/2804e64324eaaf26515281710e1792df/raw/a1e1fc17d04b47c564bbd9dba0d59a6a325ec7c1/taiwan_districts.json)

[Taiwan Roads Opendata Documentation](https://www.ris.gov.tw/rs-opendata/api/Main/docs/v1)

[Taiwan Roads Opendata Information](https://data.gov.tw/dataset/35321)

---
_Source: https://npm.io/package/tw-address · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
