A python client for the AlgoDocs API
Project description
AlgoDocs API Python Client
This client API provides all required Python bindings for communicating with AlgoDocs REST API.
Documentation
Please visit AlgoDocs API Documentation for a detailed documentation of all API methods with their parameters and expected responses.
Installation
Using pip:
Note: algodocs python client was only tested with Python 3.
pip install algodocs
OR
Clone current repository or download as zip file and unzip its contents, then change directory to the root folder and then install.
git clone https://github.com/algodocs/algodocs-python
cd algodocs-python
python setup.py install
For development:
pip install -r requirements.txt
Usage
To use AlgoDocs Python Client, you need to register at AlgoDocs and get your API Key from here
import algodocs
email_address = "your_email_addres_you_registered_with_at_AlgoDocs"
key = "your_secret_api_key"
client = algodocs.AlgoDocsClient(email_address, key)
Test connection and authenticate as follows:
result = client.me()
print(result) #this will print your name, surname and email address
Get all extractors in your AlgoDocs account:
result = client.getExtractors()
print(result)
Get all folders in your AlgoDocs account:
result = client.getFolders()
print(result)
Upload local file using its full path:
file_path= "full_path_to_your_file.pdf" #accepted file types: PDF, PNG, JPG/JPEG, WORD (.doc, .docx), EXCEL (.xls, .xlsx)
extractor_id = "your_extractor_id" #use extractor id that you got from client.getExtractors()
folder_id = "your_folder_id" #use folder id that you got from client.getFolders()
result=client.uploadDocumentLocal(extractor_id, folder_id, file_path)
print(result)
Upload file in base64 format:
with open(file_path, "rb") as file_contents:
file_base64 = base64.b64encode(file_contents.read())
result=client.uploadDocumentBase64(extractor_id, folder_id, file_base64, os.path.basename(file_path))
print(result)
Upload file using its publicly accessible url:
url="https://api.algodocs.com/content/SampleInvoice.pdf"
result=client.uploadDocumentUrl(extractor_id, folder_id, url)
print(result)
Get extracted data of a single document using its id:
document_id="your_document_id" #this document_id comes from result['id'] above, so use your actual document_id that you received in response dictionary object after importing the document to AlgoDocs...
result=client.getExtractedDataByDocumentID(document_id)
print(result)
Get extracted data of multiple documents using extractor id:
#`folder_id`, `limit` and `date` parameters are optional
limit = 10
date = (datetime.now() + timedelta(days=-10)).isoformat() # i.e. get extracted data from documents that were uploaded during last 10 days
result=client.getExtractedDataByExtractorID(extractor_id, folder_id, limit, date)
print(result)
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The library is available as open source under the terms of the MIT License.
MIT License
Copyright (c) 2022 Algosoft Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.