A client library for the REST API of DocuWare's DMS

Overview

docuware-client

This is a client library for the REST API of DocuWare DMS. Since DocuWare's documentation regarding the REST API is very sparse (at the time these lines were written), this client serves only a part of the API's functionality.

Please keep in mind: This software is not related to DocuWare. It is a work in progress, may yield unexpected results, and almost certainly contains bugs.

Usage

First you have to log in and create a persistent session:

import json
import pathlib
import docuware

dw = docuware.Client("http://localhost")
session = dw.login("username", "password", "organization")
with open(".session", "w") as f:
    json.dump(session, f)

From then on you have to reuse the session, otherwise you will be locked out of the DocuWare server for a period of time (10 minutes or longer). As the session cookie may change on subsequent logins, update the session file on every login.

session_file = pathlib.Path(".session")
if session_file.exists():
    with open(session_file) as f:
        session = json.load(f)
else:
    session = None
dw = docuware.Client("http://localhost")
session = dw.login("username", "password", "organization", cookiejar=session)
with open(session_file, "w") as f:
    json.dump(session, f)

Iterate over the organizations and file cabinets:

for org in dw.organizations:
    print(org)
    for fc in org.file_cabinets:
        print("   ", fc)

If you already know the ID or name of the objects, you can also access them directly.

org = dw.organization("1")
fc = org.file_cabinet("Archive")

Now some examples of how to search for documents. First you need a search dialog:

# Let's use the first one:
dlg = fc.search_dialog()
# Or a specific search dialog:
dlg = fc.search_dialog("Default search dialog")

Each search term consists of a field name and a search pattern. Each search dialog knows its fields:

for field in dlg.fields.values():
    print(field)

Let's search for some documents:

# Search for DOCNO equal to '123456':
for result in dlg.search("DOCNO=123456"):
    print(result)
# Search for two patterns alternatively:
for result in dlg.search(["DOCNO=123456", "DOCNO=654321"], operation=docuware.OR):
    print(result)

Please note that search terms may also contain metacharacters such as *, (, ), which may need to be escaped when searching for these characters themselves.

for result in dlg.search("DOCTYPE=Invoice \\(incoming\\)"):
    print(result)

Search terms can be as simple as a single string, but can also be more complex. The following two queries are equivalent:

dlg.search(["FIELD1=TERM1,TERM2", "FIELD2=TERM3"])
dlg.search({"FIELD1": ["TERM1", "TERM2"], "FIELD2": ["TERM3"]})

The result of a search is always an iterator over the search results, even if no result was obtained. Each individual search result holds a document attribute, which gives access to the document in the archive. The document itself can be downloaded as a whole or only individual attachments.

for result in dlg.search("DOCNO=123456"):
    doc = result.document
    # Download the complete document ...
    data, content_type, filename = doc.download(keep_annotations=True)
    docuware.write_binary_file(data, filename)
    # ... or individual attachments (or sections, as DocuWare calls them)
    for att in doc.attachments:
        data, content_type, filename = att.download()
        docuware.write_binary_file(data, filename)

CLI usage

This package also includes a simple CLI program for collecting information about the archive and searching and downloading documents or attachments.

First you need to log in:

$ dw-client login --url http://localhost/ --username "Doe, John" --password FooBar --organization "Doe Inc."

The credentials and the session cookie are stored in the .credentials and .session files in the current directory.

Of course, --help will give you a list of all options:

$ dw-client --help

Some search examples (Bash shell syntax):

$ dw-client search --file-cabinet Archive Customer=Foo\*
$ dw-client search --file-cabinet Archive DocNo=123456 "DocType=Invoice \\(incoming\\)"
$ dw-client search --file-cabinet Archive DocDate=2022-02-14

Downloading documents:

$ dw-client search --file-cabinet Archive Customer=Foo\* --download document --annotations

Downloading attachments (or sections):

$ dw-client search --file-cabinet Archive DocNo=123456 --download attachments

Some information about your DocuWare installation:

$ dw-client info

Listing all organizations, file cabinets and dialogs at once:

$ dw-client list

