# Philippines PSGC Code Lookup (`justash/psgc-lookup`) Actor

Find official PSGC codes and region/province hierarchy for any Philippine region, province, city, municipality or barangay.

- **URL**: https://apify.com/justash/psgc-lookup.md
- **Developed by:** [Ash](https://apify.com/justash) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Philippines PSGC Code Lookup

Type in the name of any Philippine region, province, city, municipality, or barangay and get back its **official PSGC code**, plus the region and province it belongs to. No spreadsheets to dig through, no manual matching.

The PSGC (Philippine Standard Geographic Code) is the Philippine Statistics Authority's official coding system for every administrative area in the country. Government offices, researchers, and data teams use it to link datasets together.

### What can you do with it?

- **Clean messy place names.** Turn "Naga City", "City of Naga", or "Naga" into one official code.
- **Join datasets.** Add PSGC codes to survey, census, or LGU data so it can be merged with other sources.
- **Prepare GIS data.** Get the codes you need to link tables to boundary maps.
- **Find the parent area.** See which province and region a municipality or barangay belongs to.
- **Look up renamed places.** Old names are included, so searching an old barangay name still finds its current record.

### How to use it

1. Click **Try for free** (or **Start**).
2. In **Place names**, enter one or more names, one per line, for example `Baao` and `Naga City`.
3. Choose the **Place type**: Region, Province, City / Municipality, or Barangay.
4. *(Optional)* Type a province in **Province (optional)** to narrow the results, for example `Camarines Sur`.
5. Click **Start**, then open the **Output** tab when the run finishes.

You can download the results as **Excel, CSV, JSON, or HTML**, or call the actor through the Apify API.

### Input

| Field | Required | Description |
|---|---|---|
| Place names | Yes | One or more names to look up (for example `Baao`, `Naga City`). |
| Place type | No | Region, Province, City / Municipality (default), or Barangay. |
| Province (optional) | No | Keep only results inside this province. Strongly recommended for barangays, because many barangay names repeat across the country. |
| Max results per name | No | How many matches to return for each name (default 10, maximum 100). |

#### Example input

```json
{
  "searchTerms": ["Baao", "Naga City"],
  "level": "city_municipality",
  "provinceFilter": "Camarines Sur",
  "maxResultsPerSearch": 5
}
```

### Output

Each match is one row. Results are sorted by match quality, with exact matches first.

| Field | Description |
|---|---|
| `searchTerm` | The name you searched for. |
| `found` | `true` if a match was found, `false` if not. |
| `matchQuality` | `exact`, `starts with`, or `partial`. |
| `name` | Official name of the place. |
| `oldName` | Previous name, if the place was renamed. |
| `level` | The place type you searched. |
| `psgcCode` | The official 10-digit PSGC code. |
| `region` / `regionCode` | Region name and code. |
| `province` / `provinceCode` | Province name and code. |
| `cityOrMunicipality` | The city or municipality (filled for city/municipality and barangay searches). |
| `isCity` / `isMunicipality` | Whether the place is classed as a city or a municipality. |

#### Example output

```json
{
  "searchTerm": "Baao",
  "found": true,
  "matchQuality": "exact",
  "name": "Baao",
  "oldName": null,
  "level": "city_municipality",
  "psgcCode": "051701000",
  "region": "Bicol Region",
  "regionCode": "050000000",
  "province": "Camarines Sur",
  "provinceCode": "051700000",
  "cityOrMunicipality": "Baao",
  "isCity": false,
  "isMunicipality": true
}
```

If a name has no match, you get a row with `"found": false` so you can see which names need checking.

### Tips for better results

- **Use the Province box for barangays.** Searching just "San Jose" returns hundreds of matches. Adding a province narrows it to the ones you want.
- **Cities may be listed as "City of ...".** The actor ignores the words "City" and "City of" when matching, so "Naga City" and "City of Naga" both work.
- **Names that exist in several provinces return several rows.** Check the `province` column or add a province filter.
- **Barangay lookups take a little longer** because the barangay list is much larger than the others.

### How much does it cost?

This actor is **free to use**. It only reads public data and does not use a browser or proxies, so a run uses very little of your Apify platform credit.

### Data source

Place names and codes come from the **Philippine Standard Geographic Code (PSGC)** published by the Philippine Statistics Authority (PSA), served through a free public JSON API. The data reflects the most recent version available from that source, which may lag behind the newest PSA publication. For official or legal use, confirm codes against the PSA's own publication.

This actor is an independent tool and is **not affiliated with or endorsed by the PSA**.

### FAQ

**Does it include all barangays?**
It covers the barangays available in the source data, which is built from the PSA's PSGC publication.

**Can I look up a place by its old name?**
Yes. Old names are searched too, and the `oldName` field shows the previous name where one exists.

**Why did my name return no results?**
Check the spelling and the Place type. For example, a barangay name won't be found if the type is set to City / Municipality. If a place was created or renamed very recently, it may not be in the source data yet.

**Can I run it on a schedule or through the API?**
Yes. Like any Apify actor, you can schedule it, connect it to other tools, or call it through the Apify API.

### Feedback and issues

Found a wrong match, a missing place, or have a feature idea? Open an issue from the **Issues** tab on this actor's page and I'll take a look.

# Actor input Schema

## `searchTerms` (type: `array`):

One or more place names to look up, e.g. Baao, Naga City.

## `level` (type: `string`):

What kind of place are you searching for?

## `provinceFilter` (type: `string`):

Only keep results inside this province, e.g. Camarines Sur. Useful for barangay names that repeat across the country.

## `maxResultsPerSearch` (type: `integer`):

How many matches to return for each name.

## Actor input object example

```json
{
  "searchTerms": [
    "Baao",
    "Naga City"
  ],
  "level": "city_municipality",
  "maxResultsPerSearch": 10
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchTerms": [
        "Baao",
        "Naga City"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("justash/psgc-lookup").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "searchTerms": [
        "Baao",
        "Naga City",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("justash/psgc-lookup").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchTerms": [
    "Baao",
    "Naga City"
  ]
}' |
apify call justash/psgc-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,justash/psgc-lookup"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hA65M3LXZIJOjgbwH/builds/QBKxJBj8DCBucSYL7/openapi.json
