identify_africa_sdk 0.1.0
identify_africa_sdk: ^0.1.0 copied to clipboard
Flutter SDK for Identify Africa's KYC and identity verification services
Identify Africa SDK #
A Flutter SDK for Identify Africa's KYC and identity verification services. This SDK provides a simple, secure way to access Identify Africa's verification APIs within Flutter applications.
Features #
- National ID verification
- Secure authentication handling
- Comprehensive error handling and reporting
- Extensible architecture for future verification types
- Cross-platform support (iOS, Android, Web)
Installation #
Add the package to your pubspec.yaml:
dependencies:
identify_africa_sdk: ^0.1.0
Then run:
flutter pub get
Usage #
Initialize the SDK #
First, initialize the SDK with your API credentials:
final identifyAfrica = IdentifyAfrica(
username: 'YOUR_API_USERNAME',
apiSecret: 'YOUR_API_SECRET',
baseUrl: 'https://partner.identifyafrica.io',
);
You must replace YOUR_API_USERNAME and YOUR_API_SECRET with the credentials provided by Identify Africa. Contact our support team if you don't have API credentials.
National ID Verification #
Verify a Kenyan National ID with a simple API call:
try {
final response = await identifyAfrica.idVerification.verifyNationalId('12345678');
if (response.success) {
// Access the verified data
final data = response.data;
print('First Name: ${data?.firstName}');
print('Last Name: ${data?.lastName}');
print('Other Name: ${data?.otherName}');
print('Full Name: ${data?.name}');
print('Gender: ${data?.gender}');
print('Date of Birth: ${data?.dob}');
print('Citizenship: ${data?.citizenship}');
print('ID Number: ${data?.idNumber}');
print('Serial Number: ${data?.serialNo}');
print('Valid: ${data?.valid}');
// The unique request ID for tracking and support
print('Request ID: ${response.requestId}');
} else {
print('Verification failed: ${response.message}');
print('Response code: ${response.responseCode}');
print('Request ID: ${response.requestId}');
}
} catch (e) {
print('Error: $e');
}
Response Structure #
All API responses follow a consistent structure:
success: Boolean indicating if the request was successfulresponseCode: HTTP status codemessage: Human-readable message about the responsedata: The verification data (specific to each verification type)requestId: Unique identifier for the request (useful for support)
Available Data Fields for National ID #
| Field | Description | Type |
|---|---|---|
| firstName | First name of the individual | String |
| lastName | Last name of the individual | String |
| otherName | Middle/other names | String |
| name | Full name | String |
| gender | Gender (Male/Female) | String |
| dob | Date of birth (YYYY-MM-DD) | String |
| citizenship | Nationality | String |
| idNumber | National ID number | String |
| serialNo | ID card serial number | String |
| valid | Whether the ID is valid | Boolean |
Error Handling #
The SDK provides specific exception types for better error handling:
AuthenticationException: Authentication failed (check your credentials)ApiException: API returned an error responseServerException: Server-side error occurredNetworkException: Network connection issuesValidationException: Input validation failed
Example of Comprehensive Error Handling #
try {
final response = await identifyAfrica.idVerification.verifyNationalId('12345678');
// Process successful response...
} catch (e) {
if (e is AuthenticationException) {
print('Authentication failed: ${e.message}');
// Handle authentication errors (e.g., show login screen)
} else if (e is ApiException) {
print('API error: ${e.message}, Status: ${e.statusCode}');
// Handle API errors based on status code
} else if (e is ServerException) {
print('Server error: ${e.message}');
// Handle server errors (e.g., retry with backoff)
} else if (e is NetworkException) {
print('Network error: ${e.message}');
// Handle network errors (e.g., check connectivity)
} else {
print('Unexpected error: $e');
// Handle other errors
}
}
Requirements #
- Flutter 2.0.0 or higher
- Dart 2.17.0 or higher
- Valid Identify Africa API credentials
Example Project #
For a complete working example, see the example folder in the repository. The example demonstrates:
- Initializing the SDK
- Making verification requests
- Handling responses
- Error handling
Future Enhancements #
The SDK is designed to be extensible. Future updates will include support for:
- Alien ID verification
- Driving License verification
- Business Registration verification
- Phone number verification
- Bank account verification
- Vehicle plate verification
- Document verification
- Liveness checks
Support #
For support, please contact:
- Email: support@identifyafrica.com
- Website: https://identifyafrica.com
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Security #
This SDK communicates securely with the Identify Africa API using HTTPS. API credentials are transmitted with every request but never stored locally.
Security Best Practices: #
- Store API credentials securely
- Implement proper access controls in your application
- Do not hardcode credentials in your source code
- Consider using environment variables for credentials in production