Overview

Cognite Client

Responses

class cognite.client._api_client.CogniteResponse(internal_representation)

Bases: object

Cognite Response class

All responses inherit from this class.

Examples

All responses are pretty-printable:

from cognite.client import CogniteClient

client = CogniteClient()
res = client.assets.get_assets(limit=1)

print(res)

All endpoints which support paging have an autopaging flag which may be set to true in order to sequentially fetch all resources. If for some reason, you want to do this manually, you may use the next_cursor() method on the response object. Here is an example of that:

from cognite.client import CogniteClient

client = CogniteClient()

asset_list = []

cursor = None
while True:
    res = client.assets.get_assets(cursor=cursor)
    asset_list.extend(res.to_json())
    cursor = res.next_cursor()
    if cursor is None:
        break

print(asset_list)
next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

class cognite.client._api_client.CogniteCollectionResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Cognite Collection Response class

All collection responses inherit from this class. Collection responses are subscriptable and iterable.

to_json()

Returns data as a json object

Exceptions

exception cognite.client.exceptions.APIError(message, code=None, x_request_id=None, extra=None)

Bases: Exception

Cognite API Error

Raised if a given request fails.

Parameters:
  • message (str) – The error message produced by the API
  • code (int) – The error code produced by the failure
  • x_request_id (str) – The request-id generated for the failed request.
  • extra (Dict) – A dict of any additional information.

Examples

Catching an API-error and handling it based on the error code:

from cognite.client import CogniteClient, APIError

client = CogniteClient()

try:
    client.login.status()
