Skip to content

DynamoxAPI

dynamox_api.DynamoxAPI(api_key_path, timeout=30, retry=True)

Class to interact with the Dynamox API

Parameters:

  • api_key_path (str) –

    Path to the API key file (json file).

  • timeout (float, default: 30 ) –

    Maximum time to wait for a request response, by default 30.

  • retry (bool, default: True ) –

    Enable/disable retry mode, by default True.

Methods:

Examples:

>>> from dynamox_api import DynamoxAPI
>>> api = DynamoxAPI("path/to/api_key.json")
# Get raw waveform data using waveform endpoint
>>> waveform = api.get_waveform("waveform_id", method="raw")

authorization_header property writable

Authorization header to be used in the requests

retry property writable

Enable/disable retry mode

timeout property writable

Maximum time to wait for a request response

_telemetry_resolution(aggregation)

Get telemetry resolution in seconds

Parameters:

  • aggregation (str) –

    Aggregation time

Returns:

  • int

    Resolution in seconds

generate_authorization_header()

Generate authorization header to be used in the requests

Returns:

  • dict

    Authorization header from token endpoint.

Raises:

get_telemetry(spot_id, aggregation='1h', start=None, end=None, verbose=False)

Get telemetry data for a given monitoring point (https://api.dynamox.solutions/docs#tag/Telemetry)

Parameters:

  • spot_id (str) –

    Monitoring point ID

  • aggregation (str, default: '1h' ) –

    Aggregation time, by default "1h"

  • start (datetime, default: None ) –

    Start date, by default 7 days ago

  • end (datetime, default: None ) –

    End date, by default now

Returns:

  • List[dict]

    Telemetry data

get_telemetry_metrics(spot_id)

Show a list of all Metric Descriptors existents for a spot (https://api.dynamox.solutions/docs#tag/Telemetry/operation/list_v1_telemetry_metric_descriptor_get)

Parameters:

  • spot_id (str) –

    Monitoring point ID

get_waveform(waveform_id, method='raw')

Call waveform endpoint to get data (https://api.dynamox.solutions/docs#tag/Waveform)

Parameters:

  • waveform_id (str) –

    Unique identifier of the waveform

  • method (str, default: 'raw' ) –

    Endpoint method, by default "raw"

Returns:

  • waveform_schema

    Waveform data

Raises:

get_waveforms_list(spot_id, page=1, limit=25, sort='startedAt', direction=1, start=None, end=None, verbose=False)

List of waveforms for given list of monitoring points or a single monitoring point (https://api.dynamox.solutions/docs#tag/Waveforms)

For now, the only parameters that matters are spot_id, start and end. The other parameters are not being used and the API doccumentation isn't updated.

Parameters:

  • spot_id (Union[str, List[str]]) –

    Monitoring point ID or list of monitoring point IDs.

  • page (int, default: 1 ) –

    Page number, by default 1

  • limit (int, default: 25 ) –

    Number of records per page, by default 25

  • sort (str, default: 'startedAt' ) –

    Sort field, by default "startedAt"

  • direction (int, default: 1 ) –

    Sort direction, by default 1 (increasing), -1 for decreasing

  • start (datetime, default: None ) –

    Start date, by default 7 days ago

  • end (datetime, default: None ) –

    End date, by default now

  • verbose (bool, default: False ) –

    Print pagination status, by default False