OCR
This article explains how to extract data from documents using the Unico Check REST API.
This method extracts data from documents such as CNH (Open, front, back or digital), RG (Front or Back) and CRM (Front or Back) sent in the request.
How to use it?
Make a POST request to the /documents/ocr
endpoint
With a valid Access token, make a request to the endpoint (POST/documents/ocr) enviando os seguintes parâmetros:
{
"type": "TIPO_DOCUMENTO",
"Base64": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAgSURBVDhPY/wPBAwUACYoTTYYNWDUABAYNWDgDWBgAABrygQclUTopgAAAABJRU5ErkJggg=="
}
Parameters:
- HEADER PARAMETERS
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
APIKEY | String | Mandatory | API key |
Authorization | String | Mandatory | Access token |
Content-Type | String | Mandatory | "application/json" |
- REQUEST BODY SCHEMA
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
type | String | Mandatory | Tipo do documento |
Base64 | String | Mandatory | Foto do documento. A imagem precisa ser em base64 (png, jpg, jpeg) |
Request example:
{
"type": 4,
"base64": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAgSURBVDhPY/wPBAwUACYoTTYYNWDUABAYNWDgDWBgAABrygQclUTopgAAAABJRU5ErkJggg=="
}
The type of document can be found in the enumerated article at OCR Documents.
Successful request
If the request was executed successfully, the return response is a JSON containing the following fields, as follows:
{
"BirthDate": "01/01/2000",
"PlaceOfBirth": "São Paulo",
"Category": "AB",
"ExpeditionCity": "São Paulo",
"ExpeditionState": "SP",
"ExpeditionDate": "01/01/2000",
"ExpirationDate": "01/01/2000",
"FatherName": "João",
"MotherName": "Maria",
"FirstLicenseDate": "01/01/2000",
"Name": "José",
"RG": "123456789",
"Code": "12345678910",
"RegistrationNumber": "01234567",
"Renach": "789456123",
"SecurityCode": "123456",
"MirrorNumber": "78910",
"CRM": "5-549788-5/PR",
"Observation": ""
}
The return parameters are:
Name | Type | Description |
---|---|---|
BirthDate | string | Indica a data de nascimento |
PlaceOfBirth | string | Indica o local de nascimento |
Category | string | Indica a categoria da habilitação (CNH) |
ExpeditionCity | string | Indica a cidade de emissão do documento |
ExpeditionState | string | Indica UF de emissão do documento |
ExpeditionDate | string | Indica a data de emissão do documento |
ExpirationDate | string | Indica a validade do documento |
FatherName | string | Indica o nome do pai |
MotherName | string | Indica o nome da mãe |
FirstLicenseDate | string | Indica a data da 1ª habilitação (CNH) |
Name | string | Indica o nome da pessoa |
RG | string | Indica o número do RG |
Code | string | Indica o número do CPF |
RegistrationNumber | string | Indica o Nº de Registro da habilitação (CNH) |
Renach | string | Indica o Registro Nacional de Carteira de Habilitação (CNH) |
SecurityCode | string | Indica o código de segurança |
MirrorNumber | string | Indica o Número do Espelho da habilitação (CNH) |
CRM | string | Indica o número do CRM |
Observation | string | Indica observaçoes que estão no documento |
Request error
If an error occurs, the return response is a JSON containing the error code and description:
{
"Error": {
"code": "40004",
"description": "Error description"
}
}
For more information on the errors returned, see the list available in the article Response Errors.
Any concerns?
Missing something or still need help? If you are already a customer or partner, you can contact us through the Help Center.