except APIError as e:
    if e.code == 401:
        print("You are not authorized")
    elif e.code == 400:
        print("Something is wrong with your request")
    elif e.code == 500:
        print("Something went terribly wrong. Here is the request-id: {}".format(e.x_request_id)
    print("The message returned from the API: {}".format(e.message))

API

Assets

Client

class cognite.client.stable.assets.AssetsClient(**kwargs)
delete_assets(asset_ids: List[int]) → None

Delete a list of assets.

Parameters:asset_ids (list[int]) – List of IDs of assets to delete.
Returns:None

Examples

You can delete an asset like this:

client = CogniteClient()
res = client.assets.delete_assets([123])
get_asset(asset_id) → cognite.client.stable.assets.AssetResponse

Returns the asset with the provided assetId.

Parameters:asset_id (int) – The asset id of the top asset to get.
Returns:A data object containing the requested assets with several getter methods with different output formats.
Return type:stable.assets.AssetResponse

Examples

You can fetch a single asset like this:

client = CogniteClient()
res = client.assets.get_asset(asset_id=123)
print(res)
get_asset_subtree(asset_id, depth=None, **kwargs) → cognite.client.stable.assets.AssetListResponse

Returns asset subtree of asset with provided assetId.

Parameters:
  • asset_id (int) – The asset id of the top asset to get.
  • depth (int) – Get subassets this many levels below the top asset.
Keyword Arguments:
 
  • limit (int) – The maximum nuber of assets to be returned.
  • cursor (str) – Cursor to use for paging through results.
  • autopaging (bool) – Whether or not to automatically page through results. If set to true, limit will be disregarded. Defaults to False.
Returns:

A data object containing the requested assets with several getter methods with different output formats.

Return type:

stable.assets.AssetListResponse

Examples

You can fetch an asset subtree like this:

client = CogniteClient()
res = client.assets.get_asset_subtree(asset_id=123, depth=)
print(res.to_pandas())
get_assets(name=None, path=None, description=None, metadata=None, depth=None, fuzziness=None, **kwargs) → cognite.client.stable.assets.AssetListResponse

Returns assets matching provided description.

Parameters:
  • name (str) – The name of the asset(s) to get.
  • path (str) – The path of the subtree to search in.
  • description (str) – Search query.
  • metadata (dict) – The metadata values used to filter the results.
  • depth (int) – Get sub assets up oto this many levels below the specified path.
  • fuzziness (int) – The degree of fuzziness in the name matching.
Keyword Arguments:
 
  • autopaging (bool) – Whether or not to automatically page through results. If set to true, limit will be disregarded. Defaults to False.
  • limit (int) – The maximum number of assets to be returned.
  • cursor (str) – Cursor to use for paging through results.
Returns:

A data object containing the requested assets with several getter methods with different output formats.

Return type:

stable.assets.AssetListResponse

Examples

You can fetch all assets with a maximum depth of three like this:

client = CogniteClient()
res = client.assets.get_assets(depth=3, autopaging=True)
print(res.to_pandas())
post_assets(assets: List[cognite.client.stable.assets.Asset]) → cognite.client.stable.assets.AssetListResponse

Insert a list of assets.

Parameters:assets (list[stable.assets.Asset]) – List of asset data transfer objects.
Returns:A data object containing the posted assets with several getter methods with different output formats.
Return type:stable.assets.AssetListResponse

Examples

Posting an asset:

from cognite.client.stable.assets import Asset

client = CogniteClient()

my_asset = Asset("myasset")
assets_to_post = [my_asset]
res = client.assets.post_assets(assets_to_post)
print(res)
search_for_assets(name=None, description=None, query=None, metadata=None, asset_subtrees=None, min_created_time=None, max_created_time=None, min_last_updated_time=None, max_last_updated_time=None, **kwargs) → cognite.client.stable.assets.AssetListResponse

Search for assets.

Parameters:
  • name – Prefix and fuzzy search on name.
  • str (description) – Prefix and fuzzy search on description.
  • query (str) – Search on name and description using wildcard search on each of the words (separated by spaces). Retrieves results where at least one word must match. Example: ‘some other’
  • metadata (dict) – Filter out assets that do not match these metadata fields and values (case-sensitive). Format is {“key1”:”value1”,”key2”:”value2”}.
  • asset_subtrees (List[int]) – Filter out assets that are not linked to assets in the subtree rooted at these assets. Format is [12,345,6,7890].
  • min_created_time (str) – Filter out assets with createdTime before this. Format is milliseconds since epoch.
  • max_created_time (str) – Filter out assets with createdTime after this. Format is milliseconds since epoch.
  • min_last_updated_time (str) – Filter out assets with lastUpdatedtime before this. Format is milliseconds since epoch.
  • max_last_updated_time (str) – Filter out assets with lastUpdatedtime after this. Format is milliseconds since epoch.
Keyword Arguments:
 
  • sort (str) – Field to be sorted.
  • dir (str) – Sort direction (desc or asc)
  • limit (int) – Return up to this many results. Max is 1000, default is 25.
  • offset (int) – Offset from the first result. Sum of limit and offset must not exceed 1000. Default is 0.
  • boost_name (str) – Whether or not boosting name field. This option is test_experimental and can be changed.
Returns:

stable.assets.AssetListResponse.

Examples

Searching for assets:

client = CogniteClient()
res = client.assets.search_for_assets(name="myasset")
print(res)

Data Objects

class cognite.client.stable.assets.Asset(name, parent_id=None, description=None, metadata=None, ref_id=None, parent_name=None, parent_ref_id=None)

Bases: object

Data transfer object for assets.

Parameters:
  • name (str) – Name of asset. Often referred to as tag.
  • parent_id (int) – ID of parent asset, if any.
  • description (str) – Description of asset.
  • metadata (dict) – Custom , application specific metadata. String key -> String Value.
  • ref_id (str) – Reference ID used only in post request to disambiguate references to duplicate names.
  • parent_name (str) – Name of parent, this parent must exist in the same POST request.
  • parent_ref_id (str) – Reference ID of parent, to disambiguate if multiple nodes have the same name.
class cognite.client.stable.assets.AssetListResponse(internal_representation)

Bases: cognite.client._api_client.CogniteCollectionResponse

Assets Response Object

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

class cognite.client.stable.assets.AssetResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

Datapoints

Client

class cognite.client.stable.datapoints.DatapointsClient(**kwargs)
get_datapoints(name, start, end=None, aggregates=None, granularity=None, **kwargs) → cognite.client.stable.datapoints.DatapointsResponse

Returns a DatapointsObject containing a list of datapoints for the given query.

This method will automate paging for the user and return all data for the given time period.

Parameters:
  • name (str) – The name of the timeseries to retrieve data for.
  • start (Union[str, int, datetime]) – Get datapoints after this time. Format is N[timeunit]-ago where timeunit is w,d,h,m,s. E.g. ‘2d-ago’ will get everything that is up to 2 days old. Can also send time in ms since epoch or a datetime object which will be converted to ms since epoch UTC.
  • end (Union[str, int, datetime]) – Get datapoints up to this time. Same format as for start.
  • aggregates (list) – The list of aggregate functions you wish to apply to the data. Valid aggregate functions are: ‘average/avg, max, min, count, sum, interpolation/int, stepinterpolation/step’.
  • granularity (str) – The granularity of the aggregate values. Valid entries are : ‘day/d, hour/h, minute/m, second/s’, or a multiple of these indicated by a number as a prefix e.g. ‘12hour’.
Keyword Arguments:
 
  • workers (int) – Number of download workers to run in parallell. Defaults to 10.
  • include_outside_points (bool) – No description
  • protobuf (bool) – Download the data using the binary protobuf format. Only applicable when getting raw data. Defaults to True.
  • limit (str) – Max number of datapoints to return. If limit is specified, this method will not automate paging and will return a maximum of 100,000 dps.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.datapoints.DatapointsResponse

Examples

Getting the last 3 days of raw datapoints for a given time series:

client = CogniteClient()
res = client.datapoints.get_datapoints(name="my_ts", start="3d-ago")
print(res.to_pandas())
get_datapoints_frame(time_series, aggregates, granularity, start, end=None, **kwargs) → pandas.core.frame.DataFrame

Returns a pandas dataframe of datapoints for the given timeseries all on the same timestamps.

This method will automate paging for the user and return all data for the given time period.

Parameters:
  • time_series (list) – The list of timeseries names to retrieve data for. Each timeseries can be either a string containing the timeseries or a dictionary containing the names of thetimeseries and a list of specific aggregate functions.
  • aggregates (list) – The list of aggregate functions you wish to apply to the data for which you have not specified an aggregate function. Valid aggregate functions are: ‘average/avg, max, min, count, sum, interpolation/int, stepinterpolation/step’.
  • granularity (str) – The granularity of the aggregate values. Valid entries are : ‘day/d, hour/h, minute/m, second/s’, or a multiple of these indicated by a number as a prefix e.g. ‘12hour’.
  • start (Union[str, int, datetime]) – Get datapoints after this time. Format is N[timeunit]-ago where timeunit is w,d,h,m,s. E.g. ‘2d-ago’ will get everything that is up to 2 days old. Can also send time in ms since epoch or a datetime object which will be converted to ms since epoch UTC.
  • end (Union[str, int, datetime]) – Get datapoints up to this time. Same format as for start.
Keyword Arguments:
 
  • limit (str) – Max number of rows to return. If limit is specified, this method will not automate paging and will return a maximum of 100,000 rows.
  • workers (int) – Number of download workers to run in parallell. Defaults to 10.
Returns:

A pandas dataframe containing the datapoints for the given timeseries. The datapoints for all the timeseries will all be on the same timestamps.

Return type:

pandas.DataFrame

Examples

Get a dataframe of aggregated time series data:

client = CogniteClient()

res = client.datapoints.get_datapoints_frame(time_series=["ts1", "ts2"],
                aggregates=["avg"], granularity="30s", start="1w-ago")

print(res)

The timeseries parameter can take a list of strings and/or dicts on the following formats. This is useful for specifying aggregate functions on a per time series level:

Using strings:
    ['<timeseries1>', '<timeseries2>']

Using dicts:
    [{'name': '<timeseries1>', 'aggregates': ['<aggfunc1>', '<aggfunc2>']},
    {'name': '<timeseries2>', 'aggregates': []}]

Using both:
    ['<timeseries1>', {'name': '<timeseries2>', 'aggregates': ['<aggfunc1>', '<aggfunc2>']}]
get_latest(name, before=None) → cognite.client.stable.datapoints.LatestDatapointResponse

Returns a LatestDatapointObject containing the latest datapoint for the given timeseries.

Parameters:name (str) – The name of the timeseries to retrieve data for.
Returns:A data object containing the requested data with several getter methods with different output formats.
Return type:stable.datapoints.LatestDatapointsResponse

Examples

Get the latest datapoint from a time series before time x:

client = CogniteClient()
x = 1514761200000
client.datapoints.get_latest(name="my_ts", before=x)
get_multi_time_series_datapoints(datapoints_queries: List[cognite.client.stable.datapoints.DatapointsQuery], start, end=None, aggregates=None, granularity=None, **kwargs) → cognite.client.stable.datapoints.DatapointsResponseIterator

Returns a list of DatapointsObjects each of which contains a list of datapoints for the given timeseries.

This method will automate paging for the user and return all data for the given time period(s).

Parameters:
  • datapoints_queries (list[stable.datapoints.DatapointsQuery]) – The list of DatapointsQuery objects specifying which timeseries to retrieve data for.
  • start (Union[str, int, datetime]) – Get datapoints after this time. Format is N[timeunit]-ago where timeunit is w,d,h,m,s. E.g. ‘2d-ago’ will get everything that is up to 2 days old. Can also send time in ms since epoch or a datetime object which will be converted to ms since epoch UTC.
  • end (Union[str, int, datetime]) – Get datapoints up to this time. Same format as for start.
  • aggregates (list, optional) – The list of aggregate functions you wish to apply to the data. Valid aggregate functions are: ‘average/avg, max, min, count, sum, interpolation/int, stepinterpolation/step’.
  • granularity (str) – The granularity of the aggregate values. Valid entries are : ‘day/d, hour/h, minute/m, second/s’, or a multiple of these indicated by a number as a prefix e.g. ‘12hour’.
Keyword Arguments:
 

include_outside_points (bool) – No description.

Returns:

An iterator which iterates over stable.datapoints.DatapointsResponse objects.

Return type:

stable.datapoints.DatapointsResponseIterator

live_data_generator(name, update_frequency=1)

Generator function which continously polls latest datapoint of a timeseries and yields new datapoints.

Parameters:
  • name (str) – Name of timeseries to get latest datapoints for.
  • update_frequency (float) – Frequency to pull for data in seconds.
Yields:

dict – Dictionary containing timestamp and value of latest datapoint.

post_datapoints(name, datapoints: List[cognite.client.stable.datapoints.Datapoint]) → None

Insert a list of datapoints.

Parameters:
  • name (str) – Name of timeseries to insert to.
  • datapoints (List[stable.datapoints.Datapoint]) – List of datapoint data transfer objects to insert.
Returns:

None

Examples

Posting some dummy datapoints:

from cognite.client.stable.datapoints import Datapoint

client = CogniteClient()

start = 1514761200000
my_dummy_data = [Datapoint(timestamp=start+off, value=off) for off in range(100)]
client.datapoints.post_datapoints(ts_name, my_dummy_data)
post_datapoints_frame(dataframe) → None

Write a dataframe. The dataframe must have a ‘timestamp’ column with timestamps in milliseconds since epoch. The names of the remaining columns specify the names of the time series to which column contents will be written. Said time series must already exist.

Parameters:dataframe (pandas.DataFrame) – Pandas DataFrame Object containing the time series.
Returns:None

Examples

Post a dataframe with white noise:

client = CogniteClient()
ts_name = 'NOISE'

start = datetime(2018, 1, 1)
# The scaling by 1000 is important: timestamp() returns seconds
x = [(start + timedelta(days=d)).timestamp() * 1000 for d in range(100)]
y = np.random.normal(0, 1, 100)

# The time column must be called precisely 'timestamp'
df = pd.DataFrame({'timestamp': x, ts_name: y})

client.datapoints.post_datapoints_frame(df)
post_multi_time_series_datapoints(timeseries_with_datapoints: List[cognite.client.stable.datapoints.TimeseriesWithDatapoints], **kwargs) → None

Insert data into multiple timeseries.

Parameters:timeseries_with_datapoints (List[stable.datapoints.TimeseriesWithDatapoints]) – The timeseries with data to insert.
Keyword Arguments:
 use_gzip (bool) – Whether or not to gzip the request. Defaults to True.
Returns:None

Examples

Posting some dummy datapoints to multiple time series. This example assumes that the time series have already been created:

from cognite.client.stable.datapoints import TimeseriesWithDatapoints, Datapoint

start = 1514761200000
my_dummy_data_1 = [Datapoint(timestamp=ms, value=i) for i, ms in range(start, start+100)]
ts_with_datapoints_1 = TimeSeriesWithDatapoints(name="ts1", datapoints=my_dummy_data_1)

start = 1503331800000
my_dummy_data_2 = [Datapoint(timestamp=ms, value=i) for i, ms in range(start, start+100)]
ts_with_datapoints_2 = TimeSeriesWithDatapoints(name="ts2", datapoints=my_dummy_data_2)

my_dummy_data = [ts_with_datapoints_1, ts_with_datapoints_2]

client = CogniteClient()
res = client.datapoints.post_multi_time_series_datapoints(my_dummy_data)

Data Objects

class cognite.client.stable.datapoints.Datapoint(timestamp, value)

Bases: object

Data transfer object for datapoints.

Parameters:
  • timestamp (int, datetime) – The data timestamp in milliseconds since the epoch (Jan 1, 1970) or as a datetime object.
  • value (string) – The data value, Can be string or numeric depending on the metric.
class cognite.client.stable.datapoints.DatapointsQuery(name, aggregates=None, granularity=None, start=None, end=None, limit=None)

Bases: object

Data Query Object for Datapoints.

Parameters:
  • name (str) – Unique name of the time series.
  • aggregates (list) – The aggregate functions to be returned. Use default if null. An empty string must be sent to get raw data if the default is a set of aggregate functions.
  • granularity (str) – The granularity size and granularity of the aggregates.
  • start (str, int, datetime) – Get datapoints after this time. Format is N[timeunit]-ago where timeunit is w,d,h,m,s. Example: ‘2d-ago’ will get everything that is up to 2 days old. Can also send time in ms since epoch or as a datetime object.
  • end (str, int, datetime) – Get datapoints up to this time. The format is the same as for start.
class cognite.client.stable.datapoints.DatapointsResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Datapoints Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

class cognite.client.stable.datapoints.DatapointsResponseIterator(datapoints_objects)

Bases: object

Iterator for Datapoints Response Objects.

class cognite.client.stable.datapoints.LatestDatapointResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Latest Datapoint Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

class cognite.client.stable.datapoints.TimeseriesWithDatapoints(name, datapoints)

Bases: object

Data transfer object for a timeseries with datapoints.

Parameters:

Events

Client

class cognite.client.stable.events.EventsClient(**kwargs)
delete_events(event_ids: List[int]) → None

Deletes a list of events.

Parameters:event_ids (List[int]) – List of ids of events to delete.
Returns:None

Examples

Deleting a list of events:

client = CogniteClient()
res = client.events.delete_events(event_ids=[1,2,3,4,5])
get_event(event_id: int) → cognite.client.stable.events.EventResponse

Returns a EventResponse containing an event matching the id.

Parameters:event_id (int) – The event id.
Returns:A data object containing the requested event.
Return type:stable.events.EventResponse

Examples

Getting an event:

client = CogniteClient()
res = client.events.get_event(123)
print(res)
get_events(type=None, sub_type=None, asset_id=None, **kwargs) → cognite.client.stable.events.EventListResponse

Returns an EventListReponse object containing events matching the query.

Parameters:
  • type (str) – Type (class) of event, e.g. ‘failure’.
  • sub_type (str) – Sub-type of event, e.g. ‘electrical’.
  • asset_id (int) – Return events associated with this assetId.
Keyword Arguments:
 
  • sort (str) – Sort descending or ascending. Default ‘ASC’.
  • cursor (str) – Cursor to use for paging through results.
  • limit (int) – Return up to this many results. Maximum is 10000. Default is 25.
  • has_description (bool) – Return only events that have a textual description. Default null. False gives only those without description.
  • min_start_time (string) – Only return events from after this time.
  • max_start_time (string) – Only return events form before this time.
  • autopaging (bool) – Whether or not to automatically page through results. If set to true, limit will be disregarded. Defaults to False.
Returns:

A data object containing the requested event.

Return type:

stable.events.EventListResponse

Examples

Getting all events of a given type:

client = CogniteClient()
res = client.events.get_events(type="a special type", autopaging=True)
print(res.to_pandas())
post_events(events: List[cognite.client.stable.events.Event]) → cognite.client.stable.events.EventListResponse

Adds a list of events and returns an EventListResponse object containing created events.

Parameters:events (List[stable.events.Event]) – List of events to create.
Returns:stable.events.EventListResponse

Examples

Posting two events and linking them to an asset:

from cognite.client.stable.events import Event
client = CogniteClient()

my_events = [Event(start_time=1, end_time=10, type="workorder", asset_ids=[123]),
            Event(start_time=11, end_time=20, type="workorder", asset_ids=[123])]
res = client.events.post_events(my_events)
print(res)
search_for_events(description=None, type=None, subtype=None, min_start_time=None, max_start_time=None, min_end_time=None, max_end_time=None, min_created_time=None, max_created_time=None, min_last_updated_time=None, max_last_updated_time=None, metadata=None, asset_ids=None, asset_subtrees=None, **kwargs)

Search for events.

Parameters:
  • description (str) – Prefix and fuzzy search on description.
  • type (str) – Filter on type (case-sensitive).
  • subtype (str) – Filter on subtype (case-sensitive).
  • min_start_time (str) – Filter out events with startTime before this. Format is milliseconds since epoch.
  • max_start_time (str) – Filter out events with startTime after this. Format is milliseconds since epoch.
  • min_end_time (str) – Filter out events with endTime before this. Format is milliseconds since epoch.
  • max_end_time (str) – Filter out events with endTime after this. Format is milliseconds since epoch.
  • min_created_time (str) – Filter out events with createdTime before this. Format is milliseconds since epoch.
  • max_created_time (str) – Filter out events with createdTime after this. Format is milliseconds since epoch.
  • min_last_updated_time (str) – Filter out events with lastUpdatedtime before this. Format is milliseconds since epoch.
  • max_last_updated_time (str) – Filter out events with lastUpdatedtime after this. Format is milliseconds since epoch.
  • metadata (dict) – Filter out events that do not match these metadata fields and values (case-sensitive). Format is {“key1”:”value1”,”key2”:”value2”}.
  • asset_ids (List[int]) – Filter out events that are not linked to any of these assets. Format is [12,345,6,7890].
  • asset_subtrees (List[int]) – Filter out events that are not linked to assets in the subtree rooted at these assets. Format is [12,345,6,7890].
Keyword Arguments:
 
  • sort (str) – Field to be sorted.
  • dir (str) – Sort direction (desc or asc)
  • limit (int) – Return up to this many results. Max is 1000, default is 25.
  • offset (int) – Offset from the first result. Sum of limit and offset must not exceed 1000. Default is 0.
Returns:

stable.events.EventListResponse.

Examples

Perform a fuzzy search on event descriptions and get the first 3 results:

client = CogniteClient()
res = client.events.search_for_events(description="Something like this", limit=10)
print(res)

Data Objects

class cognite.client.stable.events.Event(start_time=None, end_time=None, description=None, type=None, sub_type=None, metadata=None, asset_ids=None)

Bases: object

Data transfer object for events.

Parameters:
  • start_time (int) – Start time of the event in ms since epoch.
  • end_time (int) – End time of the event in ms since epoch.
  • description (str) – Textual description of the event.
  • type (str) – Type of the event, e.g. ‘failure’.
  • sub_type (str) – Subtype of the event, e.g. ‘electrical’.
  • metadata (dict) – Customizable extra data about the event.
  • asset_ids (list[int]) – List of Asset IDs of related equipments that this event relates to.
class cognite.client.stable.events.EventListResponse(internal_representation)

Bases: cognite.client._api_client.CogniteCollectionResponse

Event List Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()
class cognite.client.stable.events.EventResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Event Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Files

Client

class cognite.client.stable.files.FilesClient(**kwargs)
delete_files(file_ids) → List

Delete

Parameters:file_ids (list[int]) – List of IDs of files to delete.
Returns:List of files deleted and files that failed to delete.

Examples

Delete two files:

client = CogniteClient()
res = client.files.delete_files([123, 234])
download_file(id: int, get_contents: bool = False) → Union[str, bytes]

Get list of files matching query.

Parameters:
  • id (int) – Path to file to upload, if omitted a upload link will be returned.
  • get_contents (bool, optional) – Boolean to determince whether or not to return file contents as string. Default is False and download url is returned.
Returns:

Download link if get_contents is False else file contents.

Return type:

Union[str, bytes]

Examples

Get a download url for the file:

client = CogniteClient()
res = client.files.download_file(id=12345)
download_url = res["downloadUrl"]

Download a file:

client = CogniteClient()
file_bytes = client.files.download_file(id=12345, get_contents=True)
get_file_info(id) → cognite.client.stable.files.FileInfoResponse

Returns information about a file.

Parameters:id (int) – Id of the file.
Returns:A data object containing the requested file information.
Return type:stable.files.FileInfoResponse

Examples

Get info a bout a specific file:

client = CogniteClient()
res = client.files.get_file_info(12345)
print(res)
list_files(name=None, directory=None, file_type=None, source=None, **kwargs) → cognite.client.stable.files.FileListResponse

Get list of files matching query.

Parameters:
  • name (str, optional) – List all files with this name.
  • directory (str, optional) – Directory to list files from.
  • source (str, optional) – List files coming from this source.
  • file_type (str, optional) – Type of files to list.
Keyword Arguments:
 
  • asset_id (list) – Returns all files associated with this asset id.
  • sort (str) – Sort descending or ascending. ‘ASC’ or ‘DESC’.
  • limit (int) – Number of results to return.
  • is_uploaded (bool) – List only uploaded files if true. If false, list only other files. If not set, list all files without considering whether they are uploaded or not.
  • autopaging (bool) – Whether or not to automatically page through results. If set to true, limit will be disregarded. Defaults to False.
  • cursor (str) – Cursor to use for paging through results.
Returns:

A data object containing the requested files information.

Return type:

stable.files.FileListResponse

Examples

List all files in a given directory:

client = CogniteClient()
res = client.files.list_files(directory="allfiles/myspecialfiles", autopaging=True)
print(res.to_pandas())
upload_file(file_name, file_path=None, directory=None, source=None, file_type=None, content_type=None, **kwargs) → Dict

Upload metadata about a file and get an upload link.

The link will expire after 30 seconds if not resumable. A resumable upload link is default. Such a link is one-time use and expires after one week. For more information, check this link: https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload. Use PUT request to upload file with the link returned.

If file_path is specified, the file will be uploaded directly by the SDK.

Parameters:
  • file_name (str) – File name. Max length is 256.
  • file_path (str, optional) – Path of file to upload, if omitted a upload link will be returned.
  • content_type (str, optional) – MIME type of your file. Required if file_path is specified.
  • directory (str, optional) – Directory containing the file. Max length is 512.
  • source (str, optional) – Source that this file comes from. Max length is 256.
  • file_type (str, optional) – File type. E.g. pdf, css, spreadsheet, .. Max length is 64.
Keyword Arguments:
 
  • metadata (dict) – Customized data about the file.
  • asset_ids (list) – IDs of assets related to this file.
  • resumable (bool) – Whether to generate a resumable URL or not. Default is true.
  • overwrite (bool) – Whether to overwrite existing data if duplicate or not. Default is false.
Returns:

A dictionary containing the field fileId and optionally also uploadURL if file_path is omitted.

Return type:

Dict

Examples

Upload a file and link it to an asset:

client = CogniteClient()
res = client.files.upload_file(file_name="myfile", file_path="/path/to/my/file.txt",
        content_type="text/plain", asset_ids=[123])
file_id = res["fileId"]

Data Objects

class cognite.client.stable.files.FileInfoResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

File Info Response Object.

Parameters:
  • id (int) – ID given by the API to the file.
  • file_name (str) – File name. Max length is 256.
  • directory (str) – Directory containing the file. Max length is 512.
  • source (dict) – Source that this file comes from. Max length is 256.
  • file_type (str) – File type. E.g. pdf, css, spreadsheet, .. Max length is 64.
  • metadata (dict) – Customized data about the file.
  • asset_ids (list[str]) – Names of assets related to this file.
  • uploaded (bool) – Whether or not the file is uploaded.
  • uploaded_at (int) – Epoc thime (ms) when the file was uploaded succesfully.
next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()
class cognite.client.stable.files.FileListResponse(internal_representation)

Bases: cognite.client._api_client.CogniteCollectionResponse

File List Response Object

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Login

Client

class cognite.client.stable.login.LoginClient(request_session: requests.sessions.Session, version: str = None, project: str = None, base_url: str = None, num_of_workers: int = None, cookies: Dict = None, headers: Dict = None, timeout: int = None)
status() → cognite.client.stable.login.LoginStatusResponse

Check login status

Returns:client.stable.login.LoginStatusResponse

Examples

Check the current login status:

client = CogniteClient()
login_status = client.login.status()
print(login_status)

Data Objects

class cognite.client.stable.login.LoginStatusResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

user

str – Current user

logged_in

bool – Is user logged in

project

str – Current project

project_id

str – Current project id

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

Raw

Client

class cognite.client.stable.raw.RawClient(**kwargs)
create_databases(database_names: list) → cognite.client.stable.raw.RawResponse

Creates databases in the Raw API and returns the created databases.

Parameters:database_names (list) – A list of databases to create.
Returns:A data object containing the requested data with several getter methods with different output formats.
Return type:stable.raw.RawResponse
create_rows(database_name: str = None, table_name: str = None, rows: List[cognite.client.stable.raw.RawRow] = None, ensure_parent=False, use_gzip=True) → None

Creates tables in the given Raw API database.

Parameters:
  • database_name (str) – The database to create rows in.
  • table_name (str) – The table names to create rows in.
  • rows (list[stable.raw.RawRow]) – The rows to create.
  • ensure_parent (bool) – Create database/table if it doesn’t exist already
  • use_gzip (bool) – Compress content using gzip
Returns:

None

create_tables(database_name: str = None, table_names: list = None) → cognite.client.stable.raw.RawResponse

Creates tables in the given Raw API database.

Parameters:
  • database_name (str) – The database to create tables in.
  • table_names (list) – The table names to create.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.raw.RawResponse

delete_databases(database_names: list, recursive: bool = False) → None

Deletes databases in the Raw API.

Parameters:database_names (list) – A list of databases to delete.
Returns:None
delete_rows(database_name: str = None, table_name: str = None, rows: List[cognite.client.stable.raw.RawRow] = None) → None

Deletes rows in the Raw API.

Parameters:
  • database_name (str) – The database to create tables in.
  • table_name (str) – The table name where the rows are at.
  • rows (list) – The rows to delete.
Returns:

None

delete_tables(database_name: str = None, table_names: list = None) → None

Deletes databases in the Raw API.

Parameters:
  • database_name (str) – The database to create tables in.
  • table_names (list) – The table names to create.
Returns:

None

get_databases(limit: int = None, cursor: str = None) → cognite.client.stable.raw.RawResponse

Returns a RawObject containing a list of raw databases.

Parameters:
  • limit (int) – A limit on the amount of results to return.
  • cursor (str) – A cursor can be provided to navigate through pages of results.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.raw.RawResponse

get_row(database_name: str = None, table_name: str = None, row_key: str = None) → cognite.client.stable.raw.RawResponse

Returns a RawObject containing a list of rows.

Parameters:
  • database_name (str) – The database name to retrieve rows from.
  • table_name (str) – The table name to retrieve rows from.
  • row_key (str) – The key of the row to fetch.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.raw.RawResponse

get_rows(database_name: str = None, table_name: str = None, limit: int = None, cursor: str = None) → cognite.client.stable.raw.RawResponse

Returns a RawObject containing a list of rows.

Parameters:
  • database_name (str) – The database name to retrieve rows from.
  • table_name (str) – The table name to retrieve rows from.
  • limit (int) – A limit on the amount of results to return.
  • cursor (str) – A cursor can be provided to navigate through pages of results.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.raw.RawResponse

get_tables(database_name: str = None, limit: int = None, cursor: str = None) → cognite.client.stable.raw.RawResponse

Returns a RawObject containing a list of tables in a raw database.

Parameters:
  • database_name (str) – The database name to retrieve tables from.
  • limit (int) – A limit on the amount of results to return.
  • cursor (str) – A cursor can be provided to navigate through pages of results.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.raw.RawResponse

Data Objects

class cognite.client.stable.raw.RawResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Raw Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

class cognite.client.stable.raw.RawRow(key, columns)

Bases: object

DTO for a row in a raw database.

The Raw API is a simple key/value-store. Each row in a table in a raw database consists of a unique row key and a set of columns.

Parameters:
  • key (str) – Unique key for the row.
  • columns (dict) – A key/value-map consisting of the values in the row.
repr_json()

Tagmatching

Client

class cognite.client.stable.tagmatching.TagMatchingClient(**kwargs)
tag_matching(tag_ids, fuzzy_threshold=0, platform=None) → cognite.client.stable.tagmatching.TagMatchingResponse

Returns a TagMatchingObject containing a list of matched tags for the given query.

This method takes an arbitrary string as argument and performs fuzzy matching with a user defined threshold toward tag ids in the system.

Parameters:
  • tag_ids (list) – The tag_ids to retrieve matches for.
  • fuzzy_threshold (int) – The threshold to use when searching for matches. A fuzzy threshold of 0 means you only want to accept perfect matches. Must be >= 0.
  • platform (str) – The platform to search on.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

stable.tagmatching.TagMatchingResponse

Data Objects

class cognite.client.stable.tagmatching.TagMatchingResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Tag Matching Response Object.

In addition to the standard output formats this data object also has a to_list() method which returns a list of names of the tag matches.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_list(first_matches_only=True)

Returns a list representation of the matches.

Parameters:first_matches_only (bool) – Boolean determining whether or not to return only the top match for each tag.
Returns:list of matched tags.
Return type:list
to_pandas()

Returns data as a pandas dataframe

Time Series

Client

class cognite.client.stable.time_series.TimeSeriesClient(**kwargs)
delete_time_series(name) → None

Delete a timeseries.

Parameters:name (str) – Name of timeseries to delete.
Returns:None

Examples

Delete a time series by name:

client = CogniteClient()

client.time_series.delete_time_series(name="my_ts_1")
get_time_series(prefix=None, description=None, include_metadata=False, asset_id=None, path=None, **kwargs) → cognite.client.stable.time_series.TimeSeriesListResponse

Returns an object containing the requested timeseries.

Parameters:
  • prefix (str) – List timeseries with this prefix in the name.
  • description (str) – Filter timeseries taht contains this string in its description.
  • include_metadata (bool) – Decide if the metadata field should be returned or not. Defaults to False.
  • asset_id (int) – Get timeseries related to this asset.
  • path (str) – Get timeseries under this asset path branch.
Keyword Arguments:
 
  • limit (int) – Number of results to return.
  • autopaging (bool) – Whether or not to automatically page through results. If set to true, limit will be disregarded. Defaults to False.
Returns:

A data object containing the requested timeseries with several getter methods with different output formats.

Return type:

stable.time_series.TimeSeriesListResponse

Examples

Get all time series for a given asset:

client = CogniteClient()
res = client.time_series.get_time_series(asset_id=123, autopaging=True)
print(res.to_pandas())
post_time_series(time_series: List[cognite.client.stable.time_series.TimeSeries]) → None

Create a new time series.

Parameters:time_series (list[stable.time_series.TimeSeries]) – List of time series data transfer objects to create.
Returns:None

Examples

Create a new time series:

from cognite.client.stable.time_series import TimeSeries
client = CogniteClient()

my_time_series = [TimeSeries(name="my_ts_1")]

client.time_series.post_time_series(my_time_series)
update_time_series(time_series: List[cognite.client.stable.time_series.TimeSeries]) → None

Update an existing time series.

For each field that can be updated, a null value indicates that nothing should be done.

Parameters:time_series (list[stable.time_series.TimeSeries]) – List of time series data transfer objects to update.
Returns:None

Examples

Update the unit of a time series:

from cognite.client.stable.time_series import TimeSeries
client = CogniteClient()

my_time_series = [TimeSeries(name="my_ts_1", unit="celsius")]

client.time_series.update_time_series(my_time_series)

Data Objects

class cognite.client.stable.time_series.TimeSeries(name, is_string=False, metadata=None, unit=None, asset_id=None, description=None, security_categories=None, is_step=None)

Bases: object

Data Transfer Object for a time series.

Parameters:
  • name (str) – Unique name of time series.
  • is_string (bool) – Whether the time series is string valued or not.
  • metadata (dict) – Metadata.
  • unit (str) – Physical unit of the time series.
  • asset_id (int) – Asset that this time series belongs to.
  • description (str) – Description of the time series.
  • security_categories (list(int)) – Security categories required in order to access this time series.
  • is_step (bool) – Whether or not the time series is a step series.
class cognite.client.stable.time_series.TimeSeriesListResponse(internal_representation)

Bases: cognite.client._api_client.CogniteCollectionResponse

Time series Response Object

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas(include_metadata: bool = False)

Returns data as a pandas dataframe

Parameters:include_metadata (bool) – Whether or not to include metadata fields in the resulting dataframe
class cognite.client.stable.time_series.TimeSeriesResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Time series Response Object

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

Experimental

Analytics

Models

Client

Data Objects

Time Series

Client

class cognite.client.experimental.time_series.TimeSeriesClient(**kwargs)
delete_time_series_by_id(ids: List[int]) → None

Delete multiple time series by id.

Parameters:ids (List[int]) – IDs of time series to delete.
Returns:None

Examples

Delete a single time series by id:

client = CogniteClient()

client.time_series.delete_time_series_by_id(ids=[my_ts_id])
get_multiple_time_series_by_id(ids: List[int]) → cognite.client.experimental.time_series.TimeSeriesResponse

Returns a TimeseriesResponse object containing the requested timeseries.

Parameters:ids (List[int]) – IDs of timeseries to look up
Returns:A data object containing the requested timeseries with several getter methods with different output formats.
Return type:client.experimental.time_series.TimeSeriesResponse
get_time_series_by_id(id: int) → cognite.client.experimental.time_series.TimeSeriesResponse

Returns a TimeseriesResponse object containing the requested timeseries.

Parameters:id (int) – ID of timeseries to look up
Returns:A data object containing the requested timeseries.
Return type:client.experimental.time_series.TimeSeriesResponse
search_for_time_series(name=None, description=None, query=None, unit=None, is_string=None, is_step=None, metadata=None, asset_ids=None, asset_subtrees=None, min_created_time=None, max_created_time=None, min_last_updated_time=None, max_last_updated_time=None, **kwargs) → cognite.client.experimental.time_series.TimeSeriesResponse

Returns a TimeSeriesResponse object containing the search results.

Parameters:
  • name (str) – Prefix and fuzzy search on name.
  • description (str) – Prefix and fuzzy search on description.
  • query (str) – Search on name and description using wildcard search on each of the words (separated by spaces). Retrieves results where at least on word must match. Example: “some other”
  • unit (str) – Filter on unit (case-sensitive)
  • is_string (bool) – Filter on whether the ts is a string ts or not.
  • is_step (bool) – Filter on whether the ts is a step ts or not.
  • metadata (Dict) – Filter out time series that do not match these metadata fields and values (case-sensitive). Format is {“key1”: “val1”, “key2”, “val2”}
  • asset_ids (List) – Filter out time series that are not linked to any of these assets. Format is [12,345,6,7890].
  • asset_subtrees (List) – Filter out time series that are not linked to assets in the subtree rooted at these assets. Format is [12,345,6,7890].
  • min_created_time (int) – Filter out time series with createdTime before this. Format is milliseconds since epoch.
  • max_created_time (int) – Filter out time series with createdTime after this. Format is milliseconds since epoch.
  • min_last_updated_time (int) – Filter out time series with lastUpdatedTime before this. Format is milliseconds since epoch.
  • max_last_updated_time (int) – Filter out time series with lastUpdatedTime after this. Format is milliseconds since epoch.
Keyword Arguments:
 
  • sort (str) – “createdTime” or “lastUpdatedTime”. Field to be sorted. If not specified, results are sorted by relevance score.
  • dir (str) – “asc” or “desc”. Only applicable if sort is specified. Default ‘desc’.
  • limit (int) – Return up to this many results. Maximum is 1000. Default is 25.
  • offset (int) – Offset from the first result. Sum of limit and offset must not exceed 1000. Default is 0.
  • boost_name (bool) – Whether or not boosting name field. This option is test_experimental and can be changed.
Returns:

A data object containing the requested timeseries with several getter methods with different output formats.

Return type:

client.experimental.time_series.TimeSeriesResponse

Data Objects

class cognite.client.experimental.time_series.TimeSeriesResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Time series Response Object

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas(include_metadata: bool = False)

Returns data as a pandas dataframe

Parameters:include_metadata (bool) – Whether or not to include metadata fields in the resulting dataframe

Datapoints

Client

class cognite.client.experimental.datapoints.DatapointsClient(**kwargs)
get_datapoints(id, start, end=None, aggregates=None, granularity=None, **kwargs) → cognite.client.experimental.datapoints.DatapointsResponse

Returns a DatapointsObject containing a list of datapoints for the given query.

This method will automate paging for the user and return all data for the given time period.

Parameters:
  • id (int) – The unique id of the timeseries to retrieve data for.
  • start (Union[str, int, datetime]) – Get datapoints after this time. Format is N[timeunit]-ago where timeunit is w,d,h,m,s. E.g. ‘2d-ago’ will get everything that is up to 2 days old. Can also send time in ms since epoch or a datetime object which will be converted to ms since epoch UTC.
  • end (Union[str, int, datetime]) – Get datapoints up to this time. Same format as for start.
  • aggregates (list) – The list of aggregate functions you wish to apply to the data. Valid aggregate functions are: ‘average/avg, max, min, count, sum, interpolation/int, stepinterpolation/step’.
  • granularity (str) – The granularity of the aggregate values. Valid entries are : ‘day/d, hour/h, minute/m, second/s’, or a multiple of these indicated by a number as a prefix e.g. ‘12hour’.
Keyword Arguments:
 
  • include_outside_points (bool) – No description
  • workers (int) – Number of download processes to run in parallell. Defaults to number returned by cpu_count().
  • limit (str) – Max number of datapoints to return. If limit is specified, this method will not automate paging and will return a maximum of 100,000 dps.
Returns:

A data object containing the requested data with several getter methods with different output formats.

Return type:

client.test_experimental.datapoints.DatapointsResponse

Data Objects

class cognite.client.experimental.datapoints.DatapointsResponse(internal_representation)

Bases: cognite.client._api_client.CogniteResponse

Datapoints Response Object.

next_cursor()

Returns next cursor to use for paging through results. Returns None if there are no more results.

previous_cursor()

Returns previous cursor to use for paging through results. Returns None if there are no more results.

to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

Sequences

Client

class cognite.client.experimental.sequences.SequencesClient(**kwargs)
delete_sequence_by_id(id: int) → None

Deletes the sequence with the given id.

Parameters:id (int) – ID of the sequence to delete
Returns:None
get_data_from_sequence(id: int, inclusive_from: int = None, inclusive_to: int = None, limit: int = 100, column_ids: List[int] = None) → cognite.client.experimental.sequences.SequenceDataResponse

Gets data from the given sequence.

Parameters:
  • id (int) – id of the sequence.
  • inclusive_from (int) – Row number to get from (inclusive). If set to None, you’ll get data from the first row that exists.
  • inclusive_to (int) – Row number to get to (inclusive). If set to None, you’ll get data to the last row that exists (depending on the limit).
  • limit (int) – How many rows to return.
  • column_ids (List[int]) – ids of the columns to get data for.
Returns:

A data object containing the requested sequence.

Return type:

client.test_experimental.sequences.SequenceDataResponse

get_sequence_by_external_id(external_id: str) → cognite.client.experimental.sequences.Sequence

Returns a Sequence object containing the requested sequence.

Parameters:external_id (int) – External ID of the sequence to look up
Returns:A data object containing the requested sequence.
Return type:test_experimental.dto.Sequence
get_sequence_by_id(id: int) → cognite.client.experimental.sequences.Sequence

Returns a Sequence object containing the requested sequence.

Parameters:id (int) – ID of the sequence to look up
Returns:A data object containing the requested sequence.
Return type:client.test_experimental.sequences.Sequence
post_data_to_sequence(id: int, rows: List[cognite.client.experimental.sequences.Row]) → None

Posts data to a sequence.

Parameters:
  • id (int) – ID of the sequence.
  • rows (list) – List of rows with the data.
Returns:

None

post_sequences(sequences: List[cognite.client.experimental.sequences.Sequence]) → cognite.client.experimental.sequences.Sequence

Create a new time series.

Parameters:sequences (list[test_experimental.dto.Sequence]) – List of sequence data transfer objects to create.
Returns:The created sequence
Return type:client.test_experimental.sequences.Sequence

Data Objects

class cognite.client.experimental.sequences.Column(id: int = None, name: str = None, external_id: str = None, value_type: str = None, metadata: dict = None)

Bases: object

Data transfer object for a column.

Parameters:
  • id (int) – ID of the column.
  • name (str) – Name of the column.
  • external_id (str) – External ID of the column.
  • value_type (str) – Data type of the column.
  • metadata (dict) – Custom, application specific metadata. String key -> String Value.
static from_JSON(the_column: dict)
class cognite.client.experimental.sequences.Row(row_number: int, values: List[cognite.client.experimental.sequences.RowValue])

Bases: object

Data transfer object for a row of data in a sequence.

Parameters:
  • row_number (int) – The row number for this row.
  • values (list) – The values in this row.
static from_JSON(the_row: dict)
get_row_as_csv()
class cognite.client.experimental.sequences.RowValue(column_id: int, value: str)

Bases: object

Data transfer object for the value in a row in a sequence.

Parameters:
  • column_id (int) – The ID of the column that this value is for.
  • value (str) – The actual value.
static from_JSON(the_row_value: dict)
class cognite.client.experimental.sequences.Sequence(id: int = None, name: str = None, external_id: str = None, asset_id: int = None, columns: List[cognite.client.experimental.sequences.Column] = None, description: str = None, metadata: dict = None)

Bases: object

Data transfer object for a sequence.

Parameters:
  • id (int) – ID of the sequence.
  • name (str) – Name of the sequence.
  • external_id (str) – External ID of the sequence.
  • asset_id (int) – ID of the asset the sequence is connected to, if any.
  • columns (List[Column]) – List of columns in the sequence.
  • description (str) – Description of the sequence.
  • metadata (dict) – Custom, application specific metadata. String key -> String Value.
static from_JSON(the_sequence: dict)
class cognite.client.experimental.sequences.SequenceDataRequest(inclusive_from: int, inclusive_to: int, limit: int = 100, column_ids: List[int] = None)

Bases: object

Data transfer object for requesting sequence data.

Parameters:
  • inclusive_from (int) – Row number to get from (inclusive).
  • inclusive_to (int) – Row number to get to (inclusive).
  • limit (int) – How many rows to return.
  • column_ids (List[int]) – ids of the columns to get data for.
class cognite.client.experimental.sequences.SequenceDataResponse(rows: List[cognite.client.experimental.sequences.Row])

Bases: object

Data transfer object for the data in a sequence, used when receiving data.

Parameters:rows (list) – List of rows with the data.
static from_JSON(the_data: dict)
to_json()

Returns data as a json object

to_pandas()

Returns data as a pandas dataframe

Data Transfer Service