Skip to main content

PakDataKit for Python

Utilities for Pakistani data: CNIC, mobile numbers and networks, WhatsApp links, IBAN, postal codes, cities and districts, address parsing, Roman Urdu, Hijri dates, public holidays, rupee formatting, amounts in words, NTN/STRN, landlines and Raast QR codes.

This is the Python port of the pakdatakit npm package. It ships the same datasets and is tested against shared test vectors generated from the TypeScript library, so both give identical results. Pure Python, no dependencies, Python 3.9+.

Install

pip install pakdatakit

Examples

import datetime as dt
import pakdatakit as pdk

pdk.validate_cnic("35202-1234567-1")          # True
pdk.get_cnic_info("35202-1234567-1")
# CNICInfo(digits='3520212345671', formatted='35202-1234567-1', province='Punjab', gender='male')

pdk.format_phone("0300 1234567")              # '+923001234567'
pdk.get_network("0345-1234567")               # 'Telenor'
pdk.create_whatsapp_link("03001234567", "Salam!")

pdk.validate_iban("PK36 SCBL 0000 0011 2345 6702")       # True
pdk.get_bank_from_iban("PK36SCBL0000001123456702")       # 'Standard Chartered Bank (Pakistan) Limited'
pdk.get_bank_info("MEZN").type                           # 'islamic'

pdk.get_province("Lahore")                    # 'Punjab'
pdk.parse_address("House 12, Street 5, Model Town Lahore 54000")

pdk.format_pkr(150000)                        # 'Rs. 150,000'
pdk.format_lakh(2500000)                      # '25 Lakh'
pdk.amount_in_words(125000, cheque=True)      # 'Rupees One Lakh Twenty-Five Thousand Only'
pdk.number_to_words(125000, language="ur")    # 'ایک لاکھ پچیس ہزار'

pdk.format_hijri(dt.date(2026, 3, 1))         # '12 Ramadan 1447'
pdk.get_pakistan_holidays(2026)[0]            # Holiday(id='kashmir-day', ...)

payload = pdk.create_raast_p2p_qr("PK36SCBL0000001123456702", amount=1500, expires_in="1d")
pdk.validate_raast_qr(payload).valid          # True

pdk.format_cnic_input("3520212")              # '35202-12'
pdk.check_phone_input("0300 12")              # 'incomplete'

API

Every function of the npm package is available under its snake_case name (validateCNIC → validate_cnic, createRaastP2PQr → create_raast_p2p_qr). Option objects become keyword arguments ({ expiresIn: '1d' } → expires_in="1d"), structured results are frozen dataclasses with snake_case fields, null is None, and a RangeError is a ValueError. Dates are datetime.date / naive local datetime.datetime.

DATA_VERSION gives the date the datasets were last checked, and __version__ the package version.

See the main README for the full API reference and DATA.md for where each dataset comes from.

Development

From python/:

uv run --with pytest pytest -q

The data files in src/pakdatakit/data/ and the vectors in ../test-vectors/ are generated from the TypeScript package; don't edit them by hand. From the repository root:

npm run build && node scripts/generate-test-vectors.mjs

License

MIT

Metadata

Release files for pakdatakit 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pakdatakit 2.2.1
File Size Uploaded Provenance Actions
pakdatakit-2.2.1.tar.gz 42.4 kB With provenance Details for pakdatakit-2.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pakdatakit 2.2.1
File Interpreter ABI Platform Actions
pakdatakit-2.2.1-py3-none-any.whl Python 3 none any Details for pakdatakit-2.2.1-py3-none-any.whl

Total release size: 92.1 kB

Release files / pakdatakit-2.2.1.tar.gz

Download URL pakdatakit-2.2.1.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
65d35f309fb34c897aaf94bc6334b2eebcf6e2775195caa9f1e2d3674756785c
BLAKE2b-256 checksum
How to use checksums
d5ad791bf043f547fba11d0aa1a6b1c24679ae6105d6e9e02b2e347968bb8345
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / pakdatakit-2.2.1-py3-none-any.whl

Download URL pakdatakit-2.2.1-py3-none-any.whl
Size 49.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1664e2b40ce3631dbdd22315fe75080f85162a5f5f0e26cf524dbe0f99753f44
BLAKE2b-256 checksum
How to use checksums
0abfd1b4ff568b31bdb206f015a6e511f342854858bf1b82d7d4dc6e962a3107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for pakdatakit 2.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pakdatakit-2.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page