Zip Code and Address Converter
This command-line tool allows you to convert zip codes to addresses and vice versa using the OneMap API.
Prerequisites
Installation
- Clone this repository or download the code.
- Navigate to the project directory in your terminal.
- Install the required dependencies:
npm install axios dotenv commander fs
4.Install TypeScript and ts-node globally:
npm install -g typescript ts-node
5.Create a .env file in the project directory and add your OneMap API key:
ONEMAP_API_KEY=your_api_key_here
Usage
To convert a zip code to an address, run the following command:
ts-node index.ts --zipcode <zipcode>
To convert an address to a zip code, run the following command:
ts-node index.ts --address "<address>"
To save the addresses for a zip code to a file, add the --file flag:
ts-node index.ts --zipcode <zipcode> --file
Example
ts-node index.ts --zipcode 123456
ts-node index.ts --address "10 Downing St, Westminster, London"