soff-geo

v0.2.7~2KB Core

Lightweight geographic data library for LATAM - Departments, municipalities, postal codes and more.

Live Demo - Municipality Search
Type to search...

Installation

npm install soff-geo

Quick Start

// Import only what you need
import { getDepartments, getMunicipalities, searchMunicipalities } from 'soff-geo/co';

// Get all departments
const departments = getDepartments();
// [{ code: '05', name: 'Antioquia', ... }, ...]

// Get municipalities for a department
const antioquiaMunis = getDepartmentMunicipalities('05');
// [{ code: '05001', name: 'Medellín', ... }, ...]

// Search
const results = searchMunicipalities('medellin');
// [{ item: { name: 'Medellín', ... }, score: 1 }]

Available Locales

🇨🇴Colombia
soff-geo/co
DepartmentsMunicipalitiessearchvalidate codes
🇲🇽México
soff-geo/mx
StatesMunicipalitiessearchvalidate codes

API Reference

Colombia

import { 
  getDepartments, 
  getMunicipalities, 
  getDepartment, 
  getMunicipality, 
  getDepartmentMunicipalities, 
  searchDepartments, 
  searchMunicipalities, 
  validateDepartmentCode, 
  validateMunicipalityCode 
} from 'soff-geo/co';

// Get all departments
const depts = getDepartments();

// Get specific department
const antioquia = getDepartment('05');

// Get municipalities of a department
const munis = getDepartmentMunicipalities('05');

// Search
const results = searchMunicipalities('medellin', { limit: 5 });