Extract Data Easily with our AI-Powered OCR API
TextSense OCR#
TextSense OCR is a large-volume document image text conversion solution based on deep learning AI. Use this to extract data from invoices, forms, bank statements or any other kind of document.
Available Methods#
/textsense/job/build#
Use the REST API to request OCR work on documents in various formats from the TextSense server.
Method: POST
Endpoint: /v1/textsense/job/build
Important
You should run the Background Job Check API to check the status of a TextSense OCR operation. As this is an asynchronous operation you will need to supply the jobId for the process and wait for the status value to return success
- then you will obtain the URL for the TextSense OCR output file.
“options” object#
Contains the extraJobs object.
Attribute |
Description |
Required |
---|---|---|
Defines the job details to be performed. |
yes |
“extraJobs” object#
Defines the job details for the OCR operation.
Attribute |
Description |
Required |
---|---|---|
|
This is the separator for the OCR operation. To perform OCR work, |
yes |
Option values to be applied to the OCR operation are transmitted in the form of a JSON object. |
yes |
“option” object#
Attribute |
Description |
Required |
---|---|---|
|
Set the recognition logic for OCR work. Use |
yes |
The default value is an empty json object. In addition to the basic recognition of |
yes |
|
|
Set the type of result file to be created through OCR work.
Supported output types are |
yes |
|
Set the range to perform OCR work. The default is for all pages. Examples: |
no |
“reqOption” object#
In addition to basic recognition, you can make additional settings for OCR work.
Attribute |
Description |
Required |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
This option allows you to perform special operations before OCR extraction. Keys for this are as follows:
|
no |
||||||||||||||
|
This option allows you to specify options for the desired result. Keys for this are as follows:
|
no |
||||||||||||||
|
This option allows you to temporarily change/set the value of a custom setting. You can temporarily change/set the value of
|
no |
||||||||||||||
|
This option allows you to extract data by adding special. Keys for this are as follows:
|
no |
SearchAPI.Type Object definition#
FindRow#
This is an API that collects and returns data in the same row as the target containing a specific string.
If there are multiple rows with the same content, only the first row detected is returned.
The key value of the request JSON is compared based on the word element, and may not work properly if the spacing between words is large.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindRow",
"Name" : "Test-Title",
"Key" : ["Keyword in row"]
}
]
}
FindRightRow#
This uses the same algorithm as FindRow, but returns only those positions to the right of the search target in the results.
If there are multiple rows with the same content, only the first row detected is returned.
The key value of the request JSON is compared based on the word element, and may not work properly if the spacing between words is large.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindRightRow",
"Name" : "Test-Title",
"Key" : ["Keyword in row"]
}
]
}
FindCol#
This collects and returns data in the same column as the target that contains a specific string.
If there are multiple columns with the same content, only the first detected column is returned.
The key value of the request JSON is compared based on the word element, and may not work properly if the spacing between words is large.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindCol",
"Name" : "Test-Title",
"Key" : ["Keyword in column"]
}
]
}
FindBottomCol#
This uses the same algorithm as FindCol, but only returns the results located below the search target.
If there are multiple columns with the same content, only the first detected column is returned.
The key value of the request JSON is compared based on the word element, and may not work properly if the spacing between words is large.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindBottomCol",
"Name" : "Test-Title",
"Key" : ["Keyword in column"]
}
]
}
FindWord#
This request searches for and returns data containing a specific string.
The key value of the request JSON is compared based on the word element, and may not work properly if the spacing between words is large.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindWord",
"Name" : "Test-Title",
"Key" : ["Keyword"]
}
]
}
FindLine#
This request searches for and returns data on lines that contain a specific string.
FindLine performs a similar function to FindRow, but while FindRow aims to search tables, FindLine aims to search text lines.
Therefore, we recommend using FindRow when looking for data inside a table and FindLine when looking for data in a general document outside the table.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindLine",
"Name" : "Test-Title",
"Key" : ["Keyword"]
}
]
}
FindRegion#
This request collects and returns data contained within a specific rectangular region.
The FindRegion API, unlike other APIs, contains coordinates rather than letters in the key.
The coordinates are TL (Top-Left) and BR (Bottom-Right) of the area to be recognized.
"reqOption" : {
"SearchAPI" : [
{
"Type" : "FindRegion",
"Name" : "city",
"Key" : [
[
217.218085106383,
156.75531914893617
],
[
265.19680851063833,
174.2845744680851
]
]
},{
"Type" : "FindRegion",
"Name" : "phone-number",
"Key" : [
[
428.8377659574468,
296.7154255319149
],
[
507.04787234042544,
320.9627659574469
]
]
}
]
}
Code Samples#
Payload#
{
"inputUri": "https://yourfile.pdf",
"options": {
"extraJobs": [
{
"type": "textSense",
"option": {
"reqType": "Document",
"reqOption": {
"SearchAPI": [
{
"Type": "FindRegion",
"Name": "city",
"Key": [
[
217.218085106383,
15675531914896317
],
[
265.19680851063833,
174.2845744680851
]
]
},
{
"Type": "FindRegion",
"Name": "phone-number",
"Key": [
[
428.8377659574468,
296.7154255319149
],
[
507.04787234042544,
320.9627659574469
]
]
}
]
},
"outputType": "json",
"pages": "all"
}
}
]
}
}
Response 2#
{
"jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA--151-300",
"error": false,
"status": 200,
"credits": 21,
"remainingCredits": 45036,
"duration": 943
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/textsense/job/build' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ' \
--data-raw '{
"inputUri": "https://yourfile.pdf",
"options": {
"extraJobs": [
{
"type": "textSense",
"option": {
"reqType": "Document",
"reqOption": {
"SearchAPI": [
{
"Type": "FindRegion",
"Name": "city",
"Key": [
[
217.218085106383,
15675531914896317
],
[
265.19680851063833,
174.2845744680851
]
]
},
{
"Type": "FindRegion",
"Name": "phone-number",
"Key": [
[
428.8377659574468,
296.7154255319149
],
[
507.04787234042544,
320.9627659574469
]
]
}
]
},
"outputType": "json",
"pages": "all"
}
}
]
}
}'
Footnotes
- 1
Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API check out the File Upload section. Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add
cache:
to enable built-in URL caching. (e.gcache:https://example.com/file1.pdf
) For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.- 2
Response codes as follows:
Code
Description
200
The request has succeeded
400
Bad input parameters
401
Unauthorized
403
Not enough credits
405
Timeout error. To process large documents or files please use asynchronous mode (set the
async
parameter totrue
) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using thepages
parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.