Skip to main content

Python client library for the Odyssey Momentum platform.

Project description

Odyssey Momentum

Python library to interact with the Odyssey momentum platform.

PyPI - Version PyPI - Python Version


:warning: Work in progress, API of this library has not been stablized.


Table of Contents

Installation

Prerequisites

  • Python 3.10 or 3.11
  • x86_64 platform (for now, a c extension is used, not build for other platforms yet)
pip install --pre odyssey-momentum

(pre, since it is still in development)

Usage

The python package contains 3 parts:

  • api - To access the JSON, REST-like API.
  • posbus - To connect throurh websocket and receive real times updates.
  • bot - A higher level library build on top of these, providing functionality to build bots.

Library is build around python async/await functionality, particulary async context managers and async generators. So needs to be used with either asyncio or trio.

Example

Run from an asyncio shell:

python -m asyncio

Example API call:

from odyssey_momentum import api, posbus

url = "https://dev.odyssey.ninja"
auth = await posbus.authenticate_guest(url, cache=False)
client = api.API(url, auth["token"])
me = await client.current_user()
print(me.name)

Example websocket connection:

from odyssey_momentum import posbus

url = "https://dev.odyssey.ninja"
auth = await posbus.authenticate_guest(url, cache=False)
async with posbus.connect(url, auth) as (send, stream):
  await send(posbus.teleport_request("00000000-0000-8000-8000-000000000002"))
  async for msg in stream:
    print(msg)

See examples directory for more

Development

Project is managed with hatch.

To get a shell for development:

hatch shell

Run tests:

hatch run test

Run code lint:

hatch run lint:all
hatch build --hooks-only

Build packages (outputs in dist directory:

hatch build

License

odyssey-momentum is distributed under the terms of the MIT license.

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

odyssey_momentum-0.0.1a2.tar.gz (732.1 kB view hashes)

Uploaded Source

Built Distribution

odyssey_momentum-0.0.1a2-py3-none-any.whl (262.2 kB view hashes)

Uploaded Python 3

Supported by

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