Skip to main content

identify-africa

Python SDK for the Identify Africa KYC and identity verification API. Provides typed, validated access to national ID, alien ID, driving license, vehicle plate, and phone intelligence verification.

Installation

pip install identify-africa

Usage

from identify_africa import IdentifyAfricaClient, verify_national_id, NationalIdRequest

client = IdentifyAfricaClient(
    api_key="your_api_key",
    api_secret="your_api_secret",
)

result = verify_national_id(client, NationalIdRequest(idnumber="12345678"))

if result["success"]:
    print(result["data"]["first_name"])
else:
    print(result["message"], result["response_code"])

Responses are returned exactly as sent by the API, unmodified — including both success and error payloads.

Configuration

Parameter Type Required Default Description
api_key str Yes Your API key
api_secret str Yes Your API secret
environment "sandbox" | "production" No "sandbox" Which base URL to target
timeout float No 10.0 Request timeout in seconds
max_retries int No 2 Max retry attempts on transient failures
retry_delay float No 0.3 Base delay (seconds) for exponential backoff
logger Logger No Optional logger for request/response/retry events

Store your credentials in your own .env file (loaded with a tool like python-dotenv) — never commit them to source control:

API_KEY=your_api_key API_SECRET=your_api_secret

Logging

import logging
from identify_africa import IdentifyAfricaClient

logger = logging.getLogger("identify_africa")
logging.basicConfig(level=logging.DEBUG)

client = IdentifyAfricaClient(
    api_key="...",
    api_secret="...",
    logger=logger,
)

Sensitive request fields (idnumber, plate, number) are automatically masked in log output (e.g. ****5678). Response data is never logged.

Available Functions

verify_national_id(client, NationalIdRequest(idnumber=...))

Verifies a Kenyan National ID number (8 digits).

verify_alien_id(client, AlienIdRequest(idnumber=...))

Verifies an Alien ID number for non-citizens.

verify_driving_license(client, DrivingLicenseRequest(idnumber=...))

Looks up driving license details using a National ID number.

verify_vehicle_plate(client, VehiclePlateRequest(plate=...))

Verifies vehicle registration details using a number plate.

get_phone_intel(client, PhoneIntelRequest(number=...))

Retrieves phone intelligence — carrier, spam score, location, and validation details.

Each function validates required input client-side before sending the request, raising a ValueError if validation fails (some fields are also validated at construction time by the underlying pydantic request models).

Response Shape

Every function returns a plain dict matching the API's response envelope:

{
    "success": bool,
    "response_code": int,
    "message": str,
    "data": ...,        # shape depends on endpoint and success/failure
    "request_id": str,
}

Check result["success"] before relying on result["data"]'s shape.

Error Codes

Code Meaning Retried automatically?
200 Success
401 Unauthorized — invalid or missing credentials No
402 Low credit balance No
412 Validation error (check data for field errors) No
424 Upstream dependency failure Yes
502 Upstream service unavailable Yes

Development

pip install -e ".[dev]"
pytest
python -m build

Built with httpx and pydantic. Tests run with pytest.

Release Process

This project follows Semantic Versioning. CI runs tests and a build check on every push/PR to main.

Publishing to PyPI is automated via Trusted Publishing (OIDC) — pushing a version tag triggers the publish.yml workflow, which runs tests, builds, and publishes with no stored credentials:

# bump version in pyproject.toml
git add .
git commit -m "Release vX.Y.Z"
git tag vX.Y.Z
git push && git push --tags

License

MIT

identify-africa

Python SDK for the Identify Africa KYC and identity verification API. Provides typed, validated access to national ID, alien ID, driving license, vehicle plate, and phone intelligence verification.

Installation

pip install identify-africa

Usage

from identify_africa import IdentifyAfricaClient, verify_national_id, NationalIdRequest

client = IdentifyAfricaClient(
    api_key="your_api_key",
    api_secret="your_api_secret",
)

