OCR Services API
Extract text from images using our Optical Character Recognition (OCR) service. This endpoint processes images and returns the extracted text along with metadata.
Token Usage
This endpoint consumes tokens from your token balance based on the complexity and length of the processed image.
Learn more about billingEndpoint Details
Endpoint
POST /api/ocr/process
Headers
Content-Type: application/json
X-API-Key: your_api_key_here
Request Body
{
"key": "ocr/user_id/filename.jpg"
}
Parameter | Type | Required | Description |
---|---|---|---|
key | string | Yes | The S3 key of the uploaded image file (format: ocr/user_id/filename.ext). |
Success Response (200 OK)
{
"id": "ocr-result-id",
"text": "Extracted text from the image",
"key": "ocr/user_id/filename.jpg",
"fileUrl": "https://storage.amazonaws.com/bucket-name/ocr/user_id/filename.jpg",
"createdAt": "2023-06-15T10:30:00Z",
"wordCount": 150,
"tokensUsed": 200,
"language": "en"
}
Field Descriptions
Field Path | Type | Description |
---|---|---|
id | string | Unique identifier for the OCR result. |
text | string | The extracted text from the image. |
key | string | The S3 key of the processed image. |
fileUrl | string | Public URL of the processed image. |
createdAt | string | Timestamp when the OCR was performed (ISO 8601). |
wordCount | number | Number of words in the extracted text. |
tokensUsed | number | Number of tokens consumed by this operation. |
language | string | Detected language of the extracted text (ISO 639-1 code). |
Error Responses
Example error for invalid input:
{
"error": "Invalid file key format" // Example error
}
Refer to the Error Handling section for details on other potential errors.
Code Examples
Use the following examples to integrate the OCR Services API.
curl -X POST https://your-api-domain.com/api/ocr/process \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
"key": "ocr/user_id/filename.jpg"
}'
File Upload Required
Before calling this endpoint, you must first upload your image file to our S3 storage using the File Upload API. See the File Upload documentation for details.