Skip to main content

Using NuOCR service via APIs

Project description

An API gateway is a software pattern that sits in front of an application programming interface (API) or group of microservices, to facilitate requests and delivery of data and services. Its primary role is to act as a single entry point and standardized process for interactions between an organization's apps, data and services and internal and external customers.

This NuOCR package act as an API gateway which simplifies service delivery and provides flexibility by combining multiple API calls to request and retrieve data and services, which reduces the volume of requests, traffic and manual efforts by great margin.

Advantages are security, reliability, resilience and optimization.

Installation

To install the NuOCR package, please run the following command in your command line prompt.


pip install NuOCR

Examples

Below are few examples, showing the usage of the package.

  1. NuOCR.Util.user

import grpc

from NuOCR.Util import user



key_request = {

    'username': "YOUR USERNAME HERE",

    'password': "YOUR PASSWORD HERE"

}



with grpc.insecure_channel("SERVER DOMAIN OR IP HERE") as channel:

    # To fetch the user api-key

    response = user.GetKey(channel, key_request)

    print(response)

    

    # To update the user api-key

    response = user.ChangeKey(channel, key_request)

    print(response)

For using the NuOCR services, you need to first register and get the API key or user-credentials, then provide the API-key in the meta-deta to use the following services based on your subscription.

  1. NuOCR.Util.extractor

import grpc

from NuOCR.Util import extractor



params = {

    "base64": "YOUR BASE64 HERE"

    "extractionType": "invoice" # anyone from ["invoice", "form", "reciept"],

    "mimeType": "application/pdf",

    "table": True, # boolean value

    "rawJson": True # boolean value

}



user_metadata = [('key', 'YOUR API-KEY HERE')]



with grpc.insecure_channel("SERVER DOMAIN OR IP HERE") as channel:

    # To extract document using the DocRecognizer service.

    print('-'*20, 'Recognizer', '-'*20)

    response = extractor.DocRecognizer(channel, params, user_metadata)

    print(response)

    

    # To extract document using the FormRecognizer service.

    print('-'*20, 'Recognizer', '-'*20)

    response = extractor.FormRecognizer(channel, params, user_metadata)

    print(response)

Similarly, you can fetch and push data from the IO adaptors using NuOCR.Util.io_adaptor. We have currently integrated S3 and FTP as inbound and outbound adapters.

  1. NuOCR.Util.io_adaptor

import grpc

from NuOCR.Util import io_adaptor





ftp_param = {

    "host": HOST,

    "port": PORT NUMBER OF THE REMOTE HOST,

    "username": YOUR FTP USERNAME,

    "password": YOUR FTP PASSWORD,

    "isSecure": False, #BOOLEAN VALUE

    "subscriberId": YOUR SUBSCRIBER ID,

    "remoteFolder": SOURCE OR DESTINATION PATH OF FILE,

    "remoteFilename": NAME OF THE FILE YOU WANT TO STORE OR FETCH,

    "base64": YOUR BASE64 HERE

}



s3_params = {

    "subscriberId": YOUR SUBSCRIBER ID,

    "regionName": REGION NAME,

    "accessKey": YOUR ACCESS KEY,

    "secretKey": YOUR SECRET KEY,

    "bucketName": BUCKET NAME,

    "folderName": SOURCE OR DESTINATION PATH,

    "filename": NAME OF THE FILE YOU WANT TO STORE OR FETCH,

    "base64": YOUR BASE64 HERE,

    "localFilename": LOCAL FILE NAME

}



user_metadata = [('key', 'YOUR API-KEY HERE')]



with grpc.insecure_channel("SERVER DOMAIN OR IP HERE") as channel:

    # To fetch document from S3, this will fetch base64 and file name of all files in that directory.

    print('-'*20, 'S3', '-'*20)

    response = io_adaptor.S3InBound(channel, s3_params)

    for i in response:

        print(i.filename, i.base64)

        

    # To push document to FTP, this will push file to destination path.

    print('-'*20, 'FTP', '-'*20)

    response = io_adaptor.FTPOutBound(channel, ftp_param)

    print(response)

Contributing

TBD

License

TBD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NuOCR-0.0.9.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

NuOCR-0.0.9-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file NuOCR-0.0.9.tar.gz.

File metadata

  • Download URL: NuOCR-0.0.9.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for NuOCR-0.0.9.tar.gz
Algorithm Hash digest
SHA256 7ba8fc8adda72109fe8385263754fb3ce33696643a9b6b38a1048f07b9646cb1
MD5 b8e8b5c2da8858410c7e10b8c6babb8d
BLAKE2b-256 a7e042f8c3b3bf7c8c777ddaab772666409f6b95b4f0a8bda3098d826c08f421

See more details on using hashes here.

Provenance

File details

Details for the file NuOCR-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: NuOCR-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for NuOCR-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 beb9b6efd471263073d7430101ec0b8f271920dcc078fd2d5d727c64d30761ed
MD5 5246b7d30151f5413752e739f8b40581
BLAKE2b-256 0e0513e6353abb544f710fe503b23bbc199644e0748fb3413e8deb57b4a18411

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page