No project description provided
Project description
from rossum_api.dtos import UserCredentialsfrom rossum_api.dtos import UserCredentials
Rossum SDK
rossum-sdk is a repository for libraries useful when integrating Rossum platform into other Python applications. The following packages are provided:
rossum-api– delivers programmatic access to the Rossum API.- This package is focused on accessing HTTP API only, if you need more advanced usage like Schema Transformations or interactive CLI tool, please refer to Rossum package.
rossum-api
Installation
The easiest way is to install the package from PyPI:
pip install git+https://github.com/rossumai/rossum-sdk#egg=rossum-api
You can eventually download an installation file from GitHub releases. and install it manually.
Usage
Python API SDK
The rossum-api library can be used to communicate with Rossum API, instead of using requests library directly. The advantages of using rossum-sdk:
- it contains a function that merges the paginated results into one list so the user does not need to get results page by page and take care of their merging,
- it comes with both synchronous and asynchronous API, so you can choose the flavour you need,
- it takes care of authenticating the user,
- it includes many methods for frequent actions that you don't need to write by yourself from scratch,
- it returns the result as a Python first class object - Dataclass, so you don't need to parse the JSON by yourself,
- it maps method naming as close as possible to API docs,
- in case the API version changes, the change will be implemented to the library by Rossum for all the users.
- it has minimal dependencies
Examples
You can choose between asynchronous and synchronous client. Both are exactly the same in terms of features. If you try to use synchronous client in the environment, where event loop is already present and running (for example Jupyter Notebook), exception will be thrown advising to use the async version.
Async version:
import os
import asyncio
from rossum_api import AsyncRossumAPIClient
from rossum_api.dtos import UserCredentials
WORKSPACE = {
"name": "Rossum Client NG Test",
"organization": "https://elis.rossum.ai/api/v1/organizations/116390",
}
async def main_with_async_client():
client = AsyncRossumAPIClient(
base_url="https://elis.rossum.ai/api/v1",
credentials=UserCredentials(os.environ["ELIS_USERNAME"], os.environ["ELIS_PASSWORD"]),
)
ws = await client.create_new_workspace(data=WORKSPACE)
workspace_id = ws.id
ws = await client.retrieve_workspace(workspace_id)
print("GET result:", ws)
print("LIST results:")
async for w in client.list_workspaces(ordering=["-id"], name=WORKSPACE["name"]):
print(w)
await client.delete_workspace(workspace_id)
print(f"Workspace {workspace_id} deleted.")
asyncio.run(main_with_async_client())
Sync version:
import os
from rossum_api import SyncRossumAPIClient
from rossum_api.dtos import UserCredentials
WORKSPACE = {
"name": "Rossum Client NG Test",
"organization": "https://elis.rossum.ai/api/v1/organizations/116390",
}
def main_with_sync_client():
client = SyncRossumAPIClient(
base_url="https://elis.rossum.ai/api/v1",
credentials=UserCredentials(os.environ["ELIS_USERNAME"], os.environ["ELIS_PASSWORD"]),
)
ws = client.create_new_workspace(data=WORKSPACE)
workspace_id = ws.id
ws = client.retrieve_workspace(workspace_id)
print("GET result:", ws)
print("LIST results:")
for w in client.list_workspaces(ordering=["-id"], name=WORKSPACE["name"]):
print(w)
client.delete_workspace(workspace_id)
print(f"Workspace {workspace_id} deleted.")
main_with_sync_client()
Development
There is a Makefile that can help you setup a development environment quickly, run the following commands
make .venv # Creates virtualenv in .venv folder
make install # Installs all project dependencies including test ones
Run make help to see more available actions.
TODO
- convert datetimes to ISO 8601 string in
APIClientto allow users passing standard datetime objects - implement password reset
- rate limiting?
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rossum_api-3.2.0.tar.gz.
File metadata
- Download URL: rossum_api-3.2.0.tar.gz
- Upload date:
- Size: 102.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64adfddebd41eb79f9b28d4f87c87ad21e4c854c780c19908e562ea421254499
|
|
| MD5 |
8354f23ef513f0f1c7f910cf8cf99c6a
|
|
| BLAKE2b-256 |
6f29e75680212b05f48e06e2e9c299c448e9496e5a592f8884a5eb12b741fdbc
|
File details
Details for the file rossum_api-3.2.0-py3-none-any.whl.
File metadata
- Download URL: rossum_api-3.2.0-py3-none-any.whl
- Upload date:
- Size: 41.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba0f6d928d24a82b9f8c799b61cf2ab45814eedc14a435a2646f1ccaf4503233
|
|
| MD5 |
08d91087f68e52ae34b56effe9b89c32
|
|
| BLAKE2b-256 |
f78ee47f80775b5b5c614f067c59e77bdc2845c196e0a31808887445f7bf12ab
|