ngsildclient.api.temporal#

Functions

troes_to_dataframe(troes)

Classes

Pagination([count, pagesize, next_url, prev_url])

Temporal(client, url)

A wrapper for the NGSI-LD API temporal endpoint.

TemporalResult(result[, pagination])

class ngsildclient.api.temporal.Pagination(count=0, pagesize=0, next_url=None, prev_url=None)[source]#

Bases: object

class ngsildclient.api.temporal.Temporal(client, url)[source]#

Bases: object

A wrapper for the NGSI-LD API temporal endpoint.

get(eid, attrs=None, ctx=None, verbose=False, pagesize=0, as_dataframe=False)[source]#

Retrieve the Temporal Representation of (an) Entity (TRoE) given its id.

If already dealing with an entity instance one can provide the entity itself instead of its id.

Parameters
  • eid (Union[EntityId, Entity]) – The entity identifier or the entity instance

  • attrs (List[str]) – The list of the attributes (changing over time) you’re interested in

  • ctx (str) – The context

  • verbose (bool) – Default is False, meaning the result is formatted as simplified TRoE.

  • as_dataframe (bool) – Default is false, meaning it returns JSON TRoE. If set returns a pandas dataframe. Requires pandas.

Returns

A dict equivalent to the Temporal Representation of the Entity

Return type

dict

query(*, eid=None, type=None, attrs=None, q=None, gq=None, ctx=None, verbose=False, tq=None, lastn=0, pagesize=0, as_dataframe=False)[source]#

Retrieve Temporal Representation of Entities (TRoE) given id, or type and/or query string.

Retrieve all TRoEs matching the criteria. Do the dirty pagination job for you, sending under the wood as many requests as needed. Assume data hold in memory. Should not be an issue except for very large datasets.

Parameters
  • eid (Union[EntityId, Entity]) – The entity identifier or the entity instance

  • etype (str) – The entity’s type

  • attrs (List[str]) – The list of the attributes (changing over time) you’re interested in

  • ctx (str) – The context

  • q (str) – The query string (NGSI-LD Query Language)

  • gq (str) – The geoquery string (NGSI-LD Geoquery Language)

  • verbose (bool) – Default is False, meaning the result is formatted as simplified TRoE.

  • tq (TemporalQuery) – The temporal query as a py:class:: TemporalQuery instance

  • lastn (int) – Among the temporal values, limit the result to the latest <lastn> values. By default returns all values.

  • pagesize (int) – By default the broker pagesize default.

  • as_dataframe (bool) – Default is false, meaning it returns JSON TRoE. If set returns a pandas dataframe. Requires pandas.

  • limit (int) – The number of entities retrieved in each request

Returns

The Temporal Representation of the Entities matching the given criteria

Return type

list[dict]

Example

>>> with Client() as client:
>>>     troe = client.temporal.query(type="RoomObserved")
class ngsildclient.api.temporal.TemporalResult(result, pagination=None)[source]#

Bases: object