Document Insighter Python Client
Project description
Document Insighter Python Client
document-insighter
is a set of tools that enables developers to interactive with Document Insighter API, like query extraction results.
Installation
pip install document-insighter
Getting Started
Authentication
OKTA Base Applications
Configure ENV variables
# Client application credentials
INSIGHTER_CLIENT_IDP=xxxx
INSIGHTER_CLIENT_ID=xxxx
INSIGHTER_CLIENT_SECRET=xxxx
# Client access token file path, no need to create it
INSIGHTER_CLIENT_TOKEN_PATH=insighter_token.json
# Tenant name, which can be found in settings page
INSIGHTER_TENANT=xxxx
Fetch Token
from document_insighter.api_client import OktaApplicationClient
from document_insighter.model import Env, Extraction
# Change to Env.PRODUCTION for production
document_insighter = OktaApplicationClient(Env.STAGING)
document_insighter.fetch_token()
Service Account Base Applications
Configure ENV variables
# Client application credentials
INSIGHTER_SA_CLIENT_ID=xxxx
INSIGHTER_SA_CLIENT_SECRET=xxxx
# Path of service account access token, which download from settings page
INSIGHTER_SA_CLIENT_TOKEN_PATH=service-account-token.json
# Tenant name, which can be found in settings page
INSIGHTER_TENANT=xxxx
Create Client
from document_insighter.api_client import ServiceAccountClient
from document_insighter.model import Env
document_insighter = ServiceAccountClient(Env.STAGING)
Query Extractions
from datetime import datetime
pages_generator = document_insighter.query_extractions_pages(datetime(2022, 4, 13), datetime(2022, 4, 14), page_size=50)
extraction_dicts = [x for page in pages_generator for x in page]
# read first extraction
sections = extraction_dicts[0].get('data').get('sections')
batch_sections = list(filter(lambda x:x.get('category') == 'coa_batch', sections))
aggregation_sections = list(filter(lambda x:x.get('category') == 'coa_aggregation', sections))
# load json to models
from typing import List
extractions: List[Extraction] = [Extraction.from_dict(x) for x in extraction_dicts]
Upload and Poll Extractions
extractions = document_insighter.upload_and_poll("BR", 'tests/data/br_document.pdf')
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file document-insighter-0.0.8.tar.gz
.
File metadata
- Download URL: document-insighter-0.0.8.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 221fdbbb683b0c9131867f8ff959ffafcf70c732ac979491f0c7daab56330e12 |
|
MD5 | af5616dc7e54b18b1d3394669adadc38 |
|
BLAKE2b-256 | 1c3898d4aa5228c72e4c668b6e6e70d5ac38d01f24b3705c6d10862992b911ba |
File details
Details for the file document_insighter-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: document_insighter-0.0.8-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd28ad612abb2491497908c403c12f0512eb4a73f67d3c706c749869fb1e77b2 |
|
MD5 | 77cff24feb8ed124fca15e0428966b85 |
|
BLAKE2b-256 | da141be8344077f7c8f90e8064ca3352c75b76b284c6766ede86513c2f96e83a |