API
Možete koristiti našu uslugu putem RESTful API-ja.
Format zahtjeva
Zahtjev mora biti poslan metodom POST
u formatu JSON
na krajnju točku https://www.imagetotext.com/api/ocr
.
Popis parametara zahtjeva nalazi se u nastavku.
Naziv | Vrijednost |
---|---|
api_key | Vaš API ključ. Dostupan na vašoj profilnoj stranici nakon prijave. |
api_secret | Vaš API tajni ključ. Dostupan na vašoj profilnoj stranici nakon prijave. |
image | Slika kodirana u Base64 |
Format odgovora
Odgovor će sadržavati rezultate prepoznavanja u običnom tekstu s kodom statusa 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
ili poruku o grešci s kodom statusa 40*
u suprotnom slučaju.
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
Primjeri
Primjer 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==" }'
Primjer JavaScript s Axiosom
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==' } });
Primjer 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()); }