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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590bded6b02140e721216f15dbb2c6592f15886519be1c10af108dc95d958299
|
|
| MD5 |
70828fcbcafcefe280bbf80e4ed8a610
|
|
| BLAKE2b-256 |
e09c18e78040dd57fc3157aa897a88197f3b30fabc7ff54a036e7f989fa20ba4
|
File details
Details for the file identify_africa-0.1.1-py3-none-any.whl.
File metadata
- Download URL: identify_africa-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3dc4cadfe5881c7bfef5ee6d1ddbe020aeeee1c3082047b1e16193fa444e0fa
|
|
| MD5 |
48faea89d914d8ab1b5b9fd41efda6ec
|
|
| BLAKE2b-256 |
6f1525eb1c37e88c6b23009e57c254b2d0b31d08b52c6addeb49543e6f2bd9ba
|