- Print
- PDF
General OCR
- Print
- PDF
The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.
Available in Classic and VPC
Recognize and extract text from all areas of an image.
Request
This section describes the request format. The method and URI are as follows:
Method | URI |
---|---|
POST | /general |
Request headers
For information about the headers common to all CLOVA OCR APIs, see CLOVA OCR request headers.
Request body
You can include the following data in the body of your request:
For Content-Type: application/json
You can include the following data in the body of your request if the request header's Content-Type
is application/json
:
Field | Type | Required | Description |
---|---|---|---|
version | String | Required | Version information
|
requestId | String | Required | Random API call UUID |
timestamp | Integer | Required | Random API call time (timestamp) |
lang | String | Optional | OCR recognition request language information
|
images | Array | Required | images details
|
enableTableDetection | Boolean | Optional | Whether to recognize table areas within document images and provide a structured form
|
For Content-Type: multipart/form-data
You can include the following data in the body of your request if the request header's Content-Type
is multipart/form-data
.
Field | Type | Required | Description |
---|---|---|---|
message | Object | Required | Request data information |
file | File | Required | OCR recognition image file |
message.version | String | Required | Version information
|
message.requestId | String | Required | Random API call UUID |
message.timestamp | Integer | Required | Random API call time (timestamp) |
message.lang | String | Optional | OCR recognition request language information
|
message.images | Array | Required | images details
|
message.enableTableDetection | Boolean | Optional | Whether to recognize table areas within document images and provide a structured form
|
images
The following describes images
.
Field | Type | Required | Description |
---|---|---|---|
format | String | Required | Image format
|
name | String | Required | Image name
|
url | String | Conditional | Image URL address
|
data | String | Conditional | Base64-encoded image data
|
Request example
The request example is as follows:
For Content-Type: application/json
The request example if the request header's Content-Type
is application/json
is as follows:
curl --location --request POST 'https://*****.apigw.ntruss.com/custom/v1/33675/8f694ccb00dbd8001e9b0fcbac****************/general' \
--header 'Content-Type: application/json' \
--header 'X-OCR-SECRET: {Secret key issued when registering the app}' \
--data '{
"version": "V2",
"requestId": "1234",
"timestamp": "1722225600000",
"lang": "ko",
"images": [
{
"format": "jpg",
"name": "demo_2",
"url": "https://www.ncloud.com/file-img/vol02/000/614/********/********_0001.jpg"
}
],
"enableTableDetection": false
}'
For Content-Type: multipart/form-data
The request example if the request header's Content-Type
is multipart/form-data
is as follows:
curl --location --request POST 'https://*****.apigw.ntruss.com/custom/v1/33675/8f694ccb00dbd8001e9b0fcbac**********************/general' \
--header 'Content-Type: multipart/form-data' \
--header 'X-OCR-SECRET: {Secret key issued when registering the app}' \
--form 'file=@"{file}.pdf"' \
--form 'message="{\"version\": \"v1\", \"requestId\": \"1234\", \"timestamp\": 1722225600000, \"lang\": \"ko\", \"images\": [{\"format\": \"pdf\", \"name\": \"covid_sample\"}]}"'
Response
This section describes the response format.
When requesting with the V2
version, the bounding
and boundingPoly
information is displayed in the response result value.
Response body
The response body includes the following data:
Field | Type | Required | Description |
---|---|---|---|
version | String | - | Version information
|
requestId | String | - | API call UUID |
timestamp | Integer | - | API call time (timestamp) |
images | Array | - | images details |
images
The following describes images
.
Field | Type | Required | Description |
---|---|---|---|
uid | String | - | Image UID
|
name | String | - | Image name
|
inferResult | String | - | Image recognition result
|
message | String | - | Result message |
validationResult | Object | - | Validity check result information |
validationResult.result | String | - | Validity check result code
|
validationResult.message | String | - | Validity check result details message
|
convertedImageInfo | Object | - | Converted image information
|
convertedImageInfo.width | Integer | - | Converted image width |
convertedImageInfo.height | Integer | - | Converted image height |
convertedImageInfo.pageIndex | Integer | - | Converted image page index |
convertedImageInfo.longImage | Boolean | - | Whether the converted image length is long
|
combineResult | Object | - | Image recognition result combination information |
combineResult.name | String | - | Image combination field name |
combineResult.text | String | - | Output value and fixed text for each image field |
tables | Array | - | Tables details |
fields | Array | - | Fields details |
tables
The following describes tables
.
Field | Type | Required | Description |
---|---|---|---|
cells | Array | - | Cells details |
inferText | String | - | Recognized text |
inferConfidence | Float | - | Confidence of recognized text
|
boundingPoly | Object | - | Bounding poly information
|
boundingPoly.vertices | Array | - | Bounding poly vertices details |
fields
The following describes fields
.
Field | Type | Required | Description |
---|---|---|---|
name | String | - | Image name
|
valueType | String | - | Input value type
|
boundingPoly | Object | - | Bounding poly information
|
boundingPoly.vertices | Array | - | Bounding poly vertices details |
inferText | String | - | Recognized text
|
inferConfidence | Float | - | Confidence of recognized text
|
type | String | - | Recognized image type
|
lineBreak | Boolean | - | Indicate whether the recognized text is the last line
|
checked | Boolean | - | Checkbox selection
|
cells
The following describes cells
.
Field | Type | Required | Description |
---|---|---|---|
boundingPoly | Object | - | Bounding poly information
|
boundingPoly.vertices | Array | - | Bounding poly vertices details |
cellTextLines | Array | - | Cell's line details |
inferConfidence | Float | - | Confidence of recognized text
|
rowSpan | Integer | - | Number of horizontal columns occupied by cells in the table (span) |
rowIndex | Integer | - | Position value of the corresponding horizontal column in the table |
columnSpan | Integer | - | Number of vertical rows occupied by cells in the table (span) |
columnIndex | Integer | - | Position value of the corresponding vertical row in the table |
cellTextLines
The following describes cellTextLines
.
Field | Type | Required | Description |
---|---|---|---|
boundingPoly | Object | - | Bounding poly information
|
boundingPoly.vertices | Array | - | Bounding poly vertices details |
inferConfidence | Float | - | Confidence of recognized text
|
cellWords | Array | - | Cell's text details |
cellWords
The following describes cellWords
.
Field | Type | Required | Description |
---|---|---|---|
boundingPoly | Object | - | Bounding poly information
|
boundingPoly.vertices | Array | - | Bounding poly vertices details |
inferConfidence | Float | - | Confidence of recognized text
|
inferText | String | - | Recognized text |
vertices
The following describes vertices
.
Field | Type | Required | Description |
---|---|---|---|
x | Float | - | Bounding poly X-axis coordinate value |
y | Float | - | Bounding poly Y-axis coordinate value |
Response status codes
For information about the HTTP status codes common to all CLOVA OCR APIs, see Common CLOVA OCR response status codes.
Response example
The response example is as follows:
If version
is V2
The response example when version
is V2
is as follows.
{
"version": "V2",
"requestId": "string",
"timestamp": 1576569034247,
"images": [{
"uid": "9fd73a6aacad4025b3099a36ee55aacd",
"name": "medium",
"inferResult": "SUCCESS",
"message": "SUCCESS",
"validationResult": {
"result": "NO_REQUESTED"
},
"convertedImageInfo": {
"width": 1224,
"height": 1584,
"pageIndex": 0,
"longImage": false
},
"fields": [{
"valueType": "ALL",
"inferText": "How beautiful",
"inferConfidence": 0.99992156,
"type": "NORMAL",
"lineBreak": true,
"boundingPoly": {
"vertices": [{
"x": 2713.7295,
"y": 1277.0492
}, {
"x": 2713.7295,
"y": 977.7408
}, {
"x": 2841.4343,
"y": 977.7408
}, {
"x": 2841.4343,
"y": 1277.0492
}]
}
},
{
"valueType": "ALL",
"inferText": "this",
"inferConfidence": 0.99958915,
"type": "NORMAL",
"lineBreak": false,
"boundingPoly": {
"vertices": [{
"x": 2314.6516,
"y": 1468.6066
}, {
"x": 2314.6516,
"y": 1328.9293
}, {
"x": 2426.3936,
"y": 1328.9293
}, {
"x": 2426.3936,
"y": 1468.6066
}]
}
},
{
"valueType": "ALL",
"inferText": "world is",
"inferConfidence": 0.9998707,
"type": "NORMAL",
"lineBreak": false,
"boundingPoly": {
"vertices": [{
"x": 2314.6516,
"y": 1604.2931
}, {
"x": 2314.6516,
"y": 1460.625
}, {
"x": 2430.3843,
"y": 1460.625
}, {
"x": 2430.3843,
"y": 1604.2931
}]
}
}
]
}]
}
If version
is V1
The response example when version
is V1
is as follows.
{
"version": "v1",
"requestId": "1234",
"timestamp": 1724821610657,
"images": [
{
"uid": "{uid}",
"name": "covid_demo",
"inferResult": "SUCCESS",
"message": "SUCCESS",
"validationResult": {
"result": "NO_REQUESTED"
},
"fields": [
{
"valueType": "ALL",
"boundingPoly": {
"vertices": [
{
"x": 581.0,
"y": 123.0
},
{
"x": 650.0,
"y": 123.0
},
{
"x": 650.0,
"y": 149.0
},
{
"x": 581.0,
"y": 149.0
}
]
},
"inferText": "Cultivating",
"inferConfidence": 0.9985
},
{
"valueType": "ALL",
"boundingPoly": {
"vertices": [
{
"x": 399.0,
"y": 1168.0
},
{
"x": 790.0,
"y": 1168.0
},
{
"x": 790.0,
"y": 1215.0
},
{
"x": 399.0,
"y": 1215.0
}
]
},
"inferText": "Principal of Seoul Elementary School",
"inferConfidence": 0.9997
}
]
}
]
}