Skip to main content

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
NameTypeMandatory/OptionalDescription
APIKEYStringMandatoryAPI key
AuthorizationStringMandatoryAccess token
Content-TypeStringMandatory"application/json"
  • REQUEST BODY SCHEMA
NameTypeMandatory/OptionalDescription
typeStringMandatoryTipo do documento
Base64StringMandatoryFoto do documento. A imagem precisa ser em base64 (png, jpg, jpeg)

Request example:

Arquivo JSON
{
"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:

NameTypeDescription
BirthDatestringIndica a data de nascimento
PlaceOfBirthstringIndica o local de nascimento
CategorystringIndica a categoria da habilitação (CNH)
ExpeditionCitystringIndica a cidade de emissão do documento
ExpeditionStatestringIndica UF de emissão do documento
ExpeditionDatestringIndica a data de emissão do documento
ExpirationDatestringIndica a validade do documento
FatherNamestringIndica o nome do pai
MotherNamestringIndica o nome da mãe
FirstLicenseDatestringIndica a data da 1ª habilitação (CNH)
NamestringIndica o nome da pessoa
RGstringIndica o número do RG
CodestringIndica o número do CPF
RegistrationNumberstringIndica o Nº de Registro da habilitação (CNH)
RenachstringIndica o Registro Nacional de Carteira de Habilitação (CNH)
SecurityCodestringIndica o código de segurança
MirrorNumberstringIndica o Número do Espelho da habilitação (CNH)
CRMstringIndica o número do CRM
ObservationstringIndica 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.