Plugin Quickstart

Get the psgc-aux-data plugin running in two minutes — from the CLI and from Python with PluginLoader.
Author

bendlikeabamboo

Enable the psgc-aux-data plugin (supplementary PSGC metadata: correspondence codes, old names, city class, income classification, urban/rural, population, and status) in under two minutes — from both the CLI and Python.

Enable the plugin

barangay search "City of Lapu-Lapu" --plugin psgc-aux-data --format json --limit 1
from barangay import Database

db = Database()
db.use_plugins(["psgc-aux-data"])

use_plugins(["psgc-aux-data"]) activates the plugin on the Database singleton; every record the level views return from then on carries the enriched fields. For the lower-level loader API, see Plugin Python API.

Verify the enrichment

After enabling, the supplementary fields appear on each record. For Barangay 291, City of Manila (1380602005), the enriched values are:

#| eval: false
from barangay import Database

db = Database()
db.use_plugins(["psgc-aux-data"])

row = db.barangays.to_frame().loc[lambda d: d["psgc_id"] == "1380602005"].iloc[0]
print(row.filter(like="psgc_aux_data"))
# psgc_aux_data.correspondence_code      0133902005
# psgc_aux_data.old_names                       None
# psgc_aux_data.city_class                      None
# psgc_aux_data.income_classification           None
# psgc_aux_data.urban_rural                         U
# psgc_aux_data.population                       2537
# psgc_aux_data.status                          None
NoteSeven keys, that’s all

psgc-aux-data exposes exactly seven keys: correspondence_code, old_names, city_class, income_classification, urban_rural, population, and status. In flattened form (via to_dicts()) they become psgc_aux_data.<key> columns; on a record object they live in the record’s extensions. See the data dictionary for the full per-field reference.

The same enrichment shows up everywhere — search_fuzzy results, validate matches, and direct .get()/.lookup() calls all return enriched records once the plugin is active.

Next examples

  • Configure plugins — enable/disable via env vars or the loader config in Plugin configuration.
  • Use enriched data from Python — read fields off SearchResult / EnrichedRecord and via to_dicts() in Plugin Python API.
  • Write your own plugin — ship a manifest, point it at your data, and join by psgc_id in Creating a plugin.

See also