Skip to main content

Moonsense Cloud API Client

Project description

Moonsense Cloud API Client

Simple client library for the Moonsense Cloud API.

Installation

Install the module from PyPI:

pip install moonsense 

Or from source like this:

python setup.py install 

Getting Started

Start by getting an API secret key by navigating to App in Console and creating a token. You will need to save the generated secret key to a secure place.

https://console.moonsense.cloud/dashboard

We recommend exporting the API secret key as an environment variable:

export MOONSENSE_SECRET_TOKEN=...

You can then very easily list sessions and access the granular data:

from moonsense.client import Client

client = Client()
for session in client.list_sessions():
    print(session)

    for bundle in client.read_session(session.session_id):
        # Each bundle is a SealedBundle. See schema below.

Recommended: For a more realistic example see consumer_example.py. It shows how you can write a consumer that will process session data using an incremental approach.

Webhooks

See webhook_example.py for an example on how to create a very simple handler that the consumer webhooks.

The request payload use the following schema:

 message WebhookPayload {
    string project_id = 1; // checked in the handler since not all event types can provide a projectId.
    string app_id = 2;
    string session_id = 3;
    WebhookEventTypes event_type = 4;
    v2.bundle.SealedBundle bundle = 5; // payload is optional and only a small number of events require a bundle.
    string client_session_group_id = 6;
    repeated string session_labels = 7;
}

The following webhook types are supported:

enum WebhookEventTypes {
    UNKNOWN = 0;
    SESSION_CREATED = 1;
    BUNDLE_RECEIVED = 2;
    CHUNK_PERSISTED = 3;
    SESSION_INACTIVE = 4;
}

Tests

Simply run: pytest

Release

rm -rf build/ dist/
python setup.py sdist bdist_wheel
twine upload dist/*

Dont' forget to bump main branch to the next version.

Code coverge

Generate coverage report with: py.test --cov=moonsense tests/

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

moonsense-0.9.0.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

moonsense-0.9.0-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

Details for the file moonsense-0.9.0.tar.gz.

File metadata

  • Download URL: moonsense-0.9.0.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for moonsense-0.9.0.tar.gz
Algorithm Hash digest
SHA256 e060cd90b05482060c3832d2d08196ed01fa26ed3fb742475e7ede63deaaeb9d
MD5 b1728bb3dcacb1feb019b50142b47f73
BLAKE2b-256 b187a708164b1bed8180cc94d1075e31c21e2ff7e8acf7c36b0db8c3e287df79

See more details on using hashes here.

File details

Details for the file moonsense-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: moonsense-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 54.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for moonsense-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67e2b3b47b42ff04572ca32af11c2b7021a99e050f7b59ee409d2698edfe4d6d
MD5 a742e540e99beef75bba1bb96c2b2e95
BLAKE2b-256 81ccbfeeaecc67b98b39063ce1010c2d8b10697bfcebb566ad09c47107863449

See more details on using hashes here.

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