This package provides an interface to access the Philippine Standard Geographic Code (PSGC) data. The PSGC is a systematic classification and coding of geographic areas in the Philippines, essential for various government and private sector activities such as statistical analysis, geographic information systems (GIS), and more.
- Retrieve PSGC codes and descriptions.
- Access hierarchical and flat list representations of geographic areas.
- Efficient and easy-to-use API for integrating PSGC data into applications.
To install the package, use npm
or your package manager of choice (e.g., pnpm
):
npm install psgc-areas
First, import the package into your project:
import { PSGCResource } from "psgc-areas";
To retrieve a hierarchical representation of all areas with regions at the top:
PSGCResource.getAll()
.then(data => {
console.log(data);
})
.catch(error => {
console.error("Error fetching hierarchical data:", error);
});
To get a flat list of all areas from the PSGC publication:
PSGCResource.getAreas()
.then(areas => {
console.log(areas);
})
.catch(error => {
console.error("Error fetching areas:", error);
});
To retrieve all regions:
PSGCResource.getRegions()
.then(regions => {
console.log(regions);
})
.catch(error => {
console.error("Error fetching regions:", error);
});
To retrieve all provinces:
PSGCResource.getProvinces()
.then(provinces => {
console.log(provinces);
})
.catch(error => {
console.error("Error fetching provinces:", error);
});
To retrieve all cities:
PSGCResource.getCities()
.then(cities => {
console.log(cities);
})
.catch(error => {
console.error("Error fetching cities:", error);
});
To retrieve all municipalities:
PSGCResource.getMunicipalities()
.then(municipalities => {
console.log(municipalities);
})
.catch(error => {
console.error("Error fetching municipalities:", error);
});
To retrieve all municipal districts:
PSGCResource.getMunicipalDistricts()
.then(municipalDistricts => {
console.log(municipalDistricts);
})
.catch(error => {
console.error("Error fetching municipal districts:", error);
});
To retrieve all barangays:
PSGCResource.getBarangays()
.then(barangays => {
console.log(barangays);
})
.catch(error => {
console.error("Error fetching barangays:", error);
});
- Description: Fetches a hierarchical representation of all areas with regions at the top.
- Returns: A promise that resolves to a hierarchical structure of geographic areas.
- Description: Fetches a flat list of all areas from the PSGC publication.
- Returns: A promise that resolves to an array of area objects.
- Description: Fetches all regions.
- Returns: A promise that resolves to an array of region objects.
- Description: Fetches all provinces.
- Returns: A promise that resolves to an array of province objects.
- Description: Fetches all cities.
- Returns: A promise that resolves to an array of city objects.
- Description: Fetches all municipalities.
- Returns: A promise that resolves to an array of municipality objects.
- Description: Fetches all municipal districts.
- Returns: A promise that resolves to an array of municipal district objects.
- Description: Fetches all barangays.
- Returns: A promise that resolves to an array of barangay objects.
If you would like to contribute, please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
For questions or suggestions, please open an issue on GitHub.