Detect page rotation and script (e.g. a scan that's upside down)
Detects how a scan is rotated and which script it uses, so you can straighten it before OCR.
Request
POSThttps://ocr-image-to-text.p.apihiver.com/v1/orientation
Upload the image in the file field (max 25 MB). Instead of a file you can send JSON: {"url": "https://…"} for a public image URL, or {"base64": "…"}.
*
No file chosen
File. The image file (JPG, PNG, WebP, GIF, BMP or TIFF).
Parameters and body structure are inherited from this endpoint's definition. Changes here only apply to this test run.
Language
Client
1curl --request POST \
2 --url https://ocr-image-to-text.p.apihiver.com/v1/orientation \
3 --header 'Accept: application/json' \
4 --header 'X-API-Key: YOUR_API_KEY' \
5 --header 'content-type: multipart/form-data' \
6 --form file=@file.binDetect page rotation and script (e.g. a scan that's upside down): OCR API — Image to Text reference
Detects how a scan is rotated and which script it uses, so you can straighten it before OCR. This endpoint is part of the OCR API — Image to Text: Extract text from images and scans in English, Hindi and Marathi, and pull out emails, phone numbers, URLs, PAN and GSTIN.
Detect page rotation and script (e.g. a scan that's upside down): example requests in every language
POST /v1/orientation in Shell (cURL)
curl --request POST \
--url https://ocr-image-to-text.p.apihiver.com/v1/orientation \
--header 'Accept: application/json' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'content-type: multipart/form-data' \
--form [email protected]POST /v1/orientation in Shell (HTTPie)
echo '-----011000010111000001101001
Content-Disposition: form-data; name="file"; filename="file.bin"
Content-Type: multipart/form-data
-----011000010111000001101001--
' | \
http POST https://ocr-image-to-text.p.apihiver.com/v1/orientation \
Accept:application/json \
X-API-Key:YOUR_API_KEY \
content-type:'multipart/form-data; boundary=---011000010111000001101001'POST /v1/orientation in Shell (Wget)
wget --quiet \
--method POST \
--header 'Accept: application/json' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="file"; filename="file.bin"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n' \
--output-document \
- https://ocr-image-to-text.p.apihiver.com/v1/orientationPOST /v1/orientation in Node.js (http)
const http = require('https');
const options = {
method: 'POST',
hostname: 'ocr-image-to-text.p.apihiver.com',
port: null,
path: '/v1/orientation',
headers: {
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write('-----011000010111000001101001\r\nContent-Disposition: form-data; name="file"; filename="file.bin"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n');
req.end();POST /v1/orientation in Node.js (Request)
const fs = require('fs');
const request = require('request');
const options = {
method: 'POST',
url: 'https://ocr-image-to-text.p.apihiver.com/v1/orientation',
headers: {
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
formData: {
file: {
value: fs.createReadStream('file.bin'),
options: {filename: 'file.bin', contentType: 'multipart/form-data'}
}
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});POST /v1/orientation in Node.js (Unirest)
const fs = require('fs');
const unirest = require('unirest');
const req = unirest('POST', 'https://ocr-image-to-text.p.apihiver.com/v1/orientation');
req.headers({
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
});
req.multipart([
{
body: fs.createReadStream('file.bin'),
'content-type': 'multipart/form-data'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});POST /v1/orientation in Node.js (Axios)
const axios = require('axios').default;
const options = {
method: 'POST',
url: 'https://ocr-image-to-text.p.apihiver.com/v1/orientation',
headers: {
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="file"; filename="file.bin"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}POST /v1/orientation in Node.js (Fetch)
const fs = require('fs');
const FormData = require('form-data');
const fetch = require('node-fetch');
const formData = new FormData();
formData.append('file', fs.createReadStream('file.bin'));
const url = 'https://ocr-image-to-text.p.apihiver.com/v1/orientation';
const options = {
method: 'POST',
headers: {Accept: 'application/json', 'X-API-Key': 'YOUR_API_KEY'}
};
options.body = formData;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}POST /v1/orientation in JavaScript (XMLHttpRequest)
const data = new FormData();
data.append('file', 'file.bin');
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', 'https://ocr-image-to-text.p.apihiver.com/v1/orientation');
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('X-API-Key', 'YOUR_API_KEY');
xhr.send(data);POST /v1/orientation in JavaScript (Axios)
import axios from 'axios';
const form = new FormData();
form.append('file', 'file.bin');
const options = {
method: 'POST',
url: 'https://ocr-image-to-text.p.apihiver.com/v1/orientation',
headers: {
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
},
data: '[form]'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}POST /v1/orientation in JavaScript (Fetch)
const url = 'https://ocr-image-to-text.p.apihiver.com/v1/orientation';
const form = new FormData();
form.append('file', 'file.bin');
const options = {
method: 'POST',
headers: {Accept: 'application/json', 'X-API-Key': 'YOUR_API_KEY'}
};
options.body = form;
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}POST /v1/orientation in JavaScript (jQuery)
const form = new FormData();
form.append('file', 'file.bin');
const settings = {
async: true,
crossDomain: true,
url: 'https://ocr-image-to-text.p.apihiver.com/v1/orientation',
method: 'POST',
headers: {
Accept: 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
processData: false,
contentType: false,
mimeType: 'multipart/form-data',
data: form
};
$.ajax(settings).done(function (response) {
console.log(response);
});POST /v1/orientation in Python (http.client)
import http.client
conn = http.client.HTTPSConnection("ocr-image-to-text.p.apihiver.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = {
'Accept': "application/json",
'X-API-Key': "YOUR_API_KEY",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
conn.request("POST", "/v1/orientation", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))POST /v1/orientation in Python (Requests)
import requests
url = "https://ocr-image-to-text.p.apihiver.com/v1/orientation"
files = { "file": "open('file.bin', 'rb')" }
headers = {
"Accept": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
response = requests.post(url, files=files, headers=headers)
print(response.json())POST /v1/orientation in PHP (cURL)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ocr-image-to-text.p.apihiver.com/v1/orientation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"X-API-Key: YOUR_API_KEY",
"content-type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}POST /v1/orientation in PHP (Guzzle)
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://ocr-image-to-text.p.apihiver.com/v1/orientation', [
'multipart' => [
[
'name' => 'file',
'filename' => 'file.bin',
'contents' => null,
'headers' => [
'Content-Type' => 'multipart/form-data'
]
]
]
'headers' => [
'Accept' => 'application/json',
'X-API-Key' => 'YOUR_API_KEY',
],
]);
echo $response->getBody();POST /v1/orientation in PHP (PECL HTTP v1)
<?php
$request = new HttpRequest();
$request->setUrl('https://ocr-image-to-text.p.apihiver.com/v1/orientation');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'Accept' => 'application/json',
'X-API-Key' => 'YOUR_API_KEY',
'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
]);
$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="file"; filename="file.bin"
Content-Type: multipart/form-data
-----011000010111000001101001--
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}POST /v1/orientation in PHP (PECL HTTP v2)
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->addForm(null, [
[
'name' => 'file',
'type' => 'multipart/form-data',
'file' => 'file.bin',
'data' => null
]
]);
$request->setRequestUrl('https://ocr-image-to-text.p.apihiver.com/v1/orientation');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'Accept' => 'application/json',
'X-API-Key' => 'YOUR_API_KEY'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();POST /v1/orientation in Java (AsyncHttp)
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "https://ocr-image-to-text.p.apihiver.com/v1/orientation")
.setHeader("Accept", "application/json")
.setHeader("X-API-Key", "YOUR_API_KEY")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();POST /v1/orientation in Java (java.net.http)
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ocr-image-to-text.p.apihiver.com/v1/orientation"))
.header("Accept", "application/json")
.header("X-API-Key", "YOUR_API_KEY")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());POST /v1/orientation in Java (OkHttp)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("https://ocr-image-to-text.p.apihiver.com/v1/orientation")
.post(body)
.addHeader("Accept", "application/json")
.addHeader("X-API-Key", "YOUR_API_KEY")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();POST /v1/orientation in Java (Unirest)
HttpResponse<String> response = Unirest.post("https://ocr-image-to-text.p.apihiver.com/v1/orientation")
.header("Accept", "application/json")
.header("X-API-Key", "YOUR_API_KEY")
.header("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.asString();POST /v1/orientation in C# (HttpClient)
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://ocr-image-to-text.p.apihiver.com/v1/orientation"),
Headers =
{
{ "Accept", "application/json" },
{ "X-API-Key", "YOUR_API_KEY" },
},
Content = new MultipartFormDataContent
{
new StringContent("")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("multipart/form-data"),
ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "file",
FileName = "file.bin",
}
}
},
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}POST /v1/orientation in C# (RestSharp)
var client = new RestClient("https://ocr-image-to-text.p.apihiver.com/v1/orientation");
var request = new RestRequest("", Method.Post);
request.AddHeader("Accept", "application/json");
request.AddHeader("X-API-Key", "YOUR_API_KEY");
request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
var response = client.Execute(request);POST /v1/orientation in Go (NewRequest)
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://ocr-image-to-text.p.apihiver.com/v1/orientation"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("X-API-Key", "YOUR_API_KEY")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}POST /v1/orientation in Ruby (net::http)
require 'uri'
require 'net/http'
url = URI("https://ocr-image-to-text.p.apihiver.com/v1/orientation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["X-API-Key"] = 'YOUR_API_KEY'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_bodyPOST /v1/orientation in Swift (NSURLSession)
import Foundation
let headers = [
"Accept": "application/json",
"X-API-Key": "YOUR_API_KEY",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "file",
"fileName": "file.bin",
"contentType": "multipart/form-data"
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error as Any)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "https://ocr-image-to-text.p.apihiver.com/v1/orientation")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()POST /v1/orientation in Objective-C (NSURLSession)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Accept": @"application/json",
@"X-API-Key": @"YOUR_API_KEY",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"file", @"fileName": @"file.bin", @"contentType": @"multipart/form-data" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ocr-image-to-text.p.apihiver.com/v1/orientation"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];POST /v1/orientation in Kotlin (OkHttp)
val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")
val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n")
val request = Request.Builder()
.url("https://ocr-image-to-text.p.apihiver.com/v1/orientation")
.post(body)
.addHeader("Accept", "application/json")
.addHeader("X-API-Key", "YOUR_API_KEY")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build()
val response = client.newCall(request).execute()POST /v1/orientation in C (libcurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://ocr-image-to-text.p.apihiver.com/v1/orientation");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "X-API-Key: YOUR_API_KEY");
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);POST /v1/orientation in Clojure (clj-http)
(require '[clj-http.client :as client])
(client/post "https://ocr-image-to-text.p.apihiver.com/v1/orientation" {:headers {:X-API-Key "YOUR_API_KEY"}
:multipart [{:name "file"
:content (clojure.java.io/file "file.bin")}]
:accept :json})POST /v1/orientation in OCaml (CoHTTP)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://ocr-image-to-text.p.apihiver.com/v1/orientation" in
let headers = Header.add_list (Header.init ()) [
("Accept", "application/json");
("X-API-Key", "YOUR_API_KEY");
("content-type", "multipart/form-data; boundary=---011000010111000001101001");
] in
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)POST /v1/orientation in R (httr)
library(httr)
url <- "https://ocr-image-to-text.p.apihiver.com/v1/orientation"
payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"file.bin\"\r\nContent-Type: multipart/form-data\r\n\r\n\r\n-----011000010111000001101001--\r\n"
encode <- "multipart"
response <- VERB("POST", url, body = payload, add_headers('X-API-Key' = 'YOUR_API_KEY'), content_type("multipart/form-data"), accept("application/json"), encode = encode)
content(response, "text")POST /v1/orientation in PowerShell (Invoke-WebRequest)
$headers=@{}
$headers.Add("Accept", "application/json")
$headers.Add("X-API-Key", "YOUR_API_KEY")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-WebRequest -Uri 'https://ocr-image-to-text.p.apihiver.com/v1/orientation' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="file"; filename="file.bin"
Content-Type: multipart/form-data
-----011000010111000001101001--
'POST /v1/orientation in PowerShell (Invoke-RestMethod)
$headers=@{}
$headers.Add("Accept", "application/json")
$headers.Add("X-API-Key", "YOUR_API_KEY")
$headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
$response = Invoke-RestMethod -Uri 'https://ocr-image-to-text.p.apihiver.com/v1/orientation' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="file"; filename="file.bin"
Content-Type: multipart/form-data
-----011000010111000001101001--
'POST /v1/orientation in HTTP (HTTP/1.1)
POST /v1/orientation HTTP/1.1
Accept: application/json
X-Api-Key: YOUR_API_KEY
Content-Type: multipart/form-data; boundary=---011000010111000001101001
Host: ocr-image-to-text.p.apihiver.com
Content-Length: 169
-----011000010111000001101001
Content-Disposition: form-data; name="file"; filename="file.bin"
Content-Type: multipart/form-data
-----011000010111000001101001--
Example response (200, application/json)
Success.
1{
2 "script": "Latin",
3 "rotate_by_degrees": 0,
4 "script_confidence": 7.78,
5 "orientation_degrees": 0,
6 "orientation_confidence": 2.96
7}Errors
- 400 — A required parameter is missing or a value has the wrong format.
1{ 2 "error": { 3 "code": "INVALID_INPUT", 4 "message": "Provide a file upload, 'url', or 'base64'." 5 } 6}
Gateway errors (missing key, no subscription, rate limits) are listed in Error codes.