Python SDK for Fayda IDA (Identity Authentication) - OTP, Authentication and eKYC services
Project description
Python IDA SDK
Python SDK for Fayda IDA (Identity Authentication) services. Provides a simple and intuitive interface for OTP generation, authentication, and eKYC (electronic Know Your Customer) operations.
Features
- OTP Management: Request and manage OTPs for Fayda ID verification
- Yes/No Auth: Yes/No authentication using OTP
- eKYC Services: Perform electronic KYC to retrieve verified identity information
- Secure Cryptography: Built-in support for RSA-OAEP, AES-GCM, and JWT signatures
- PKCS12 Key Management: Support for PKCS12 certificate and key files
- Easy Configuration: Configure via environment variables or dictionary
- Comprehensive Error Handling: Robust error handling and logging
Installation
Install from PyPI:
pip install fayda-python-sdk
Or install from source:
git clone https://github.com/National-ID-Program-Ethiopia/python-ida-sdk.git
cd python-ida-sdk
pip install -e .
Quick Start
Usage
Basic Configuration
from fayda_py_sdk import ConfigBuilder
from fayda_py_sdk.dto import OtpRequestDTO, AuthRequestDTO
# Configure from environment variables
config = ConfigBuilder().from_env()
# Or configure from dictionary
config = ConfigBuilder().from_dict({
"partnerId": "fayda-partner-demo",
"fayda.base.url": "https://fayda.baseurl.et",
"mispLicenseKey": "your-license-key",
"partnerApiKey": "your-api-key",
"ida.reference.id": "PARTNER",
"p12.path": "keys",
"p12.password": "pass@123",
"ida.ssl.verify": False
})
# Build client
client = config.build()
Request OTP
from fayda_py_sdk.dto import OtpRequestDTO
otp_request = OtpRequestDTO(
individual_id="1234567890",
individual_id_type="FIN",
otp_channel=["email"]
)
response = client.request_otp(otp_request)
print(response)
Yes/No Auth
from fayda_py_sdk.dto import AuthRequestDTO
# Fayda ID: UIN for FIN or VID for FAN
auth_request = AuthRequestDTO(
individual_id="1234567890", # Fayda ID
individual_id_type="UIN", # UIN for FIN or VID for FAN
otp="123456"
)
response = client.yes_no_auth(auth_request)
print(response)
Perform eKYC
from fayda_py_sdk.dto import AuthRequestDTO
# Fayda ID: UIN for FIN or VID for FAN
ekyc_request = AuthRequestDTO(
individual_id="1234567890", # Fayda ID
individual_id_type="UIN", # UIN for FIN or VID for FAN
otp="123456"
)
response = client.perform_ekyc(ekyc_request)
print(response)
Configuration
The SDK can be configured using:
-
Environment Variables:
PARTNER_ID: Partner IDFAYDA_BASE_URL: Base URL for Fayda APIMISP_LICENSE_KEY: MISP License KeyPARTNER_API_KEY: Partner API KeyIDA_REFERENCE_ID: IDA Reference IDP12_PATH: Path to PKCS12 keys directoryP12_PASSWORD: Password for PKCS12 filesIDA_SSL_VERIFY: Enable/disable SSL verification (true/false)
-
Dictionary: Pass configuration as a dictionary to
ConfigBuilder.from_dict() -
Manual Configuration: Use
ConfigBuilder().set_config(key, value)for individual settings
Key Files
The SDK expects PKCS12 key files in the keys directory (default: keys/). The files should be named:
{partnerId}-partner.p12- Partner private key and certificate{partnerId}-partner.cer- Partner certificate
Running Examples
# Make sure your keys are in the keys/ directory
# Update configuration in example.py or set environment variables
python example.py
Requirements
- Python 3.8 or higher
- PKCS12 key files (
.p12format) for partner authentication - Valid Fayda API credentials
Error Handling
The SDK includes comprehensive error handling. All exceptions are logged and raised with descriptive messages. Common errors include:
RuntimeError: For authentication failures, certificate errors, or API errorsValueError: For invalid configuration or key file issuesException: For network or parsing errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
For issues, questions, or contributions, please use the GitHub Issues page.
For direct support, contact:
- Fayda API Support: api_support@id.et
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG.md for a list of changes and version history.
Project details
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 fayda_python_sdk-1.0.4.tar.gz.
File metadata
- Download URL: fayda_python_sdk-1.0.4.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0639944966f92e2ff0203918e9b5456ba1efcd27874aba416d932cfeb97d59da
|
|
| MD5 |
8bd32213351e52583cab3250d4a538ef
|
|
| BLAKE2b-256 |
7fa967ceecbd11bf57e95ce076d0581d45df0ef10fbc6dc4b4a8bb627dfa5c62
|
File details
Details for the file fayda_python_sdk-1.0.4-py3-none-any.whl.
File metadata
- Download URL: fayda_python_sdk-1.0.4-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee17ee3ff59089c65665947e0925a0df673d54a4153c3a983ffe6274b28064c
|
|
| MD5 |
06cb27caccd0eb0f3220cc8502783f6e
|
|
| BLAKE2b-256 |
c0647692a919f6e8b4a85d53f19f9bafc6db44942bb9318e96d9f739e8b83e50
|