Background supergraphic

Paspor (Passport)

Paspor (Passport).

Paspor Object

  • Name
    status
    Type
    string
    Description

    Enum code indicating the status of the reading result.

    1. SUCCESS
    2. NO_FILE
    3. FILE_INVALID_FORMAT
    4. FAILED
  • Name
    reason
    Type
    string
    Description

    A human-readable message providing more details about the reading result.

  • Name
    read
    Type
    object
    Description

    Contains the reading for each Passport fields. Each field contains:

    • confidence (number): Overall confidence score in percentage
    • value (string): The processed/extracted value
    • value_original (string): The original text as read from the document
    • confidence_text (number): Text recognition confidence in percentage
    • polygon (array): Array of coordinate pairs [x, y] representing the bounding box of the field
    • page_index (number): Page number where the field was found (0-indexed)
    • Name
      birth_date
      Type
      object
      Description

      Date of birth in dd-mm-yyyy format.

    • Name
      birth_date_hash
      Type
      object
      Description

      Date of birth hash.

    • Name
      country
      Type
      object
      Description

      Country.

    • Name
      doc_number
      Type
      object
      Description

      Document number.

    • Name
      doc_number_hash
      Type
      object
      Description

      Document number hash.

    • Name
      document_type
      Type
      object
      Description

      Document type.

    • Name
      expiry_date
      Type
      object
      Description

      Expiry date in dd-mm-yyyy format.

    • Name
      expiry_date_hash
      Type
      object
      Description

      Expiry date hash.

    • Name
      final_hash
      Type
      object
      Description

      Final hash.

    • Name
      name
      Type
      object
      Description

      Name.

    • Name
      nationality
      Type
      object
      Description

      Nationality.

    • Name
      optional_data
      Type
      object
      Description

      Optional data.

    • Name
      optional_data_hash
      Type
      object
      Description

      Optional data hash.

    • Name
      sex
      Type
      object
      Description

      Sex.

    • Name
      surname
      Type
      object
      Description

      Surname.


POST/ocr/v1/passport

Read Passport

Detects a valid Passport image and returns the information that contain on MRZ code (located at the bottom of the passport).

Required parameter

  • Name
    image
    Type
    file (.png, .jpg, .jpeg)
    Description

    The image file for the Passport.

Sample Request

POST
/ocr/v1/passport
1
2
3
4
5
6
import { Vision } from '@glair/vision'; const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password' }); // Image can be a file path, base64 string, or Blob/File object await vision.ocr.passport({ image: '/path/to/image/Passport.jpg' });

Sample Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{ "status": "SUCCESS", "reason": "File Successfully Read", "read": { "birth_date": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "10-01-1968", "page_index": 0, "confidence_text": 99.61, "value_original": "680110" }, "birth_date_hash": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "6", "page_index": 0, "confidence_text": 99.61, "value_original": "6" }, "country": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "PRK", "page_index": 0, "confidence_text": 99.61, "value_original": "PRK" }, "doc_number": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "556130001", "page_index": 0, "confidence_text": 99.61, "value_original": "556130001" }, "doc_number_hash": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "3", "page_index": 0, "confidence_text": 99.61, "value_original": "3" }, "document_type": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "PP", "page_index": 0, "confidence_text": 99.61, "value_original": "PP" }, "expiry_date": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "23-01-2014", "page_index": 0, "confidence_text": 99.61, "value_original": "140123" }, "expiry_date_hash": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "5", "page_index": 0, "confidence_text": 99.61, "value_original": "5" }, "final_hash": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "0", "page_index": 0, "confidence_text": 99.61, "value_original": "0" }, "name": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "JUNGRYONG", "page_index": 0, "confidence_text": 99.61, "value_original": "JUNGRYONG" }, "nationality": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "PRK", "page_index": 0, "confidence_text": 99.61, "value_original": "PRK" }, "optional_data": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "", "page_index": 0, "confidence_text": 99.61, "value_original": "" }, "optional_data_hash": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "<", "page_index": 0, "confidence_text": 99.61, "value_original": "<" }, "sex": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "M", "page_index": 0, "confidence_text": 99.61, "value_original": "M" }, "surname": { "confidence": 84.77, "polygon": [ [25, 502], [755, 502], [755, 577], [25, 577] ], "value": "YU", "page_index": 0, "confidence_text": 99.61, "value_original": "YU" } } }

Request ID

An associated request identifier is generated for every request made to this endpoint. This value can be found in the response headers under Request-Id


Responses

Various responses for this endpoint, in addition to general responses specified in Errors.

200 - OK

Request with readable Passport image

Response

1
2
3
4
5
{ "status": "SUCCESS", "reason": "File successfully read.", //..., }

200 - OK

Request with non Passport image

Response

1
2
3
4
5
{ "status": "SUCCESS", "reason": "File successfully read. Some fields are invalid.", //..., }

400 - Bad Request

Request without form-data image

Response

1
2
3
4
5
{ "status": "NO_FILE", "reason": "No file in request body", //..., }

415 - Unsupported Media Type

Request with non-image file format

Response

1
2
3
4
5
{ "status": "FILE_INVALID_FORMAT", "reason": "Failed to process invalid file format. Please upload the correct file format", //..., }