Skip to main content

No project description provided

Project description

Rossum SDK

Build Status Coverage Code style: Ruff PyPI version MIT licence

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 rossum-api

or from the github repo:

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()

Local development

Pull the repository, create a virtual environment, and install the package from the source with test dependencies:

# Create and activate virtual environment
python -m venv .env
source .env/bin/activate

# Install in editable mode with test dependencies
pip install -e .[tests]

We use ruff for linting and formatting. Run all pre-commit hooks with:

pre-commit run --all-files

Or run specific tools:

# Linting and formatting
pre-commit run ruff --all-files
pre-commit run ruff-format --all-files

# Type checking
pre-commit run mypy --all-files

# Run tests
pytest

License

MIT

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

rossum_api-3.4.0.tar.gz (103.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rossum_api-3.4.0-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file rossum_api-3.4.0.tar.gz.

File metadata

  • Download URL: rossum_api-3.4.0.tar.gz
  • Upload date:
  • Size: 103.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rossum_api-3.4.0.tar.gz
Algorithm Hash digest
SHA256 8efac0441feea9411ffec31656e3b4cdd241fd6b2b3cf12940e483a3400c5b0f
MD5 b6b1c29c33f436077e434c90670e9b76
BLAKE2b-256 ae401db9088747aaf91c96da3133ef06484a5a41f3b750e13eaf3845f80feb1d

See more details on using hashes here.

File details

Details for the file rossum_api-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: rossum_api-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rossum_api-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24037fab2348647dbba63e43fedcd6731b8c6f2b4d9ffd70c205f028a4967747
MD5 de0008b6e771c01cedeab8c0e5df1155
BLAKE2b-256 12ffa3e7e2f1f4e672cc8ee8aba4c44856e12e9d3735d106bdd1ab6014944dce

See more details on using hashes here.

Supported by

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