Package Exports
- @rmderojr/ibge-data-cli
- @rmderojr/ibge-data-cli/src/app.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rmderojr/ibge-data-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
IBGE Data CLI
ibge-data-cli is a command-line interface (CLI) tool to fetch, store, and query Brazilian location data (states and cities) from the official IBGE API.
This tool is perfect for developers, data analysts, and students who need quick and offline access to this public data.
Features
- One-Command Sync: Fetch all states and cities from the IBGE API and store them in a local SQLite database.
- Offline Queries: List all cities for a specific state directly from your terminal, without needing an internet connection after the initial sync.
- Data Export: Export the entire dataset of states and cities to a single CSV file for use in other applications or analysis.
- Local Cache: API requests are cached to avoid unnecessary calls and respect rate limits.
Installation
You can install the CLI globally via npm to use it anywhere on your system.
npm install -g ibge-data-cliUsage
1. Import Data
First, you need to sync the data from the IBGE API to your local database. This command creates the database and populates it.
ibge-data-cli import-data2. List Cities by State
Once the data is imported, you can list all cities for a given state using its two-letter abbreviation (UF).
ibge-data-cli list-cities <UF>Example:
ibge-data-cli list-cities SP3. Export to CSV
Export all states and their corresponding cities to a CSV file.
ibge-data-cli export-csv <filename.csv>Example:
ibge-data-cli export-csv brazil-locations.csvDevelopment
If you want to contribute to the project, follow these steps:
- Clone the repository:
git clone https://github.com/mrx6SO/ibge-data-cli.git - Install dependencies:
npm install - Run migrations:
npm run knex:migrate - Run commands locally:
node src/app.js <command>