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.1.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.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: identify_africa-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 590bded6b02140e721216f15dbb2c6592f15886519be1c10af108dc95d958299
MD5 70828fcbcafcefe280bbf80e4ed8a610
BLAKE2b-256 e09c18e78040dd57fc3157aa897a88197f3b30fabc7ff54a036e7f989fa20ba4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for identify_africa-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3dc4cadfe5881c7bfef5ee6d1ddbe020aeeee1c3082047b1e16193fa444e0fa
MD5 48faea89d914d8ab1b5b9fd41efda6ec
BLAKE2b-256 6f1525eb1c37e88c6b23009e57c254b2d0b31d08b52c6addeb49543e6f2bd9ba

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

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