A more specific list, only one file cabinet:

$ dw-client list --file-cabinet Archive

You can also display a (partial) selection of the contents of individual fields:

$ dw-client list --file-cabinet Archive --dialog custom --field DocNo

Further reading

License

This work is released under the BSD 3 license. You may use and redistribute this software as long as the copyright notice is preserved.

You might also like...
wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

wyscoutapi wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3). Usage Install with pip install wyscoutapi. To connect to the Wys

Python API Client for Twitter API v2
Python API Client for Twitter API v2

🐍 Python Client For Twitter API v2 🚀 Why Twitter Stream ? Twitter-Stream.py a python API client for Twitter API v2 now supports FilteredStream, Samp

Drcom-pt-client - Drcom Pt version client with refresh timer

drcom-pt-client Drcom Pt version client with refresh timer Dr.com Pt版本客户端 可用于网页认

Dns-Client-Server - Dns Client Server For Python

Dns-client-server DNS Server: supporting all types of queries and replies. Shoul

Raphtory-client - The python client for the Raphtory project

Raphtory Client This is the python client for the Raphtory project Install via p

Pure Python 3 MTProto API Telegram client library, for bots too!

Telethon ⭐️ Thanks everyone who has starred the project, it means a lot! Telethon is an asyncio Python 3 MTProto library to interact with Telegram's A

Python client library for Google Maps API Web Services

Python Client for Google Maps Services Description Use Python? Want to geocode something? Looking for directions? Maybe matrices of directions? This l

Python client library for Bigcommerce API

Bigcommerce API Python Client Wrapper over the requests library for communicating with the Bigcommerce v2 API. Install with pip install bigcommerce or

Backlog API v2 Client Library for Python
Backlog API v2 Client Library for Python

BacklogPy - Backlog API v2 Client Library for Python BacklogPy is Backlog API v2 Client Library for Python 2/3 Install You can install the client libr

Owner
Stefan Schönberger
Stefan Schönberger
Python bindings for swm-core client REST API

Python bindings for swm-core client REST API Description Sky Port is an universal bus between user software and compute resources. It can also be cons

Sky Workflows 1 Jan 1, 2022
Spore REST API asyncio client

Spore REST API asyncio client

LEv145 16 Aug 2, 2022
Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Harun Mbaabu Mwenda 46 Sep 1, 2022
A Python Library to interface with Flickr REST API, OAuth & JSON Responses

Python-Flickr Python-Flickr is A Python library to interface with Flickr REST API & OAuth Features Photo Uploading Retrieve user information Common Fl

Mike Helmick 40 Sep 25, 2021
A Python Library to interface with Tumblr v2 REST API & OAuth

Tumblpy Tumblpy is a Python library to help interface with Tumblr v2 REST API & OAuth Features Retrieve user information and blog information Common T

Mike Helmick 125 Jun 20, 2022
Python library for interacting with the Wunderlist 2 REST API

Overview Wunderpy2 is a thin Python library for accessing the official Wunderlist 2 API. What does a thin library mean here? Only the bare minimum of

mieubrisse 24 Dec 29, 2020
NiceHash Python Library and Command Line Rest API

NiceHash Python Library and Command Line Rest API Requirements / Modules pip install requests Required data and where to get it Following data is nee

Ashlin Darius Govindasamy 2 Jan 2, 2022
NiceHash Python Library and Command Line Rest API

NiceHash Python Library and Command Line Rest API Requirements / Modules pip install requests Required data and where to get it Following data is nee

Ashlin Darius Govindasamy 2 Jan 2, 2022
TM1py is a Python package that wraps the TM1 REST API in a simple to use library.

By wrapping the IBM Planning Analytics (TM1) REST API in a concise Python framework, TM1py facilitates Python developments for TM1. Interacting with T

Cubewise CODE 147 Dec 15, 2022
Python library wrapping and enhancing the Invenio RDM REST API.

Iridium The metal Iridium is used to refine and enhance metal alloys. Similarly, this package provides an enhanced coating around the Invenio RDM APIs

Materials Data Science and Informatics 2 Mar 29, 2022