https://github.com/davideviolante/ocr-space-api-wrapper
Node.js wrapper for ocr.space APIs.
https://github.com/davideviolante/ocr-space-api-wrapper
api javascript nodejs ocr ocr-recognition wrapper
Last synced: 3 months ago
JSON representation
Node.js wrapper for ocr.space APIs.
- Host: GitHub
- URL: https://github.com/davideviolante/ocr-space-api-wrapper
- Owner: DavideViolante
- License: mit
- Created: 2020-11-09T14:57:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T11:08:08.000Z (over 1 year ago)
- Last Synced: 2025-03-30T21:14:18.631Z (over 1 year ago)
- Topics: api, javascript, nodejs, ocr, ocr-recognition, wrapper
- Language: JavaScript
- Homepage: https://ocr.space/ocrapi
- Size: 1.43 MB
- Stars: 27
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OCR.Space Node.js API wrapper
[](https://github.com/DavideViolante/ocr-space-api-wrapper/actions?query=workflow%3A"Node.js+CI") [](https://coveralls.io/github/DavideViolante/ocr-space-api-wrapper?branch=master) [](https://www.npmjs.com/package/ocr-space-api-wrapper) [](https://www.paypal.me/dviolante)
[](https://www.npmjs.com/package/ocr-space-api-wrapper)
Node.js wrapper for [ocr.space APIs](https://ocr.space/ocrapi), a service for executing OCR (Optical Character Recognition) to images and PDFs.
## Install
`npm i ocr-space-api-wrapper`
## Usage
```js
const { ocrSpace } = require('ocr-space-api-wrapper');
async function main () {
try {
// Using the OCR.space default free API key (max 10reqs in 10mins) + remote file
const res1 = await ocrSpace('http://dl.a9t9.com/ocrbenchmark/eng.png');
// Using your personal API key + local file
const res2 = await ocrSpace('/path/to/file.pdf', { apiKey: '' });
// Using your personal API key + base64 image + custom language
const res3 = await ocrSpace('data:image/png;base64...', { apiKey: '', language: 'ita' });
} catch (error) {
console.error(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](https://ocr.space/ocrapi). Default API key has a limit of max 10reqs in 10mins.
- `ocrUrl`: a different URL for ocr.space APIs, for example when you purchase the PRO plan.
- `signal`: an `AbortSignal` for `AbortController` to abort the request.
- All other params as documented in the [official website](https://ocr.space/OCRAPI#PostParameters).
## Response
This package does not change the response in any way, please refer to the [official website](https://ocr.space/OCRAPI#Response).
## Run lint
`npm run lint`
## Run tests
`npm test`
## Bug or feedback
Please open a new issue.
## Author
- [Davide Violante](https://github.com/DavideViolante)