Library reference

class json_timeseries.TsRecord(timestamp: datetime, value: float | str | int = None, quality: int = None, annotation: str = None)[source]

A record of TimeSeries object

Parameters:
  • timestamp (datetime) – Timestamp

  • value (Union[float, str, int]) – Value. For data type ‘NUMBER’, value must be int or float.

  • quality (int) – Quality

  • annotation (str) – Annotation

class json_timeseries.TimeSeries(name: str, units: str = None, identifier: str = '45a5f861-7185-4d12-8c9f-47347ae4370a', data_type: str = 'NUMBER', records: List[TsRecord] | TsRecord = None)[source]

TimeSeries object

Parameters:
  • data_type (str, optional) – Type of time series. E.g.: ‘NUMBER’, ‘TEXT’, ‘TIME’, ‘COORDINATES’

  • records (list, optional) – List of records

  • name (str) – Time series name

  • identifier (str, optional) – Time series ID. Autogenerated as UUID4 if not specified

Default data_type:

‘NUMBER’

insert(records: TsRecord | List[TsRecord])[source]

Insert single or multiple records

toJSON() str[source]

Outputs formatted JSON

class json_timeseries.JtsDocument(series: List[TimeSeries] | TimeSeries = None, version: str = '1.0')[source]

JTS document object

Raises:

[TypeError] – [Value of ‘series’ must be types of TimeSeries or List[TimeSeries]]

addSeries(series: List[TimeSeries] | TimeSeries)[source]

Add single or multiple TimeSeries

static fromJSON(json_str: str) JtsDocument[source]

Create a new jtsDocument from JSON

getSeries(identifier: str) TimeSeries[source]

Get series by id

toJSON() dict[source]

Output as dictionary of JSON structure

Returns:

Python dictionary of JSON structure

Return type:

dict

toJSONString() str[source]

Output as stringified JSON (json.dumps)

Returns:

Output as stringified JSON

Return type:

str