API

Vous pouvez utiliser notre service via l'API RESTful.

Format de la requête

La requête doit être envoyée via la méthode POST au format JSON vers le point de terminaison https://www.imagetotext.com/api/ocr. Vous trouverez ci-dessous la liste des paramètres de requête.

Nom Valeur
api_key Votre clé API. Disponible sur votre page de profil après connexion.
api_secret Votre secret API. Disponible sur votre page de profil après connexion.
image Image encodée en Base64

Format de la réponse

La réponse contiendra les résultats de reconnaissance en texte clair avec le code de statut 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 un message d'erreur avec le code de statut 40* sinon.

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

Exemples

Exemple 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=="
  }'

Exemple JavaScript avec 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=='
  }
});

Exemple 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());
}