API

Você pode usar nosso serviço através da API RESTful.

Formato da solicitação

A solicitação deve ser enviada usando o método POST no formato JSON para o endpoint https://www.imagetotext.com/api/ocr. Você pode encontrar a lista de parâmetros de solicitação abaixo.

Nome Valor
api_key Sua chave da API. Disponível na sua página de perfil após o login.
api_secret Seu segredo da API. Disponível na sua página de perfil após o login.
image Imagem codificada em Base64

Formato da resposta

A resposta conterá resultados de reconhecimento em texto simples com código de status 200

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Vary: Accept-Encoding
Date: Wed, 23 Oct 2024 18:32:09 GMT
Connection: close

Hello

ou uma mensagem de erro com código de status 40* caso contrário.

HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Content-Length: 13
Vary: Accept-Encoding
Date: Wed, 23 Oct 2024 18:29:55 GMT
Connection: close

No text found

Exemplos

Exemplo Curl

curl -X "POST" "https://www.imagetotext.com/api/ocr" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -d $'{
    "api_key": "API_KEY",
    "api_secret": "API_SECRET",
    "image": "iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAACXBIWXMAAAsTAAALEwEAmpwYAAACfUlEQVR4nO2Yz0sqURTHlYxSMzBcuJaWLiRFhMRAXYi5kUAQBGnTMlAEfyAUiNBGSHAh6EJBEDXEtQqFqJvCTf9CMNs2lUj5fdyBJ/iUpy6Gd994P3DBO5c5dzifcc6ZkYBBFZJ/fQGMeZgQymBCKIMJoQwmhDKYEMpgQv5nIdVqFcVicekax3G4u7vD6+vr2vGGwyHu7+9n82w2i8FggG1mIyF2ux16vX7p2vPzMyQSCcrl8trx0uk0jo6OZnONRoNUKoVthgnZNiHkEXR7e4ubmxv0er2NhPz8/KBer+P6+hrJZBLdbhdiR1Ah4XAYUqkUVqsVFosFMpkMwWCQT/QqIZPJBC6XC3K5HG63Gx6PB3t7ewgEAvj+/oZY2VjIwcEBnE7nwjCbzXNCWq0WP280GrPzyR1OjtVqtZVCMpkML5AU/t88PT3xgguFAsTKxkJIAq+urhaG1+udE+Lz+WAymRZiGAwGXF5erhRyenrK/yv+xGg0Lj0uFgR7ZJHEK5VK6HS6uaFQKHB+fr5SiFarRSKRWNjn4uJiqWixIJiQk5MTvnZ0Op2F8fLyspaQWCy2sI/D4ZgJFSOCCfH7/Tg+Pp4VcAL5HYlE0Gw2Vwqx2Ww4Ozub2+Pz8xMqlQrxeBxiRTAhpICTAkza3fF4zCeTJHJ3dxej0WilkFKpxMfL5XJ8x0VihEIh7O/v4+3tDWJF0LY3n8/zdYRIIB3T4eEhKpXKbP1vQqbTKaLRKHZ2dvh2l4hQq9V4eHiAmBH84+L7+zseHx/5F8SPj4+Nz+c4Du12G/1+H19fXxA77GsvZTAhlMGEUAYTQhlMCGUwIZTBhFAGE0IZTAjo4heZTxFod+qzwwAAAABJRU5ErkJggg=="
  }'

Exemplo JavaScript usando Axios

