npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

geo-peru

v1.1.0

Published

Peru ubigeo data from RENIEC — departments, provinces, and districts

Downloads

78

Readme

geo-peru

Peru's ubigeo data from RENIEC. Includes departments, provinces, and districts with coordinates and area.

Installation

npm install geo-peru
# or
yarn add geo-peru

Usage

import {
  getDepartments,
  getProvinces,
  getDistricts,
  getByUbigeo,
} from "geo-peru";

// List all 25 departments
const departments = getDepartments();
// [{ code: "01", name: "Amazonas" }, ...]

// Provinces of a department (Lima = "14")
const provinces = getProvinces("14");
// [{ code: "1401", name: "Lima", departmentCode: "14" }, ...]

// All districts in the country
const districts = getDistricts();

// Districts of a province (Lima = "1401")
const limaDistricts = getDistricts("1401");

// Look up by ubigeo
const district = getByUbigeo("140101");
// {
//   ubigeo: "140101",
//   name: "Lima",
//   provinceCode: "1401",
//   departmentCode: "14",
//   area: 21.98,
//   lat: -12.0467,
//   lon: -77.0322
// }

API

getDepartments()

Returns all 25 departments.

interface Department {
  code: string; // "01"–"25"
  name: string;
}

getProvinces(departmentCode?)

Returns all provinces, or those of a given department if departmentCode is provided.

interface Province {
  code: string;           // 4 digits: "0101"
  name: string;
  departmentCode: string; // 2 digits: "01"
}

getDistricts(provinceCode?)

Returns all districts, or those of a given province if provinceCode is provided.

interface District {
  ubigeo: string;         // 6 digits: "010101"
  name: string;
  provinceCode: string;   // 4 digits: "0101"
  departmentCode: string; // 2 digits: "01"
  area: number;           // km²
  lat: number;            // centroid latitude
  lon: number;            // centroid longitude
}

getByUbigeo(ubigeo)

Returns the district with the given ubigeo, or undefined if not found.

getLocation(ubigeo)

Returns the department, province, and district names for a given 6-digit ubigeo, or undefined if not found.

interface Location {
  department: string;
  province: string;
  district: string;
}

getLocation("150101");
// { department: "Loreto", province: "Maynas", district: "Iquitos" }

Department codes

| Code | Department | Code | Department | |------|---------------|------|---------------| | 01 | Amazonas | 14 | Lima | | 02 | Ancash | 15 | Loreto | | 03 | Apurimac | 16 | Madre de Dios | | 04 | Arequipa | 17 | Moquegua | | 05 | Ayacucho | 18 | Pasco | | 06 | Cajamarca | 19 | Piura | | 07 | Cusco | 20 | Puno | | 08 | Huancavelica | 21 | San Martin | | 09 | Huanuco | 22 | Tacna | | 10 | Ica | 23 | Tumbes | | 11 | Junin | 24 | Callao | | 12 | La Libertad | 25 | Ucayali | | 13 | Lambayeque | | |

Data

  • Source: RENIEC / GEODIR
  • Last updated: January 15, 2019
  • Coverage: 25 departments · 195 provinces · 1,838 districts
  • Ubigeo: 6-digit code (DD PP ZZ — department, province, district)

License

MIT