Python client library for the Odyssey Momentum platform.
Project description
Odyssey Momentum
Python library to interact with the Odyssey momentum platform.
: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
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
Hashes for odyssey_momentum-0.0.1a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76e7d78b1e4695ebde0c89215f3659934399db15f8a0a64a6a9dc60f1e6c4f9 |
|
MD5 | d8c50f288e8ccb76ea69d31adde75df5 |
|
BLAKE2b-256 | 3332df8c8d3c960d1dacb78b308770ec399fc194c91b8c52f9eda0d86c44de03 |