OCR.space API
api.ocr.space · Developer Tools
Free OCR API — extract text from images and PDFs. Supports 25+ languages, table detection, and searchable PDF output. Free tier: 500 requests/day.
Authentication
API Key
Free API key at ocr.space/ocrapi. Pass as apikey header or query parameter. Use "helloworld" for testing.
Sample Requests
POST
OCR an image URL
Extract text from an image URL using OCR.
https://api.ocr.space/parse/imageurl
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| apikey | helloworld |
| Content-Type | application/x-www-form-urlencoded |
Request Body — data you're sending
"url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng"
curl -X POST "https://api.ocr.space/parse/imageurl" \ -H "apikey: helloworld" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Content-Type: application/json" \ -d '"url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng"'
import requests
headers = {
"apikey": "helloworld",
"Content-Type": "application/x-www-form-urlencoded"
}
data = "url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng"
response = requests.post(
"https://api.ocr.space/parse/imageurl",
headers=headers,
json=data,
)
print(response.json())const url = 'https://api.ocr.space/parse/imageurl';
const response = await fetch(url, {
method: 'POST',
headers: {
'apikey': 'helloworld',
'Content-Type': 'application/x-www-form-urlencoded'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify("url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng"),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://api.ocr.space/parse/imageurl"
jsonData, _ := json.Marshal("url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng")
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("apikey", "helloworld")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.ocr.space/parse/imageurl")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["apikey"] = "helloworld"
req["Content-Type"] = "application/x-www-form-urlencoded"
req["Content-Type"] = "application/json"
req.body = "\"url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng\""
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.ocr.space/parse/imageurl";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"apikey: helloworld",
"Content-Type: application/x-www-form-urlencoded",
"Content-Type: application/json"
]),
"content" => json_encode("url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cara_de_un_Gato.jpg/220px-Cara_de_un_Gato.jpg&language=eng"),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Use "helloworld" as API key for testing
- Register at ocr.space for a free key (500 req/day)
- POST to /parse/imageurl with url= or /parse/image with file upload
- Parameters: language=eng, isTable=true, OCREngine=2 (for handwriting)
- Response includes ParsedText and TextOverlay with bounding boxes