Last updated 7 months ago
Extract text from an image.
POST https://apis.aigen.online/aiscript/general-ocr/v2
POST
https://apis.aigen.online/aiscript/general-ocr/v2
{ "status": "200", "request_id": "string", "error": [ { "object": "error", "code": "string", "message": "string" } ], "data": [ { "bboxes": [ { "bbox": [ [ 0, 0 ], [ 50, 0 ], [ 50, 50 ], [ 0, 50 ] ], "bbox_norm": [ [ 0.1, 1 ], [ 0.2, 0.3 ], [ 0.5, 0.5 ], [ 0.5, 0.5 ] ], "char_pos_norm": [ 0.01, 0.03, 0.05 ], "text": "548 9", "confidence": 0.99875 } ], "text_page": "123 abc\n", "page": 1, "max_page": 5 } ] }
{ "detail": [ { "loc": [ "string", 0 ], "msg": "string", "type": "string" } ] }
import requests api = "https://apis.aigen.online/aiscript/general-ocr/v2" headers = {"x-aigen-key": "<key>"} data = {"image": "<base64_string>"} res = requests.post(api, json=data, headers=headers) print(res.json())
const axios = require("axios"); const api = "https://apis.aigen.online/aiscript/general-ocr/v2"; const headers = { "x-aigen-key": "<key>", }; const data = { image: "<base64_string>" }; axios .post(api, data, { headers: headers }) .then((res) => { console.log(res.data); }) .catch((err) => { console.error(err.response.data); });
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://apis.aigen.online/aiscript/general-ocr/v2', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "image": "<base64_string>", }', CURLOPT_HTTPHEADER => array( 'X-AIGEN-KEY: <aigen-key>', 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ?>
curl --location 'https://apis.aigen.online/aiscript/general-ocr/v2' \ --header 'X-AIGEN-KEY: <aigen-key>' \ --header 'Content-Type: application/json' \ --data '{ "image": "<base64_string>", }'
200
-
Successful Response
400
image_not_support
error <array>
image convert error
422
field required
image *
String
Full-page image or multi-page PDF encoded in base64 UTF-8 format