result = verify_national_id(client, NationalIdRequest(idnumber="12345678"))

if result["success"]:
    print(result["data"]["first_name"])
else:
    print(result["message"], result["response_code"])

Responses are returned exactly as sent by the API, unmodified — including both success and error payloads.

Configuration

Parameter Type Required Default Description
api_key str Yes Your API key
api_secret str Yes Your API secret
environment "sandbox" | "production" No "sandbox" Which base URL to target
timeout float No 10.0 Request timeout in seconds
max_retries int No 2 Max retry attempts on transient failures
retry_delay float No 0.3 Base delay (seconds) for exponential backoff
logger Logger No Optional logger for request/response/retry events

Store your credentials in your own .env file (loaded with a tool like python-dotenv) — never commit them to source control:

API_KEY=your_api_key API_SECRET=your_api_secret

Logging

import logging
from identify_africa import IdentifyAfricaClient

logger = logging.getLogger("identify_africa")
logging.basicConfig(level=logging.DEBUG)

client = IdentifyAfricaClient(
    api_key="...",
    api_secret="...",
    logger=logger,
)

Sensitive request fields (idnumber, plate, number) are automatically masked in log output (e.g. ****5678). Response data is never logged.

Available Functions

verify_national_id(client, NationalIdRequest(idnumber=...))

Verifies a Kenyan National ID number (8 digits).

verify_alien_id(client, AlienIdRequest(idnumber=...))

Verifies an Alien ID number for non-citizens.

verify_driving_license(client, DrivingLicenseRequest(idnumber=...))

Looks up driving license details using a National ID number.

verify_vehicle_plate(client, VehiclePlateRequest(plate=...))

Verifies vehicle registration details using a number plate.

get_phone_intel(client, PhoneIntelRequest(number=...))

Retrieves phone intelligence — carrier, spam score, location, and validation details.

Each function validates required input client-side before sending the request, raising a ValueError if validation fails (some fields are also validated at construction time by the underlying pydantic request models).

Response Shape

Every function returns a plain dict matching the API's response envelope:

{
    "success": bool,
    "response_code": int,
    "message": str,
    "data": ...,        # shape depends on endpoint and success/failure
    "request_id": str,
}

Check result["success"] before relying on result["data"]'s shape.

Error Codes

Code Meaning Retried automatically?
200 Success
401 Unauthorized — invalid or missing credentials No
402 Low credit balance No
412 Validation error (check data for field errors) No
424 Upstream dependency failure Yes
502 Upstream service unavailable Yes

Development

pip install -e ".[dev]"
pytest
python -m build

Built with httpx and pydantic. Tests run with pytest.

Release Process

This project follows Semantic Versioning. CI runs tests and a build check on every push/PR to main.

Publishing to PyPI is automated via Trusted Publishing (OIDC) — pushing a version tag triggers the publish.yml workflow, which runs tests, builds, and publishes with no stored credentials:

# bump version in pyproject.toml
git add .
git commit -m "Release vX.Y.Z"
git tag vX.Y.Z
git push && git push --tags

License

MIT

Download files

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

Source Distribution

identify_africa-0.1.2.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

identify_africa-0.1.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file identify_africa-0.1.2.tar.gz.

File metadata

  • Download URL: identify_africa-0.1.2.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for identify_africa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ea0912338507e053e2d71095011e528524573a400dc44ef9d2e663261d45b1d3
MD5 9dc075151f5ddd9c957590cde635f521
BLAKE2b-256 e50b00159b26581b322c8467bd7c22c45c2249b2e467d950a7e698d73c14f424

See more details on using hashes here.

File details

Details for the file identify_africa-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for identify_africa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f15350f2d2e7f3f4d241a04873341b92e8e928eb35b04ac99635e2e440a9013
MD5 b4db2327ac82746dc11409300b499bb1
BLAKE2b-256 92c3b05f34c30dec2be6da7e8bd0db2605052a2aa02711e7a580e16af6d45c8c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page