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 queryfields
: 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
-
Clone the repository
git clone https://github.com/jayson-panganiban/phzipcodes.git cd phzipcodes
-
Install dependencies
poetry install
-
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
Built Distribution
File details
Details for the file phzipcodes-0.1.0.tar.gz
.
File metadata
- Download URL: phzipcodes-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9d11f0523db6de4265a5d95326c1f255568830bea0a7858e3a0c23461598819 |
|
MD5 | 99566fe9d56bcf32074395209f2090a5 |
|
BLAKE2b-256 | 004f20285f844c5001330d04d680a8f2eb135f37c81641d1ec98ab9000953e4f |
File details
Details for the file phzipcodes-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: phzipcodes-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ad1ca800c29c726a5e9d3228eb9525f5d6d63159b6a9f7fbe9afe5767f0d105 |
|
MD5 | d0a3648fd5e17fa835da9cdfc7066c75 |
|
BLAKE2b-256 | dfdb5dcf476864827c2f19a5062f636eed6e445bd510fe58cb265747f36fca9b |