JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6353
  • Score
    100M100P100Q136409F
  • License MIT

Node.js wrapper for ocr.space APIs.

Package Exports

  • ocr-space-api-wrapper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ocr-space-api-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OCR Space Node.js API wrapper

Donate

Node.js wrapper for ocr.space APIs, a service for executing OCR (Optical Character Recognition) to images and PDFs.

Install

npm i ocr-space-api-wrapper

Usage

const ocrSpace = require('ocr-space-api-wrapper')

async function main () {
  try {
    // Using the OCR.space default free token + remote file
    const res1 = await ocrSpace('http://dl.a9t9.com/ocrbenchmark/eng.png')

    // Using your personal token + local file
    const res2 = await ocrSpace('/path/to/file.pdf', { apiKey: '<API_KEY_HERE>' })
    
    // Using your personal token + base64 image + custom language
    const res3 = await ocrSpace('data:image/png;base64...', { apiKey: '<API_KEY_HERE>', language: 'ita' })
  } catch (error) {
    console.log(error)
  }
}

Params

input string (required)

The input param specifies the input file (see examples above). It can be one of the following:

  • a remote URL address such as http://example.com/image.jpg;
  • a local file path such as /path/to/file.pdf;
  • a base64 image string such as data:image/png;base64....

options object

This param is an object with the following keys:

  • apiKey: your API key for ocr.space APIs.
  • ocrUrl: a different URL for oce.space APIs, for example when you purchase the PRO plan.
  • All other params as documented in the official website.

Response

Refer to the official website.

Bug or feedback

Please open a new issue.

Author