/ocr/idcard
1.API Specification
2.Request Params
3.Response Params
4.Error Codes
5.Sample
1.API Specification
This API is used to recognize ID card of Tanzania, and extract the key information.
Image spec
1. Format: JPG(JPEG), PNG, e-aadhaar(PDF)
2. Between 128*128 and 6000*6000 (pixels), Recommended resolution: 1280*1280
3. File size: no larger than 5 MB
Request Method
POST
Request URL
https://cloudapi.tanzania.accuauth.com/ocr/idcard
Debugging Tool
2.Request Params
2.1 Request Header
Parameter | Type | Required | Description |
---|---|---|---|
X-DF-API-ID | string | Yes | For API credentials,Please visit API Request |
X-DF-API-SECRET | string | Yes | For API credentials,Please visit API Request |
2.2 Request Body
Fields | Type | Description | |
---|---|---|---|
optional | file | file | Binary data of the image |
optional | image_base64 | string | Base64 encoded data of image |
optional | detect_face | integer | 1: enable face detection, and the face_region field will be returned; 0: the default value, disable face detection. |
Either parameter
file
orimage_base64
must be provided as a request parameter.You MUST add image stream to multipart/form-data section of POST message when using
file
parameter.
3.Response Params
Fields | Type | Description |
---|---|---|
request_id | string | Unique id of each request |
status | string | Response status, OK if request success, other if failed; See Error Codes for details |
results | array | The array of card ocr results,See results belowed for details |
Elements in results
:
Fields | Type | Description |
---|---|---|
card_side | string | The side of card: front |
card_info | object | The key infomation of card |
card_type | string | ID or Voter |
face_region | array | Four point coordinates of face rect, format as: [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]; The coordinate is based on the original image, while the points order is based on the face after rotation(top left, top right, bottom right, bottom left). |
Elements in the card_info
- Front side of ID card info:
Fields | Type | Description |
---|---|---|
id_number | string | ID card number |
given_name | string | Given name |
middle_name | string | Middle name |
last_name | string | Last name |
birthday | string | Date of birth |
birthday_s | string | Formatted date of birth: dd-mm-yyyy |
gender | string | Gender, M or F |
resident_type | string | Resident type |
nationality | string | Nationality |
expiry_date | string | Expiry date |
expiry_date_s | string | Formatted expiry date: dd-mm-yyyy |
- Front side of Voter card info:
Fields | Type | Description |
---|---|---|
id_number | string | Voter ID card number |
full_name | string | Full name |
gender | string | Gender, ME (Male) or KE (Female) |
gender_s | string | Gender, M or F |
birthday | string | Date of birth: dd mm yyyy |
birthday_s | string | Formatted date of birth: dd-mm-yyyy |
registration_centre | string | Registration center |
street | string | Street |
ward | string | Ward |
Response Syntax
- Front side of ID card
{
"request_id": "TIDe32de81c8a194ee9bca6c5de00ca338a",
"results": [
{
"card_info": {
"id_number": "19880622-75120-*****-**",
"given_name": "AMXXX",
"middle_name": "AYOXXX",
"last_name": "AMXXX",
"birthday": "03 MAY 1967",
"birthday_s": "03-05-1967",
"gender": "M",
"nationality": "",
"resident_type": "CITIZEN IDENTITY CARD"
"expiry_date": "05/24",
"expiry_date_s": "01-05-2024"
},
"card_side": "front",
"face_region": [
[
325,
1010
],
[
736,
1010
],
[
736,
1523
],
[
325,
1523
]
]
}
],
"status": "OK"
}
- Front side of Voter card
{
"request_id": "TID21afee54bdda4b76b9593222db2c6dee",
"results": [
{
"card_info": {
"birthday": "26 04 1999",
"birthday_s": "26-04-1999",
"full_name": "AMINA S *****",
"gender": "KE",
"gender_s": "F",
"id_number": "1538273*****",
"registration_centre": "MSINGI *****",
"street": "CHANGANYIKENI",
"ward": "MAKONGO"
},
"card_side": "front",
"card_type": "VOTER"
}
],
"status": "OK"
}
4.Error Codes
Common error codes of this API:
Http Status Code | Status field |
Description |
---|---|---|
400 |
INVALID_ARGUMENT | Request parameter is invalid |
400 |
DETECTION_FAILED | Detect image failed |
401 |
UNAUTHORIZED | Unauthorized or access is denied |
401 |
KEY_EXPIRED | Your API ID has expired |
403 |
NO_PERMISSION | You are not authorized to use this API |
403 |
OUT_OF_QUOTA | API calls quota exceeded |
403 |
RATE_LIMIT_EXCEEDED | API request frequency exceeds the limit |
404 |
NOT_FOUND | Requested API cannot be found |
500 |
INTERNAL_ERROR | Internal server error |
Comment: Please see the reason
field for details when the above 40X error occurred
Response Syntax
{
"status": "INVALID_ARGUMENT",
"reason": "must specify 'file' or 'image_base64' argument",
"request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e"
}