axios({
  'method': 'POST',
  'url': 'https://www.imagetotext.com/api/ocr',
  'headers': {
    'Content-Type': 'application/json; charset=utf-8',
  },
  'data': {
    'api_key': 'API_KEY',
    'api_secret': 'API_SECRET',
    'image': 'iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAACXBIWXMAAAsTAAALEwEAmpwYAAACfUlEQVR4nO2Yz0sqURTHlYxSMzBcuJaWLiRFhMRAXYi5kUAQBGnTMlAEfyAUiNBGSHAh6EJBEDXEtQqFqJvCTf9CMNs2lUj5fdyBJ/iUpy6Gd994P3DBO5c5dzifcc6ZkYBBFZJ/fQGMeZgQymBCKIMJoQwmhDKYEMpgQv5nIdVqFcVicekax3G4u7vD6+vr2vGGwyHu7+9n82w2i8FggG1mIyF2ux16vX7p2vPzMyQSCcrl8trx0uk0jo6OZnONRoNUKoVthgnZNiHkEXR7e4ubmxv0er2NhPz8/KBer+P6+hrJZBLdbhdiR1Ah4XAYUqkUVqsVFosFMpkMwWCQT/QqIZPJBC6XC3K5HG63Gx6PB3t7ewgEAvj+/oZY2VjIwcEBnE7nwjCbzXNCWq0WP280GrPzyR1OjtVqtZVCMpkML5AU/t88PT3xgguFAsTKxkJIAq+urhaG1+udE+Lz+WAymRZiGAwGXF5erhRyenrK/yv+xGg0Lj0uFgR7ZJHEK5VK6HS6uaFQKHB+fr5SiFarRSKRWNjn4uJiqWixIJiQk5MTvnZ0Op2F8fLyspaQWCy2sI/D4ZgJFSOCCfH7/Tg+Pp4VcAL5HYlE0Gw2Vwqx2Ww4Ozub2+Pz8xMqlQrxeBxiRTAhpICTAkza3fF4zCeTJHJ3dxej0WilkFKpxMfL5XJ8x0VihEIh7O/v4+3tDWJF0LY3n8/zdYRIIB3T4eEhKpXKbP1vQqbTKaLRKHZ2dvh2l4hQq9V4eHiAmBH84+L7+zseHx/5F8SPj4+Nz+c4Du12G/1+H19fXxA77GsvZTAhlMGEUAYTQhlMCGUwIZTBhFAGE0IZTAjo4heZTxFod+qzwwAAAABJRU5ErkJggg=='
  }
});

Exemplo PHP

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();

$data = [
  'api_key' => 'API_KEY',
  'api_secret' => 'API_SECRET',
  'image' => 'iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAACXBIWXMAAAsTAAALEwEAmpwYAAACfUlEQVR4nO2Yz0sqURTHlYxSMzBcuJaWLiRFhMRAXYi5kUAQBGnTMlAEfyAUiNBGSHAh6EJBEDXEtQqFqJvCTf9CMNs2lUj5fdyBJ/iUpy6Gd994P3DBO5c5dzifcc6ZkYBBFZJ/fQGMeZgQymBCKIMJoQwmhDKYEMpgQv5nIdVqFcVicekax3G4u7vD6+vr2vGGwyHu7+9n82w2i8FggG1mIyF2ux16vX7p2vPzMyQSCcrl8trx0uk0jo6OZnONRoNUKoVthgnZNiHkEXR7e4ubmxv0er2NhPz8/KBer+P6+hrJZBLdbhdiR1Ah4XAYUqkUVqsVFosFMpkMwWCQT/QqIZPJBC6XC3K5HG63Gx6PB3t7ewgEAvj+/oZY2VjIwcEBnE7nwjCbzXNCWq0WP280GrPzyR1OjtVqtZVCMpkML5AU/t88PT3xgguFAsTKxkJIAq+urhaG1+udE+Lz+WAymRZiGAwGXF5erhRyenrK/yv+xGg0Lj0uFgR7ZJHEK5VK6HS6uaFQKHB+fr5SiFarRSKRWNjn4uJiqWixIJiQk5MTvnZ0Op2F8fLyspaQWCy2sI/D4ZgJFSOCCfH7/Tg+Pp4VcAL5HYlE0Gw2Vwqx2Ww4Ozub2+Pz8xMqlQrxeBxiRTAhpICTAkza3fF4zCeTJHJ3dxej0WilkFKpxMfL5XJ8x0VihEIh7O/v4+3tDWJF0LY3n8/zdYRIIB3T4eEhKpXKbP1vQqbTKaLRKHZ2dvh2l4hQq9V4eHiAmBH84+L7+zseHx/5F8SPj4+Nz+c4Du12G/1+H19fXxA77GsvZTAhlMGEUAYTQhlMCGUwIZTBhFAGE0IZTAjo4heZTxFod+qzwwAAAABJRU5ErkJggg=='
];

$request = new Request('POST', 'https://www.imagetotext.com/api/ocr', [
  'Content-Type' => 'application/json; charset=utf-8',
], json_encode($data)
);

try {
  $response = $client->send($request);
  echo sprintf('Response HTTP: %d', $response->getStatusCode());
} catch (\Exception $e) {
  echo sprintf('Error: %s', $e->getMessage());
}