barangay — Philippine PSGC Python Package
Offline Python package for the Philippine Standard Geographic Code (PSGC): 42,010 barangays, municipalities, cities, provinces, and regions with fuzzy search and address validation. No API calls needed.
Python package for accessing Philippine Standard Geographic Code (PSGC) data covering all 42,010 barangays, 1,493 municipalities, 150 cities, 82 provinces, and 18 regions — offline, no API calls needed.
Get started in seconds
pip install barangayfrom barangay import barangays, search_fuzzy
1brgy = barangays.get(name="Tongmageng")
print(brgy.region, brgy.province, brgy.psgc_id)
# Bangsamoro Autonomous Region In Muslim Mindanao (BARMM) Tawi-Tawi 1907005010
2for r in search_fuzzy("Tongmagen, Tawi-Tawi"):
print(f"{r.name} ({r.psgc_id}) — score: {r.score}")- 1
-
.get(name=...)returns a typedEnrichedRecordwith resolved hierarchy fields (.region,.province,.municipality, …). - 2
-
search_fuzzy()returns typedSearchResultobjects ranked by a fuzzy score — tolerant of misspellings and non-standard formats.
New here? Walk through the First Lookup tour (Python + CLI) in five minutes.
Choose your path
Features
- Bundled PSGC Dataset: Native access to PSGC data, no database or API calls needed
- Hierarchy Traversal: Navigate parent, children, and ancestors of any admin division
- Direct Pandas Export:
to_frame()andto_dicts()for immediate DataFrame access - Address Validation:
validate()andvalidate_many()for automated address checking - Fuzzy Search: Fast, customizable fuzzy matching with typed
SearchResultobjects - Historical PSGC Data: On-demand access to previous PSGC releases by date
- Multiple Data Models: Basic (nested), Extended (recursive), and Flat (list)
- Plug-in System: Enrich PSGC data with custom extensions via plug-ins (CSV, JSON, Parquet)
Quick links
- Get Started
- Learn — tutorials
- How-To — task recipes
- Reference — Python API, CLI, data dictionary
- Concepts — foundations and explanation
- Plugins
- FAQ · Troubleshooting · Changelog · Blog
Data Version
Current data version: 2026-04-13 (April 13 2026 PSGC masterlist)
WarningDeprecation Notice
BARANGAY/BARANGAY_EXTENDED/BARANGAY_FLAT dict aliases and search() are deprecated and will be removed in 2027.X.X.X. Use the Database API for new code (e.g. barangays.get(name="Tongmageng"), search_fuzzy("query")). See Migrate from the legacy API.