Skip to content

Scrapes ISO's website to get the latest ISO 3166-1 country codes

License

Notifications You must be signed in to change notification settings

takuma7/get-country-codes

Repository files navigation

get-country-codes

Fetches the canonical ISO 3166-1 country codes from ISO's website and writes to a CSV file.

If your only interest is to get the CSV file, you can check takuma7/iso-3166-1-csv out.

CLI

Installation:

pnpm add --global get-country-codes

Usage:

get-country-codes -o ./out/iso-3166-1.csv # You can specify the output path (default: ./iso-3166-1.csv)

API

getTable

Gets the country codes table from the ISO website.

getTable(): Promise<{ headers: string[]; rows: string[][] }>

Usage:

const { headers, rows } = await getTable()