GithubHelp home page GithubHelp logo

rossum-sdk's Introduction

Rossum SDK

Build Status Coverage Code style: black 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 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 asyncio
from rossum_api.elis_api_client import ElisAPIClient

WORKSPACE = {
    "name": "Rossum Client NG Test",
    "organization": "https://elis.rossum.ai/api/v1/organizations/116390",
}

async def main_with_async_client():
    client = ElisAPIClient(
        os.environ["ELIS_USERNAME"],
        os.environ["ELIS_PASSWORD"],
        base_url="https://elis.rossum.ai/api/v1",
    )
    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_all_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:

from rossum_api.elis_api_client_sync import ElisAPIClientSync

WORKSPACE = {
    "name": "Rossum Client NG Test",
    "organization": "https://elis.rossum.ai/api/v1/organizations/116390",
}

def main_with_sync_client():
    client = ElisAPIClientSync(
        os.environ["ELIS_USERNAME"],
        os.environ["ELIS_PASSWORD"],
        base_url="https://elis.rossum.ai/api/v1",
    )
    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_all_workspaces(ordering=["-id"], name=WORKSPACE["name"]):
        print(w)
    client.delete_workspace(workspace_id)
    print(f"Workspace {workspace_id} deleted.")

main_with_sync_client()

TODO

  • convert datetimes to ISO 8601 string in APIClient to allow users passing standard datetime objects
  • implement password reset
  • rate limiting?

License

MIT

rossum-sdk's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.