Skip to main content

This is the official Python library for the Myst Platform.

Project description

Myst Python Library

This is the official Python client library for the Myst Platform.

Requirements

  • Python 3.6+.

Installation

To install the package from PyPI:

$ pip install --upgrade myst_v1alpha1

Authentication

The Myst API uses JSON Web Tokens (JWTs) to authenticate requests. The Myst Python library handles the sending of JWTs to the API automatically and currently supports two ways to authenticate to obtain a JWT: through your Google user account or a Myst service account.

Authenticating using your user account

If you don't yet have a Google account, you can create one on the Google Account Signup page.

Once you have access to a Google account, send an email to support@myst.ai with your email so we can authorize you to use the Myst Platform.

Use the following code snippet to authenticate using your user account:

import myst_v1alpha1

myst_v1alpha1.authenticate()

The first time you run this, you'll be presented with a web browser and asked to authorize the Myst Python library to make requests on behalf of your Google user account.

Authenticating using a service account

You can also authenticate using a Myst service account. To request a service account, email support@myst.ai.

To authenticate using a service account, set the MYST_APPLICATION_CREDENTIALS environment variable to the path to your service account key file and specify use_service_account=True:

$ export MYST_APPLICATION_CREDENTIALS=</path/to/key/file.json>
import myst_v1alpha1

myst_v1alpha1.authenticate(use_service_account=True)

You can also explicitly pass the path to your service account key when authenticating:

import myst_v1alpha1

myst_v1alpha1.authenticate(
    use_service_account=True,
    service_account_key_file_path='/path/to/key/file.json',
)

Working with time series

The Myst python library currently supports listing, getting, and fetching data for time series.

Listing time series

import myst_v1alpha1

myst_v1alpha1.authenticate()

all_time_series = myst_v1alpha1.TimeSeries.list()

Getting a time series

import myst_v1alpha1

myst_v1alpha1.authenticate()

time_series = myst_v1alpha1.TimeSeries.get('fc84...')

Fetching data from a time series

You can either fetch data by specifying absolute start and end times, or offsets relative to the as_of_time. If no as_of_time is given, it is assumed to mean "as of now":

import datetime
import pytz

import myst_v1alpha1

myst_v1alpha1.authenticate(...)

time_series = myst_v1alpha1.TimeSeries.get('fc84...')

# Fetching data using absolute start and end times.
data_series = time_series.fetch_data_series(
    start_time=datetime.datetime(2019, 1, 1),
    end_time=datetime.datetime(2019, 1, 2),
)

# Fetching data specifying an as of time.
data_series = time_series.fetch_data_series(
    start_time=datetime.datetime(2019, 1, 1),
    end_time=datetime.datetime(2019, 1, 2),
    as_of_time=datetime.datetime(2019, 1, 1, 12),
)

# Fetching data using offsets relative to now.
data_series = time_series.fetch_data_series(
    start_offset=datetime.timedelta(hours=-12),
    end_offset=datetime.timedelta(hours=12),
)

# Fetching data specifying a combination of relative offsets and absolute timestamps.
data_series = time_series.fetch_data_series(
    start_offset=datetime.timedelta(hours=-12),
    end_time=datetime.datetime(2019, 1, 2),
)

Support

For questions or just to say hi, reach out to support@myst.ai.

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

myst-v1alpha1-1.0.5.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

myst_v1alpha1-1.0.5-py2.py3-none-any.whl (41.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file myst-v1alpha1-1.0.5.tar.gz.

File metadata

  • Download URL: myst-v1alpha1-1.0.5.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.9

File hashes

Hashes for myst-v1alpha1-1.0.5.tar.gz
Algorithm Hash digest
SHA256 8a58bd73d7def507aa50ce56af000e3bcddac31c9ed206e999800b1844c773c5
MD5 d4e873dd859e969945f0df5021843ffd
BLAKE2b-256 e37a66be337e9aa216daa53f558657264c3caf3a7349da4b40cf87c69d38df14

See more details on using hashes here.

File details

Details for the file myst_v1alpha1-1.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: myst_v1alpha1-1.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.9

File hashes

Hashes for myst_v1alpha1-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f7f5b487a77bf644a19e83edf4f525a3a25304e9d8632c61c9c63fe00c6458b9
MD5 54c12830cd94e9e1c5843501ac9f609b
BLAKE2b-256 e299c6b94dbd07e9d5809d041d65336cf05a017917458e39fbba0d248a3a8332

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