Postal codes and post offices
import { getPostalCode, getCityByPostalCode, getPostOffice, searchPostOffices } from 'pakdatakit/postal'
Two datasets: the main postal codes of the cities the package lists, and Pakistan Post’s full directory of about 2,560 delivery post offices, including towns and villages.
- City (getCityByPostalCode)
- —
- Post office
- Chak Dhamni
- Town
- Chak Dhamni
- District
- —
- Province
- Azad Jammu and Kashmir
Examples
Section titled “Examples”import { getPostalCode, getCityByPostalCode, getPostOffice } from 'pakdatakit';
getPostalCode('Lahore');// → '54000'
getCityByPostalCode('54000');// → 'Lahore'
getPostOffice('12380');// → {// "code": "12380",// "office": "Chak Dhamni",// "town": "Chak Dhamni",// "district": null,// "province": "Azad Jammu and Kashmir"// }from pakdatakit import get_postal_code, get_city_by_postal_code, get_post_office
get_postal_code('Lahore')# → '54000'
get_city_by_postal_code('54000')# → 'Lahore'
get_post_office('12380')# → {# "code": "12380",# "office": "Chak Dhamni",# "town": "Chak Dhamni",# "district": None,# "province": "Azad Jammu and Kashmir"# }import 'package:pakdatakit/pakdatakit.dart';
getPostalCode('Lahore');// → '54000'
getCityByPostalCode('54000');// → 'Lahore'
getPostOffice('12380');// → {// "code": "12380",// "office": "Chak Dhamni",// "town": "Chak Dhamni",// "district": null,// "province": "Azad Jammu and Kashmir"// }using PakDataKit;
Postal.GetCode("Lahore");// → "54000"
Postal.GetCity("54000");// → "Lahore"
Postal.GetPostOffice("12380");// → {// "code": "12380",// "office": "Chak Dhamni",// "town": "Chak Dhamni",// "district": null,// "province": "Azad Jammu and Kashmir"// }use PakDataKit\Postal;
Postal::getCode('Lahore');// → '54000'
Postal::getCity('54000');// → 'Lahore'
Postal::getPostOffice('12380');// → {// "code": "12380",// "office": "Chak Dhamni",// "town": "Chak Dhamni",// "district": null,// "province": "Azad Jammu and Kashmir"// }Reference
Section titled “Reference”getPostalCode()
Section titled “getPostalCode()”function getPostalCode(city: string): string | null;Returns the primary postal code of a city (case-insensitive), or null for an unknown city.
getCityByPostalCode()
Section titled “getCityByPostalCode()”function getCityByPostalCode(postalCode: string): string | null;Returns the city for one of its own post offices. A village code returns null; use getPostOffice() for those.
getPostOffice()
Section titled “getPostOffice()”function getPostOffice(code: string): PostOffice | null;
interface PostOffice { code: string; office: string; town: string; district: string | null; province: string;}Returns any delivery post office by its five-digit code.
Caveats. The directory is a separate data file, loaded only when these functions are first called.
Related: searchPostOffices(), scoreAddress(), data sources.