API Documentation
The Convertorio API allows you to integrate image conversion capabilities directly into your applications. Convert images between multiple formats programmatically with a simple RESTful API.
https://api.convertorio.com/v1
Supported Formats
The API supports conversion between the following image formats:
NEW: Use target_format: "ocr" to extract text from images with advanced AI-powered OCR.
Node.js SDK (Recommended)
The easiest way to integrate Convertorio into your Node.js application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
npm install convertorio-sdk
Installation
npm install convertorio-sdk
Basic Usage
const ConvertorioClient = require('convertorio-sdk');
const client = new ConvertorioClient({
apiKey: 'your_api_key_here'
});
// Convert an image
const result = await client.convertFile({
inputPath: './image.png',
targetFormat: 'jpg',
outputPath: './image.jpg'
});
console.log('Conversion completed:', result.jobId);
With Progress Events
client.on('progress', (data) => {
console.log(`${data.step}: ${data.message}`);
});
client.on('complete', (result) => {
console.log(`Done in ${result.processingTime}ms`);
});
await client.convertFile({
inputPath: './document.pdf',
targetFormat: 'png'
});
Advanced Conversion Options (v1.1.0+)
Control aspect ratio, crop strategy, quality, and icon sizes using conversionMetadata:
// Example 1: Convert to 16:9 widescreen
await client.convertFile({
inputPath: './photo.jpg',
targetFormat: 'webp',
conversionMetadata: {
aspect_ratio: '16:9', // 1:1, 4:3, 16:9, 9:16, 21:9, custom
crop_strategy: 'crop-center', // fit, crop-center, crop-top, etc.
quality: 85 // 1-100 (for JPG, WebP, AVIF)
}
});
// Example 2: Create square image for Instagram
await client.convertFile({
inputPath: './photo.jpg',
targetFormat: 'jpg',
conversionMetadata: {
aspect_ratio: '1:1',
crop_strategy: 'crop-center',
quality: 90
}
});
// Example 3: Create ICO favicon
await client.convertFile({
inputPath: './logo.png',
targetFormat: 'ico',
conversionMetadata: {
icon_size: 32, // 16, 32, 48, 64, 128, 256
crop_strategy: 'crop-center'
}
});
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
// Extract text from an invoice image
const result = await client.convertFile({
inputPath: './invoice.jpg',
targetFormat: 'ocr',
outputPath: './invoice.json',
conversionMetadata: {
ocr_format: 'json',
ocr_instructions: 'Extract invoice data including date, items, and total'
}
});
console.log(`Tokens used: ${result.tokensUsed}`);
console.log(`Extracted text saved to: ${result.outputPath}`);
Python SDK (Recommended)
The easiest way to integrate Convertorio into your Python application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
pip install convertorio-sdk
Installation
pip install convertorio-sdk
Basic Usage
from convertorio_sdk import ConvertorioClient
client = ConvertorioClient(api_key='your_api_key_here')
# Convert an image
result = client.convert_file(
input_path='./image.png',
target_format='jpg',
output_path='./image.jpg'
)
print(f'Conversion completed: {result["job_id"]}')
With Progress Events
def on_progress(data):
print(f"{data['step']}: {data['message']}")
def on_complete(result):
print(f"Done in {result['processing_time']}ms")
client.on('progress', on_progress)
client.on('complete', on_complete)
result = client.convert_file(
input_path='./document.pdf',
target_format='png'
)
Advanced Conversion Options (v1.2.0+)
Control aspect ratio, crop strategy, quality, icon sizes, and resize dimensions using conversion_metadata:
# Example 1: Convert to 16:9 widescreen
result = client.convert_file(
input_path='./photo.jpg',
target_format='webp',
conversion_metadata={
'aspect_ratio': '16:9', # 1:1, 4:3, 16:9, 9:16, 21:9, custom
'crop_strategy': 'crop-center', # fit, crop-center, crop-top, etc.
'quality': 85 # 1-100 (for JPG, WebP, AVIF)
}
)
# Example 2: Create square image for Instagram
result = client.convert_file(
input_path='./photo.jpg',
target_format='jpg',
conversion_metadata={
'aspect_ratio': '1:1',
'crop_strategy': 'crop-center',
'quality': 90
}
)
# Example 3: Create ICO favicon
result = client.convert_file(
input_path='./logo.png',
target_format='ico',
conversion_metadata={
'icon_size': 32, # 16, 32, 48, 64, 128, 256
'crop_strategy': 'crop-center'
}
)
# Example 4: Resize image (v1.2.0+)
result = client.convert_file(
input_path='./photo.jpg',
target_format='jpg',
conversion_metadata={
'resize_width': 800, # Width in pixels (1-10000)
'resize_height': 600, # Height in pixels (1-10000)
'quality': 90
}
)
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
# Extract text from a receipt image
result = client.convert_file(
input_path='./receipt.jpg',
target_format='ocr',
output_path='./receipt.txt',
conversion_metadata={
'ocr_format': 'txt',
'ocr_instructions': 'Extract all text from this receipt'
}
)
print(f"Tokens used: {result['tokens_used']}")
print(f"Extracted text saved to: {result['output_path']}")
PHP SDK (Recommended)
The easiest way to integrate Convertorio into your PHP application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
composer require convertorio/sdk
Installation
composer require convertorio/sdk
Basic Usage
<?php
require 'vendor/autoload.php';
use Convertorio\SDK\ConvertorioClient;
$client = new ConvertorioClient('your_api_key_here');
// Convert an image
$result = $client->convertFile(
'./image.png',
'jpg',
'./image.jpg'
);
echo "Conversion completed: {$result['job_id']}";
With Progress Events
$client->on('progress', function($data) {
echo "{$data['step']}: {$data['message']}\n";
});
$client->on('complete', function($result) {
echo "Done in {$result['processing_time']}ms\n";
});
$result = $client->convertFile(
'./document.pdf',
'png'
);
Advanced Conversion Options (v1.2.0+)
Control aspect ratio, crop strategy, quality, icon sizes, and resize dimensions using $conversionMetadata:
// Example 1: Convert to 16:9 widescreen
$result = $client->convertFile(
'./photo.jpg',
'webp',
null,
[
'aspect_ratio' => '16:9', // 1:1, 4:3, 16:9, 9:16, 21:9, custom
'crop_strategy' => 'crop-center', // fit, crop-center, crop-top, etc.
'quality' => 85 // 1-100 (for JPG, WebP, AVIF)
]
);
// Example 2: Create square image for Instagram
$result = $client->convertFile(
'./photo.jpg',
'jpg',
null,
[
'aspect_ratio' => '1:1',
'crop_strategy' => 'crop-center',
'quality' => 90
]
);
// Example 3: Create ICO favicon
$result = $client->convertFile(
'./logo.png',
'ico',
null,
[
'icon_size' => 32, // 16, 32, 48, 64, 128, 256
'crop_strategy' => 'crop-center'
]
);
// Example 4: Resize image (v1.2.0+)
$result = $client->convertFile(
'./photo.jpg',
'jpg',
null,
[
'resize_width' => 800, // Width in pixels (1-10000)
'resize_height' => 600, // Height in pixels (1-10000)
'quality' => 90
]
);
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
// Extract text from a document image
$result = $client->convertFile(
'./document.jpg',
'ocr',
'./document.json',
[
'ocr_format' => 'json',
'ocr_instructions' => 'Extract form data as structured JSON'
]
);
echo "Tokens used: " . $result['tokens_used'] . "\n";
echo "Extracted text saved to: " . $result['output_path'];
Go SDK (Recommended)
The easiest way to integrate Convertorio into your Go application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
go install github.com/SedeSoft/convertorio-sdk/libs/go
Installation
go install github.com/SedeSoft/convertorio-sdk/libs/go
Basic Usage
package main
import (
"fmt"
"log"
convertorio "github.com/SedeSoft/convertorio-sdk/libs/go"
)
func main() {
client := convertorio.NewClient(convertorio.ClientConfig{
APIKey: "your_api_key_here",
})
result, err := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./image.png",
TargetFormat: "jpg",
OutputPath: "./image.jpg",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Conversion completed: %s\n", result.JobID)
}
With Progress Events
client.On("progress", func(data map[string]interface{}) {
fmt.Printf("%s: %s\n", data["step"], data["message"])
})
client.On("complete", func(data map[string]interface{}) {
fmt.Printf("Done in %dms\n", data["processing_time"])
})
result, err := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./document.pdf",
TargetFormat: "png",
})
Advanced Conversion Options (v1.2.0+)
Control aspect ratio, crop strategy, quality, icon sizes, and resize dimensions using ConversionMetadata:
// Example 1: Convert to 16:9 widescreen
result, _ := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./photo.jpg",
TargetFormat: "webp",
ConversionMetadata: map[string]interface{}{
"aspect_ratio": "16:9", // 1:1, 4:3, 16:9, 9:16, 21:9, custom
"crop_strategy": "crop-center", // fit, crop-center, crop-top, etc.
"quality": 85, // 1-100 (for JPG, WebP, AVIF)
},
})
// Example 2: Create square image for Instagram
result, _ := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./photo.jpg",
TargetFormat: "jpg",
ConversionMetadata: map[string]interface{}{
"aspect_ratio": "1:1",
"crop_strategy": "crop-center",
"quality": 90,
},
})
// Example 3: Create ICO favicon
result, _ := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./logo.png",
TargetFormat: "ico",
ConversionMetadata: map[string]interface{}{
"icon_size": 32, // 16, 32, 48, 64, 128, 256
"crop_strategy": "crop-center",
},
})
// Example 4: Resize image (v1.2.0+)
result, _ := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./photo.jpg",
TargetFormat: "jpg",
ConversionMetadata: map[string]interface{}{
"resize_width": 800, // Width in pixels (1-10000)
"resize_height": 600, // Height in pixels (1-10000)
"quality": 90,
},
})
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
// Extract text from an invoice image
result, err := client.ConvertFile(convertorio.ConvertFileOptions{
InputPath: "./invoice.jpg",
TargetFormat: "ocr",
OutputPath: "./invoice.json",
ConversionMetadata: map[string]interface{}{
"ocr_format": "json",
"ocr_instructions": "Extract invoice items and total",
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Tokens used: %d\n", result.TokensUsed)
fmt.Printf("Extracted text saved to: %s\n", result.OutputPath)
Java SDK (Recommended)
The easiest way to integrate Convertorio into your Java application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
com.sedesoft:convertorio-sdk:1.2.0 to your pom.xml (Requires Java 11+)
Installation
Maven
<dependency>
<groupId>com.sedesoft</groupId>
<artifactId>convertorio-sdk</artifactId>
<version>1.2.0</version>
</dependency>
Gradle
implementation 'com.sedesoft:convertorio-sdk:1.2.0'
Basic Usage
import com.sedesoft.convertorio.*;
public class Example {
public static void main(String[] args) {
try {
ConvertorioClient client = new ConvertorioClient(
ClientConfig.builder()
.apiKey("your_api_key_here")
.build()
);
ConversionResult result = client.convertFile(
ConversionOptions.builder()
.inputPath("./image.png")
.targetFormat("jpg")
.outputPath("./image.jpg")
.build()
);
System.out.println("Conversion completed: " + result.getJobId());
} catch (ConvertorioException e) {
System.err.println("Error: " + e.getMessage());
}
}
}
With Progress Events
client.on("progress", data -> {
System.out.println(data.getString("step") + ": " + data.getString("message"));
});
client.on("complete", data -> {
System.out.println("Done in " + data.getLong("processingTime") + "ms");
});
ConversionResult result = client.convertFile(
ConversionOptions.builder()
.inputPath("./document.pdf")
.targetFormat("png")
.build()
);
Advanced Conversion Options (v1.2.0+)
Control aspect ratio, crop strategy, quality, and icon sizes using conversionMetadata:
import java.util.HashMap;
import java.util.Map;
// Example 1: Convert to 16:9 widescreen
Map<String, Object> metadata1 = new HashMap<>();
metadata1.put("aspect_ratio", "16:9"); // 1:1, 4:3, 16:9, 9:16, 21:9, custom
metadata1.put("crop_strategy", "crop-center"); // fit, crop-center, crop-top, etc.
metadata1.put("quality", 85); // 1-100 (for JPG, WebP, AVIF)
ConversionResult result1 = client.convertFile(
ConversionOptions.builder()
.inputPath("./photo.jpg")
.targetFormat("webp")
.conversionMetadata(metadata1)
.build()
);
// Example 2: Create square image for Instagram
Map<String, Object> metadata2 = new HashMap<>();
metadata2.put("aspect_ratio", "1:1");
metadata2.put("crop_strategy", "crop-center");
metadata2.put("quality", 90);
ConversionResult result2 = client.convertFile(
ConversionOptions.builder()
.inputPath("./photo.jpg")
.targetFormat("jpg")
.conversionMetadata(metadata2)
.build()
);
// Example 3: Create ICO favicon
Map<String, Object> metadata3 = new HashMap<>();
metadata3.put("icon_size", 32); // 16, 32, 48, 64, 128, 256
metadata3.put("crop_strategy", "crop-center");
ConversionResult result3 = client.convertFile(
ConversionOptions.builder()
.inputPath("./logo.png")
.targetFormat("ico")
.conversionMetadata(metadata3)
.build()
);
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
// Extract text from a receipt image
Map metadata = Map.of(
"ocr_format", "txt",
"ocr_instructions", "Extract receipt items and total"
);
ConversionResult result = client.convertFile(
ConversionOptions.builder()
.inputPath("./receipt.jpg")
.targetFormat("ocr")
.outputPath("./receipt.txt")
.conversionMetadata(metadata)
.build()
);
System.out.println("Tokens used: " + result.getTokensUsed());
System.out.println("Extracted text saved to: " + result.getOutputPath());
Ruby SDK (Recommended)
The easiest way to integrate Convertorio into your Ruby application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you.
gem install convertorio-sdk (Requires Ruby 2.7+)
Installation
Using gem
gem install convertorio-sdk
Using Bundler (Gemfile)
gem 'convertorio-sdk', '~> 1.2'
Basic Usage
require 'convertorio'
client = Convertorio::Client.new(api_key: 'your_api_key_here')
result = client.convert_file(
input_path: './image.png',
target_format: 'jpg',
output_path: './image.jpg'
)
puts "Conversion completed: #{result[:job_id]}"
With Progress Events
client.on(:progress) do |data|
puts "#{data[:step]}: #{data[:message]}"
end
client.on(:complete) do |data|
puts "Done in #{data[:processing_time]}ms"
end
result = client.convert_file(
input_path: './document.pdf',
target_format: 'png'
)
Advanced Conversion Options (v1.2.0+)
Control aspect ratio, crop strategy, quality, and icon sizes using conversion_metadata:
# Example 1: Convert to 16:9 widescreen
result1 = client.convert_file(
input_path: './photo.jpg',
target_format: 'webp',
conversion_metadata: {
aspect_ratio: '16:9', # 1:1, 4:3, 16:9, 9:16, 21:9, custom
crop_strategy: 'crop-center', # fit, crop-center, crop-top, etc.
quality: 85 # 1-100 (for JPG, WebP, AVIF)
}
)
# Example 2: Resize and optimize
result2 = client.convert_file(
input_path: './large-photo.png',
target_format: 'jpg',
conversion_metadata: {
resize_width: 1920, # Target width in pixels
quality: 90
}
)
# Example 3: Create ICO favicon
result3 = client.convert_file(
input_path: './logo.png',
target_format: 'ico',
conversion_metadata: {
icon_size: 32, # 16, 32, 48, 64, 128, 256
crop_strategy: 'crop-center'
}
)
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
# Extract text from a form image
result = client.convert_file(
input_path: './form.jpg',
target_format: 'ocr',
output_path: './form.txt',
conversion_metadata: {
ocr_format: 'txt',
ocr_instructions: 'Extract all text preserving formatting'
}
)
puts "Tokens used: #{result[:tokens_used]}"
puts "Extracted text saved to: #{result[:output_path]}"
.NET SDK (Recommended)
The easiest way to integrate Convertorio into your .NET application is using our official SDK. It handles all the complexity of file uploads, polling, and downloads for you with a modern async/await API.
Installation
dotnet add package Convertorio.SDK
Or via Package Manager Console in Visual Studio:
Install-Package Convertorio.SDK
Basic Usage
using Convertorio.SDK;
using (var client = new ConvertorioClient("your_api_key_here"))
{
var result = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./image.png",
TargetFormat = "jpg"
});
Console.WriteLine($"Converted! {result.OutputPath}");
}
With Progress Events
using (var client = new ConvertorioClient("your_api_key_here"))
{
// Subscribe to events
client.ConversionStart += (sender, e) =>
Console.WriteLine($"Starting: {e.JobId}");
client.ConversionProgress += (sender, e) =>
Console.WriteLine($"{e.Step}: {e.Message}");
client.ConversionStatus += (sender, e) =>
Console.WriteLine($"Status: {e.Status}");
client.ConversionComplete += (sender, e) =>
Console.WriteLine($"Done in {e.ProcessingTime}ms");
var result = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./image.png",
TargetFormat = "jpg"
});
}
Advanced Options
Control aspect ratio, crop strategy, quality, and icon sizes using ConversionMetadata:
// Example 1: Convert to 16:9 widescreen
var result1 = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./photo.jpg",
TargetFormat = "webp",
ConversionMetadata = new ConversionMetadata
{
AspectRatio = "16:9", // 1:1, 4:3, 16:9, 9:16, 21:9, custom
CropStrategy = "crop-center" // fit, crop-center, crop-top, etc.
}
});
// Example 2: Convert to square with specific quality
var result2 = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./photo.jpg",
TargetFormat = "jpg",
ConversionMetadata = new ConversionMetadata
{
AspectRatio = "1:1",
CropStrategy = "crop-center",
Quality = 85
}
});
// Example 3: Create an ICO file with multiple sizes
var result3 = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./logo.png",
TargetFormat = "ico",
ConversionMetadata = new ConversionMetadata
{
IconSizes = new[] { 16, 32, 48, 64 }
}
});
OCR Text Extraction (NEW)
Extract text from images using AI-powered OCR:
// Extract text from an invoice image
using (var client = new ConvertorioClient(apiKey))
{
var result = await client.ConvertFileAsync(new ConversionOptions
{
InputPath = "./invoice.jpg",
TargetFormat = "ocr",
OutputPath = "./invoice.json",
ConversionMetadata = new ConversionMetadata
{
OcrFormat = "json",
OcrInstructions = "Extract invoice data with line items"
}
});
Console.WriteLine($"Tokens used: {result.TokensUsed}");
Console.WriteLine($"Extracted text saved to: {result.OutputPath}");
}
Authentication
All API requests require authentication using an API key. You can obtain your API key from your account dashboard.
Using Your API Key
Include your API key in the Authorization header of every request:
Authorization: Bearer cv_your_api_key_here
Quick Start
Here's a simple example to convert an image from JPG to PNG using the HTTP API directly:
const apiKey = 'cv_your_api_key_here';
const baseUrl = 'https://api.convertorio.com/v1';
// Step 1: Request upload URL
const uploadResponse = await fetch(`${baseUrl}/convert/upload-url`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filename: 'image.jpg',
source_format: 'jpg',
target_format: 'png',
file_size: file.size
})
});
const { job_id, upload_url } = await uploadResponse.json();
// Step 2: Upload file to S3
await fetch(upload_url, {
method: 'PUT',
body: file
});
// Step 3: Confirm upload
await fetch(`${baseUrl}/convert/confirm`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ job_id })
});
// Step 4: Poll for completion
const pollStatus = async () => {
const statusResponse = await fetch(`${baseUrl}/jobs/${job_id}`, {
headers: { 'Authorization': `Bearer ${apiKey}` }
});
const { job } = await statusResponse.json();
if (job.status === 'completed') {
console.log('Download URL:', job.download_url);
return job.download_url;
} else if (job.status === 'failed') {
throw new Error(job.error_message);
}
// Poll again in 2 seconds
await new Promise(r => setTimeout(r, 2000));
return pollStatus();
};
const downloadUrl = await pollStatus();
Conversion Flow
The conversion process follows these steps:
Request Upload URL
Call POST /v1/convert/upload-url with file details to receive a presigned S3 upload URL.
Upload File
Upload your file directly to S3 using the presigned URL (PUT request).
Confirm Upload
Call POST /v1/convert/confirm to queue the conversion job.
Poll Status
Poll GET /v1/jobs/{id} until status is completed or failed.
Download Result
Use the download_url from the completed job to download the converted image.
Request Upload URL
Request a presigned URL for uploading a file to storage.
Request Body
{
"filename": "image.jpg",
"source_format": "jpg",
"target_format": "png",
"file_size": 1048576,
"conversion_metadata": {
"aspect_ratio": "16:9",
"crop_strategy": "crop-center",
"quality": 85,
"icon_size": 32
}
}
Параметры
| Parameter | Type | Required | Description |
|---|---|---|---|
filename |
string | Yes | Original filename |
source_format |
string | Yes | Source format (jpg, png, webp, avif, heic, ico, pdf, ai, eps, psd, raw, etc.) |
target_format |
string | Yes | Target format (jpg, png, webp, avif, heic, ico, pdf, svg, ocr, etc.) |
file_size |
integer | Yes | File size in bytes (max: 20 MB) |
conversion_metadata |
object | No | Advanced conversion options (see below) |
Advanced Conversion Options
The conversion_metadata object supports the following optional parameters:
| Option | Type | Values | Description |
|---|---|---|---|
aspect_ratio |
string | original, 1:1, 4:3, 16:9, 9:16, 21:9, custom (e.g., "16:10") | Target aspect ratio for the output image |
crop_strategy |
string | fit, crop-center, crop-top, crop-bottom, crop-left, crop-right | How to handle aspect ratio changes. fit adds padding, crop-* removes excess |
quality |
integer | 1-100 | Compression quality for lossy formats (JPG, WebP, AVIF). Default: 85 |
icon_size |
integer | 16, 32, 48, 64, 128, 256 | Icon size in pixels for ICO format (only when target_format is "ico") |
ocr_format |
string | txt, json | Output format for OCR extraction (only when target_format is "ocr"). Default: txt |
ocr_instructions |
string | Any text | Optional instructions for AI-powered OCR (e.g., "Extract table data", "Focus on handwritten text") |
OCR Text Extraction
To extract text from images using AI-powered OCR, set target_format to "ocr". This uses advanced AI for high-accuracy text recognition.
{
"filename": "document.jpg",
"source_format": "jpg",
"target_format": "ocr",
"file_size": 2048576,
"conversion_metadata": {
"ocr_format": "json",
"ocr_instructions": "Extract all text and preserve formatting. Identify tables if present."
}
}
Important: OCR jobs consume AI tokens and will be charged accordingly. The tokens_used field in the job response shows the number of tokens consumed. Regular image conversions do not use tokens.
Ответ
{
"success": true,
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"upload_url": "https://s3.amazonaws.com/...",
"expires_in": 600
}
Confirm Upload
Confirm that the file has been uploaded and queue the conversion job.
Request Body
{
"job_id": "550e8400-e29b-41d4-a716-446655440000"
}
Ответ
{
"success": true,
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"message": "Job queued for processing"
}
Get Job Status
Retrieve the current status of a conversion job.
Path Параметры
| Parameter | Type | Description |
|---|---|---|
id |
string | Job ID (UUID) |
Ответ
{
"success": true,
"job": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"original_filename": "image.jpg",
"source_format": "jpg",
"target_format": "png",
"file_size": 1048576,
"points_cost": 1,
"points_used": 1,
"tokens_used": 0,
"processing_time_ms": 1234,
"created_at": "2025-01-19T10:00:00Z",
"completed_at": "2025-01-19T10:00:02Z",
"download_url": "https://s3.amazonaws.com/...",
"can_download": true,
"is_expired": false
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
id |
string | Job UUID identifier |
status |
string | Current job status (see table below) |
points_cost |
integer | Points required for this conversion (usually 1) |
points_used |
integer | Actual points deducted (0 if used free tier) |
tokens_used |
integer | AI tokens consumed for OCR/analysis (0 for regular conversions) |
processing_time_ms |
integer | Processing duration in milliseconds |
download_url |
string | Presigned URL to download converted file (only when completed) |
can_download |
boolean | Whether the file is ready for download |
is_expired |
boolean | Whether the job has expired (files expire after 7 days) |
Job Statuses
| Status | Description |
|---|---|
uploading |
Waiting for file upload |
queued |
Queued for processing |
processing |
Currently being converted |
completed |
Successfully converted (download_url available) |
failed |
Conversion failed (error_message available) |
OCR Job Example
Example response for an OCR text extraction job showing tokens_used:
{
"success": true,
"job": {
"id": "650e8400-e29b-41d4-a716-446655440001",
"status": "completed",
"original_filename": "invoice.jpg",
"source_format": "jpg",
"target_format": "ocr",
"file_size": 1845120,
"points_cost": 1,
"points_used": 1,
"tokens_used": 1247,
"processing_time_ms": 3456,
"created_at": "2025-01-19T14:30:00Z",
"completed_at": "2025-01-19T14:30:03Z",
"download_url": "https://s3.amazonaws.com/.../output.json",
"can_download": true,
"is_expired": false
}
}
Note: The output file will be in .txt or .json format depending on the ocr_format specified in conversion_metadata.
List Jobs
Retrieve a list of your conversion jobs.
Query Параметры
| Parameter | Type | Default | Description |
|---|---|---|---|
limit |
integer | 50 | Number of jobs to return (max: 100) |
offset |
integer | 0 | Number of jobs to skip |
status |
string | - | Filter by status (optional) |
Ответ
{
"success": true,
"jobs": [...],
"count": 10,
"pagination": {
"limit": 50,
"offset": 0
}
}
Get Account Info
Retrieve your account information and usage statistics.
Ответ
{
"success": true,
"account": {
"id": "user-id",
"email": "user@example.com",
"name": "John Doe",
"plan": "free",
"points": 100,
"daily_conversions_remaining": 3,
"total_conversions": 47
}
}
✨ OCR & AI Text Extraction
Extract text from images using advanced AI-powered OCR. Perfect for digitizing documents, receipts, invoices, and handwritten notes.
What is OCR?
OCR (Optical Character Recognition) converts images containing text into machine-readable text. Our AI-powered OCR can:
- Extract printed text from scanned documents, photos, and screenshots
- Recognize handwritten text with high accuracy
- Preserve formatting including tables, lists, and structure
- Handle multiple languages automatically
- Process complex layouts with custom instructions
Supported Input Formats
You can perform OCR on any of the following image formats:
How to Use OCR
To extract text from an image, set target_format to "ocr" in your conversion request.
Basic OCR Request
POST /v1/convert/upload-url
{
"filename": "document.jpg",
"source_format": "jpg",
"target_format": "ocr",
"file_size": 2048576
}
OCR Options
Use conversion_metadata to customize the OCR output:
| Option | Type | Values | Description |
|---|---|---|---|
ocr_format |
string | txt, json |
Output format. Use json for structured data. Default: txt |
ocr_instructions |
string | Any text | Custom instructions for the AI (e.g., "Extract only table data", "Focus on handwritten notes") |
Advanced OCR with Instructions
{
"filename": "invoice.jpg",
"source_format": "jpg",
"target_format": "ocr",
"file_size": 2048576,
"conversion_metadata": {
"ocr_format": "json",
"ocr_instructions": "Extract all text and identify invoice items in a table. Include date, total, and line items."
}
}
OCR Response
The job response includes tokens_used showing AI tokens consumed:
{
"success": true,
"job": {
"id": "650e8400-e29b-41d4-a716-446655440001",
"status": "completed",
"original_filename": "invoice.jpg",
"source_format": "jpg",
"target_format": "ocr",
"points_used": 1,
"tokens_used": 1247,
"processing_time_ms": 3456,
"download_url": "https://s3.amazonaws.com/.../output.json"
}
}
Pricing & Tokens
OCR jobs consume AI tokens in addition to conversion points. The number of tokens depends on image complexity, resolution, and text density.
Token Usage
| Image Type | Typical Tokens | Example |
|---|---|---|
| Simple text document | 500 - 1,500 tokens | Receipt, business card |
| Complex document | 1,500 - 3,000 tokens | Invoice with tables, multi-page PDF |
| High-resolution scan | 3,000 - 6,000 tokens | Magazine page, detailed form |
Cost Breakdown
- Conversion Points: 1 point (same as regular conversions)
- AI Tokens: Charged based on actual tokens used (shown in
tokens_usedfield) - Free Tier: OCR uses your free daily conversions, but tokens are still tracked
tokens_used field in the job response shows exactly how many tokens were consumed. Regular image conversions use 0 tokens.
OCR Examples
Node.js SDK
const Convertorio = require('convertorio-sdk');
const client = new Convertorio('your-api-key');
// Basic OCR
const result = await client.convertFile({
inputPath: './receipt.jpg',
targetFormat: 'ocr',
outputPath: './receipt.txt'
});
console.log(`Tokens used: ${result.tokensUsed}`);
// Advanced OCR with JSON output
const invoice = await client.convertFile({
inputPath: './invoice.jpg',
targetFormat: 'ocr',
outputPath: './invoice.json',
conversionMetadata: {
ocr_format: 'json',
ocr_instructions: 'Extract invoice data including date, items, and total'
}
});
console.log(`Extracted data saved to invoice.json`);
console.log(`Tokens used: ${invoice.tokensUsed}`);
Python SDK
from convertorio import Convertorio
client = Convertorio('your-api-key')
# Basic OCR
result = client.convert_file(
input_path='./document.jpg',
target_format='ocr',
output_path='./document.txt'
)
print(f'Tokens used: {result["tokens_used"]}')
# Advanced OCR with custom instructions
result = client.convert_file(
input_path='./form.jpg',
target_format='ocr',
output_path='./form.json',
conversion_metadata={
'ocr_format': 'json',
'ocr_instructions': 'Extract form fields and values as JSON'
}
)
print(f'Extracted: {result["tokens_used"]} tokens')
cURL Example
# Step 1: Request upload URL for OCR
curl -X POST https://api.convertorio.com/v1/convert/upload-url \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "invoice.jpg",
"source_format": "jpg",
"target_format": "ocr",
"file_size": 2048576,
"conversion_metadata": {
"ocr_format": "json",
"ocr_instructions": "Extract invoice items and total"
}
}'
# Step 2: Upload file (returns job_id and upload_url)
curl -X PUT "UPLOAD_URL_FROM_STEP_1" \
--upload-file invoice.jpg
# Step 3: Confirm upload
curl -X POST https://api.convertorio.com/v1/convert/confirm \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_id": "JOB_ID_FROM_STEP_1"}'
# Step 4: Check status (poll until completed)
curl https://api.convertorio.com/v1/jobs/JOB_ID \
-H "Authorization: Bearer YOUR_API_KEY"
# Response includes tokens_used field
# Download extracted text from download_url
Error Codes
The API uses standard HTTP status codes and returns errors in JSON format:
{
"success": false,
"error": "Error message description"
}
Common Status Codes
| Code | Description |
|---|---|
200 |
Success |
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid or missing API key |
402 |
Payment Required - Insufficient credits |
403 |
Forbidden - Access denied to resource |
404 |
Not Found - Resource doesn't exist |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error |
Rate Limits
The following rate limits apply to API usage:
Free Tier
- 5 conversions per day
- Maximum file size: 20 MB
- No concurrent conversions limit
Paid Tier (Points)
- Unlimited conversions (1 point per conversion)
- Maximum file size: 20 MB
- No rate limits
When you exceed the free tier limit, you can purchase points from your account dashboard to continue converting.
Code Examples
Python Пример
import requests
import time
API_KEY = 'cv_your_api_key_here'
BASE_URL = 'https://api.convertorio.com/v1'
def convert_image(file_path, source_format, target_format):
# Step 1: Request upload URL
with open(file_path, 'rb') as f:
file_size = len(f.read())
response = requests.post(
f'{BASE_URL}/convert/upload-url',
headers={'Authorization': f'Bearer {API_KEY}'},
json={
'filename': file_path.split('/')[-1],
'source_format': source_format,
'target_format': target_format,
'file_size': file_size
}
)
data = response.json()
job_id = data['job_id']
upload_url = data['upload_url']
# Step 2: Upload file
with open(file_path, 'rb') as f:
requests.put(upload_url, data=f)
# Step 3: Confirm upload
requests.post(
f'{BASE_URL}/convert/confirm',
headers={'Authorization': f'Bearer {API_KEY}'},
json={'job_id': job_id}
)
# Step 4: Poll for completion
while True:
response = requests.get(
f'{BASE_URL}/jobs/{job_id}',
headers={'Authorization': f'Bearer {API_KEY}'}
)
job = response.json()['job']
if job['status'] == 'completed':
return job['download_url']
elif job['status'] == 'failed':
raise Exception(job['error_message'])
time.sleep(2)
# Usage
download_url = convert_image('image.jpg', 'jpg', 'png')
print(f'Download URL: {download_url}')
Node.js Пример
const fs = require('fs');
const axios = require('axios');
const API_KEY = 'cv_your_api_key_here';
const BASE_URL = 'https://api.convertorio.com/v1';
async function convertImage(filePath, sourceFormat, targetFormat) {
// Step 1: Request upload URL
const fileBuffer = fs.readFileSync(filePath);
const filename = filePath.split('/').pop();
const uploadResponse = await axios.post(
`${BASE_URL}/convert/upload-url`,
{
filename,
source_format: sourceFormat,
target_format: targetFormat,
file_size: fileBuffer.length
},
{ headers: { 'Authorization': `Bearer ${API_KEY}` }}
);
const { job_id, upload_url } = uploadResponse.data;
// Step 2: Upload file
await axios.put(upload_url, fileBuffer);
// Step 3: Confirm upload
await axios.post(
`${BASE_URL}/convert/confirm`,
{ job_id },
{ headers: { 'Authorization': `Bearer ${API_KEY}` }}
);
// Step 4: Poll for completion
while (true) {
const statusResponse = await axios.get(
`${BASE_URL}/jobs/${job_id}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` }}
);
const { job } = statusResponse.data;
if (job.status === 'completed') {
return job.download_url;
} else if (job.status === 'failed') {
throw new Error(job.error_message);
}
await new Promise(resolve => setTimeout(resolve, 2000));
}
}
// Usage
convertImage('image.jpg', 'jpg', 'png')
.then(url => console.log('Download URL:', url))
.catch(err => console.error('Error:', err));
cURL Пример
# Step 1: Request upload URL
curl -X POST https://api.convertorio.com/v1/convert/upload-url \
-H "Authorization: Bearer cv_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"filename": "image.jpg",
"source_format": "jpg",
"target_format": "png",
"file_size": 1048576
}'
# Step 2: Upload file (replace UPLOAD_URL with response from step 1)
curl -X PUT "UPLOAD_URL" \
--data-binary @image.jpg
# Step 3: Confirm upload (replace JOB_ID with response from step 1)
curl -X POST https://api.convertorio.com/v1/convert/confirm \
-H "Authorization: Bearer cv_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"job_id": "JOB_ID"}'
# Step 4: Check status
curl https://api.convertorio.com/v1/jobs/JOB_ID \
-H "Authorization: Bearer cv_your_api_key_here"
Need Help?
If you have questions or need assistance with the API, please visit our Support Center or contact us directly.