Node.js wrapper for ocr.space APIs.
npm install ocr-space-api-wrapper
Node.js wrapper for ocr.space APIs, a service for executing OCR (Optical Character Recognition) to images and PDFs.
npm i ocr-space-api-wrapperjs
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
$3
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....$3
This param is an object with the following keys:
- apiKey: your API key for ocr.space APIs. 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.
- All other params as documented in the official website.Response
This package does not change the response in any way, please refer to the official website.Run lint
npm run lintRun tests
npm test`