Image To Text API
Image To Text API uses advanced machines to recognize and extract text from images. It supports multiple languages and returns the raw text along with a confidence score.
Endpoint
Section titled “Endpoint” POST
/api/v1/ocr Request Parameters
Section titled “Request Parameters”The following parameters are accepted in the request body:
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Direct URL to the image file (JPG, PNG, BMP). |
lang | string | Optional | Language code (default: eng). |
Request Examples
Section titled “Request Examples”curl -X POST https://heavstal.com.ng/api/v1/ocr \-H "Content-Type: application/json" \-H "x-api-key: <YOUR_API_KEY>" \-d '{"url": "https://i.imgur.com/example.png", "lang": "eng"}'const response = await fetch('https://heavstal.com.ng/api/v1/ocr', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': '<YOUR_API_KEY>' }, body: JSON.stringify({ url: 'https://i.imgur.com/example.png', lang: 'eng' })});
const res = await response.json();console.log(res.data.text);import { tools } from '@heavstal/api';
const ocr = await tools.ocr("https://example.com/image-with-text.jpg", "eng");console.log(ocr.data.text);import requests
url = "https://heavstal.com.ng/api/v1/ocr"headers = { "Content-Type": "application/json", "x-api-key": "<YOUR_API_KEY>"}payload = { "url": "https://i.imgur.com/example.png", "lang": "eng"}
response = requests.post(url, headers=headers, json=payload)print(response.json()["data"]["text"])Response Examples
Section titled “Response Examples”{ "status": "success", "creator": "HEAVSTAL TECH", "data": { "confidence": 92.5, "text": "HEAVSTAL TECH\nBuilding the future." }}{ "status": "error", "error": "Failed to download image from the provided URL."}