Class OCRClient

Constructors

  • Parameters

    Returns OCRClient

Properties

If you don't want to use the classic fetch

Example


import { ofetch } from "ofetch";
import OCRClient from "../dist/client";

// https://github.com/unjs/ofetch
const client = new OCRClient({
fetchFn: ofetch.native,
});

const response = await client.scanByUrl(
"https://repository-images.githubusercontent.com/450906609/c04b600b-5f0f-488b-820d-ffaeb1fde2d0",
);

console.log(response);
fetchOpts: Record<string, unknown>
headers: Record<string, string> = ...

Headers for interacting with Yandex API

host: string
session: null | Session = null
userAgent: string = config.userAgent

Methods

  • Returns Promise<Session>

  • Parameters

    • body: unknown
    • headers: Record<string, string> = {}

    Returns {
        body: unknown;
        headers: {
            Origin: string;
            Referer: string;
        };
        method: string;
    }

    • body: unknown
    • headers: {
          Origin: string;
          Referer: string;
      }
      • Origin: string
      • Referer: string
    • method: string
  • Parameters

    Returns {
        srv: Srv;
        yu: string;
        yum: string;
    }

    • srv: Srv
    • yu: string
    • yum: string
  • Returns Promise<Session>

  • The standard method for requesting the Yandex API, if necessary, you can override how it is done in the example

    Type Parameters

    • T = unknown

    Parameters

    • path: string
    • body: unknown
    • headers: Record<string, string> = {}

    Returns Promise<ClientResponse<T>>

  • Parameters

    • data: Blob | File

    Returns Promise<{
        data: OCRFullData;
        status: true;
    }>

  • Parameters

    • filepath: string

    Returns Promise<{
        data: OCRFullData;
        status: true;
    }>

  • Parameters

    • url: string
    • headers: Record<string, string> = {}

    Returns Promise<{
        data: OCRFullData;
        status: true;
    }>