Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

ya-ocr

GitHub Actions npm ru en

An unofficial library to use Yandex OCR for free via Translation API, which supports working with JavaScript, TypeScript, and also has built-in parted types for Typebox.

Installation

Installation via Bun:

bun add ya-ocr

Installation via NPM:

npm install ya-ocr

Getting started

To start working with the API, you need to create a OCR Client. This can be done using the line provided below.

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

Translation & SVG overlay

Pass withTranslate: true when creating the client to automatically translate detected text. The result will include a translatedText field and an svg field — an SVG string that embeds the original image with translated text rendered along the original text paths.

const client = new OCRClient({ withTranslate: true });
const result = await client.scanByUrl("https://example.com/image.jpg");
console.log(result.translatedText); // translated text
console.log(result.svg); // '<svg>...</svg>' overlay image

You can see more code examples here

How to use as ShareX OCR see here

Build

To build, you must have:

Don't forget to install the dependencies:

bun install

Regular Build

Building the entire package:

bun build:bun

Building a TypeBox of Types

You can use this build option if you only want to build types for TypeBox:

bun build:typebox

Tests

The library has minimal test coverage to check its performance.

Run the tests:

bun test

About

An unofficial library to use Yandex OCR for free via Translation API, which supports working with JavaScript, TypeScript, and also has built-in parted types for Typebox.

Topics

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /