API Reference

This page is the core API reference for the heedy python client.

Objects

class heedy.objects.objects.Object(objectData, session)[source]

Bases: heedy.base.APIObject

property app
delete(**kwargs)

Deletes the object

property kv
notify(*args, **kwargs)
property owner
props = {'access', 'description', 'icon', 'key', 'meta', 'name', 'owner_scope', 'tags'}
read(**kwargs)

Read the object

update(**kwargs)[source]

Updates the given data:

o.update(name="My new name",description="my new description")
class heedy.objects.objects.Objects(constraints, session)[source]

Bases: heedy.base.APIList

create(name, meta={}, otype='timeseries', **kwargs)[source]

Creates a new object of the given type (timeseries by default).

heedy.objects.registry.getObject(objectData, session)[source]

Heedy allows multiple different object types. getObject uses the registered object type to initialize the given data to the correct class. If the object is of an unregistered type, it returns a base Object object.

heedy.objects.registry.registerObjectType(objectType, objectClass)[source]

registerObjectType allows external libraries to implement object types available through heedy plugins. All you need to do is subclass Object, and register the corresponding type!

Return type

None

Timeseries

class heedy.objects.timeseries.DatapointArray(data=[])[source]

Bases: list

The DatapointArray is a convenience wrapper on data returned from timeseries. It allows a bit of extra functionality to make working with timeseries simpler.

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

d()[source]

Returns just the data portion of the datapoints as a list

dt()[source]

Returns just the durations of all datapoints.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

loadJSON(filename)[source]

Adds the data from a JSON file. The file is expected to be in datapoint format:

d = DatapointArray().loadJSON("myfile.json")

Can be used to read data dumped by writeJSON.

mean()[source]

Gets the mean of the data portions of all datapoints within

merge(array)[source]

Adds the given array of datapoints to the generator. It assumes that the datapoints are formatted correctly for heedy, meaning that they are in the format:

[{"t": unix timestamp, "d": data}]

The data does NOT need to be sorted by timestamp - this function sorts it for you

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

raw()[source]

Returns array as a raw python array. For cases where for some reason the DatapointArray wrapper does not work for you

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort(f=<function DatapointArray.<lambda>>)[source]

Sort here works by sorting by timestamp by default

sum()[source]

Gets the sum of the data portions of all datapoints within

t()[source]

Returns just the timestamp portion of the datapoints as a list. The timestamps are in python datetime’s date format.

tshift(t)[source]

Shifts all timestamps in the datapoint array by the given number of seconds. It is the same as the ‘tshift’ pipescript transform.

Warning: The shift is performed in-place! This means that it modifies the underlying array:

d = DatapointArray([{"t":56,"d":1}])
d.tshift(20)
print(d) # [{"t":76,"d":1}]
writeJSON(filename)[source]

Writes the data to the given file:

DatapointArray([{"t": unix timestamp, "d": data}]).writeJSON("myfile.json")

The data can later be loaded using loadJSON.

class heedy.objects.timeseries.Timeseries(objectData, session)[source]

Bases: heedy.objects.objects.Object

property app
append(data, duration=0)[source]

inserts one datapoint with the given data, and appends it to the timeseries, using the current timestamp:

s.append("Hello World!")
delete(**kwargs)

Deletes the object

insert(data, timestamp=None, duration=0)[source]
insert_array(datapoint_array, **kwargs)[source]

given an array of datapoints, inserts them to the timeseries. This is different from append(), because it requires an array of valid datapoints, whereas append only requires the data portion of the datapoint, and fills out the rest:

s.insert_array([{"d": 4, "t": time.time()},{"d": 5, "t": time.time(), "dt": 5.3}])

Each datapoint can optionally also contain a “dt” parameter with the datapoint’s duration in seconds. A time series can’t have multiple datapoints with the same timestamp, so such datapoints are automatically overwritten by default. Using method=”insert” will throw an error if a timestamp conflicts with an existing one.

property kv
length(actions=False)[source]
notify(*args, **kwargs)
property owner
props = {'access', 'description', 'icon', 'key', 'meta', 'name', 'owner_scope', 'tags'}
read(**kwargs)

Read the object

remove(**kwargs)[source]

Removes the given data from the timeseries

update(**kwargs)

Updates the given data:

o.update(name="My new name",description="my new description")
heedy.objects.timeseries.parseTime(t)[source]

Apps

class heedy.apps.App(access_token, url='http://localhost:1324', session='sync', cached_data={})[source]

Bases: heedy.base.APIObject

delete(**kwargs)

Deletes the object

notify(*args, **kwargs)
property owner
props = {'description', 'icon', 'name', 'settings', 'settings_schema'}
read(**kwargs)

Read the object

update(**kwargs)

Updates the given data:

o.update(name="My new name",description="my new description")
class heedy.apps.Apps(constraints, session)[source]

Bases: heedy.base.APIList

create(name, **kwargs)[source]

Users

class heedy.users.User(username, session, cached_data={})[source]

Bases: heedy.base.APIObject

delete(**kwargs)

Deletes the object

property kv
notify(*args, **kwargs)
props = {'description', 'icon', 'name', 'username'}
read(**kwargs)

Read the object

update(**kwargs)

Updates the given data:

o.update(name="My new name",description="my new description")
property username
class heedy.users.Users(constraints, session)[source]

Bases: heedy.base.APIObject

create(username, password, **kwargs)[source]
delete(**kwargs)

Deletes the object

notify(*args, **kwargs)
props = {'description', 'icon', 'name'}
read(**kwargs)

Read the object

update(**kwargs)

Updates the given data:

o.update(name="My new name",description="my new description")

Plugins

class heedy.plugins.Plugin(config=None, session='async')[source]

Bases: object

copy()[source]
fire(event)[source]

Fires the given event

async forward(request, data=None, headers={}, run_as=None, overlay=None)[source]

Forwards the given request to the underlying database. It only functions in async mode.

Returns the response.

hasAccess(request, scope)[source]
isAdmin(request)[source]
isApp(request)[source]
isUser(request)[source]
property name
notify(*args, **kwargs)[source]
objectRequest(request)[source]
query_as(accessor)[source]
async respond_forwarded(request, **kwargs)[source]

Responds to the request with the result of forward()