API Documentation

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 billing

Endpoint 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" }
ParameterTypeRequiredDescription
keystringYesThe 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 PathTypeDescription
idstringUnique identifier for the OCR result.
textstringThe extracted text from the image.
keystringThe S3 key of the processed image.
fileUrlstringPublic URL of the processed image.
createdAtstringTimestamp when the OCR was performed (ISO 8601).
wordCountnumberNumber of words in the extracted text.
tokensUsednumberNumber of tokens consumed by this operation.
languagestringDetected 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.