A command-line interface for interacting with GIS.PH API.
- π Simple and intuitive commands
- π Secure credential management
- π Multiple output formats (table, JSON)
- β‘ Fast and efficient API interactions
- π¨ Colorful and user-friendly output
- πΎ Persistent configuration storage
Install with a single command:
curl -fsSL https://gis.ph/install.sh | bashThen configure:
gis.ph config set apiUrl https://your-api.com
gis.ph config set apiKey your-api-key-here- Node.js >= 14.0.0
- npm or yarn
-
Clone or navigate to the project directory:
cd my-api-cli -
Install dependencies:
npm install
-
Link the CLI globally (optional):
npm link
After linking, you can use
gis.phcommand from anywhere. -
Configure your API:
# Set your API URL gis.ph config set apiUrl https://api.gis.ph # Set your API key (if required) gis.ph config set apiKey your-api-key-here
Alternatively, create a
.envfile:cp .env.example .env # Edit .env with your values
# Using the uninstall script
curl -fsSL https://yourusername.github.io/my-api-cli/uninstall.sh | bash
# Or manually
rm -rf ~/.gis.ph
rm ~/.local/bin/gis.ph# Set configuration
gis.ph config set <key> <value>
# Get configuration value
gis.ph config get <key>
# List all configuration
gis.ph config list
# Delete configuration
gis.ph config delete <key>
# Enable/disable automatic update checks
gis.ph config auto-update enable
gis.ph config auto-update disable# Update to latest version
gis.ph update
# Check for updates without installing
gis.ph update --check
# Force update even if on latest version
gis.ph update --forceThe CLI automatically checks for updates once per day and notifies you if a new version is available. You can disable this with gis.ph config auto-update disable.
# List all regions (table format)
gis.ph regions list
# List with pagination
gis.ph regions list --limit 5 --page 2
# List regions in JSON format
gis.ph regions list --format json
# Filter regions (e.g., status:active)
gis.ph regions list --filter status:active
# Get region by PSGC code
gis.ph regions get 0700000000# List all provinces
gis.ph provinces list
# List with pagination
gis.ph provinces list --limit 10 --page 1
# Get province by PSGC code
gis.ph provinces get 0702200000
# Get province with GeoJSON boundaries
gis.ph provinces get 0702200000 --geometry# List all cities/municipalities in a province (REQUIRED)
gis.ph municities list --province "Bohol"
# Filter by name (starts with)
gis.ph municities list --province "Bohol" --name "Al"
# Get municipality by PSGC code
gis.ph municities get 0730600000
# Get municipality with barangay boundaries (GeoJSON)
gis.ph municities get 0730600000 --geometry# List barangays in a province (REQUIRED)
gis.ph barangays list --province "Cebu"
# Filter by municipality and/or barangay name
gis.ph barangays list --province "Cebu" --municipality "Poro" --name "Pob"
# Get barangay by PSGC code
gis.ph barangays get 0730600041# Configure the CLI
gis.ph config set apiUrl https://api.gis.ph
gis.ph config set apiKey sk_live_abc123
# List all regions
gis.ph regions list
# Get all provinces in Region 7
gis.ph provinces list --limit 100 --page 1
# Find a town in Bohol
gis.ph municities list --province "Bohol" --name "Al"
# Get a specific barangay info
gis.ph barangays get 12345
# List regions as JSON for scripting
gis.ph regions list --format json | jq '.regions[0]'
# View help
gis.ph --help
gis.ph regions --help
gis.ph regions list --helpWithout installing globally:
npm start -- regions list
# or
node src/index.js regions listgis.ph-cli/
βββ src/
β βββ index.ts # Main CLI entry point
β βββ commands/ # Command implementations
β β βββ regions.ts # Regions commands
β β βββ provinces.ts # Provinces commands
β β βββ municities.ts # Cities/Municipalities commands
β β βββ barangays.ts # Barangays commands
β β βββ update.ts # Self-update logic
β β βββ config.ts # Config commands
β βββ lib/ # Core libraries
β β βββ api-client.ts # API HTTP client
β βββ utils/ # Utility functions
β βββ config.ts # Configuration management
β βββ formatter.ts # Output formatting
β βββ auto-update.ts # Background update checker
βββ package.json
βββ tsconfig.json
βββ .env.example
βββ README.md
-
Create a new command file in
src/commands/:import { Command } from 'commander'; const myCommand = new Command('mycommand'); myCommand .description('My command description') .action(async () => { // Your logic here }); export default myCommand;
-
Register it in
src/index.ts:import myCommand from './commands/mycommand.js'; program.addCommand(myCommand);
-
Add corresponding API methods in
src/lib/api-client.js:async getMyData() { return this.get('/v1/mydata'); }
Configuration is stored in your system's config directory:
- Linux:
~/.config/my-api-cli/config.json - macOS:
~/Library/Preferences/my-api-cli/config.json - Windows:
%APPDATA%\my-api-cli\config.json
The CLI supports the following environment variables:
API_URL- Base URL for the APIAPI_KEY- API authentication key
These can be set in a .env file or exported in your shell.
The CLI provides helpful error messages:
- Network errors (API unreachable)
- Authentication errors (invalid API key)
- Validation errors (invalid parameters)
- API errors (with status codes and messages)
If gis.ph command is not found after npm link:
# Unlink and relink
npm unlink -g
npm linkCheck your configuration:
gis.ph config listVerify your API URL is correct and accessible.
For more verbose output, use Node's debug mode:
NODE_DEBUG=* gis.ph regions listMIT
Contributions are welcome! Please feel free to submit a Pull Request.