Skip to main content

A Python package for Philippines zip codes

Project description

phzipcodes

Philippines zip codes package

API Reference

search(query: str, fields: List[str] = None, match_type: str = "contains") -> List[ZipCode]

Search for zip codes based on query and criteria.

  • Parameters:
    • query: str - The search query
    • fields: List[str] (optional) - List of fields to search in (default: ["city", "province", "region"])
    • match_type: str (optional) - Type of match to perform (default: "contains")
  • Returns: List[ZipCode] - List of matching ZipCode objects

get_by_zip(zip_code: str) -> Optional[ZipCode]

Retrieve zip code information by zip code.

  • Parameters:
    • zip_code: str - The zip code to look up
  • Returns: Optional[ZipCode] - ZipCode object if found, None otherwise

get_regions() -> List[str]

Get all unique regions.

  • Returns: List[str] - List of all unique regions

get_provinces(region: str) -> List[str]

Get all provinces in a specific region.

  • Parameters:
    • region: str - The region to get provinces for
  • Returns: List[str] - List of provinces in the specified region

get_cities_municipalities(province: str) -> List[str]

Get all cities/municipalities in a specific province.

  • Parameters:
    • province: str - The province to get cities for
  • Returns: List[str] - List of cities in the specified province

Data Structure

The package uses a ZipCode class with the following attributes:

class ZipCode(BaseModel):
    region: str
    province: str
    city_municipality: str
    code: str

Data Source and Collection

The zip code data used in this package is sourced from PHLPost (Philippine Postal Corporation), the official postal service of the Philippines.

To keep data current, use custom scraper tool (scraper.py).

Development

  1. Clone the repository

    git clone https://github.com/jayson-panganiban/phzipcodes.git
    cd phzipcodes
    
  2. Install dependencies

    poetry install
    
  3. Run Tests

    poetry run pytest
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phzipcodes-0.1.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

phzipcodes-0.1.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file phzipcodes-0.1.1.tar.gz.

File metadata

  • Download URL: phzipcodes-0.1.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.0 Windows/10

File hashes

Hashes for phzipcodes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b97a2a3ab8cf1cc24e05dac5ac05715995d8e40b132a74fa310ceaf359a99cf3
MD5 253b2394db6006d33f41444ea6c0b3e0
BLAKE2b-256 219b1380dbdc3df40a4ef506491956dcb9ff978d2afb8a87fc2eef50358761f8

See more details on using hashes here.

File details

Details for the file phzipcodes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: phzipcodes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.0 Windows/10

File hashes

Hashes for phzipcodes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c088f3b36f0c23310133e485f20dbfb725b6167424718e7696a59fbc3a3f08d
MD5 0b35cd4d9f9c22374c76fc8e9d9a1714
BLAKE2b-256 a0142d57240db19c3d639aed2abb27aba1b1737005499f247ad976ae61069b6b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page