Welcome to Xively Python’s documentation

xively-python is a wrapper around Xively’s REST API to make working with the connected object cloud easy and pythonic.

The library has been published to PyPI, so installing it should be as simple as running pip install xively-python from your command prompt.

Example:

>>> import xively
>>> api = xively.XivelyAPIClient("YOUR_API_KEY")
>>> feed = api.feeds.get(7021)
>>> # Viewing datapoints
>>> import datetime
>>> start = datetime.datetime(2013, 1, 1, 14, 14, 55)
>>> stream = feed.datastreams[0]
>>> points = stream.datapoints.history(start=start, duration='1second')
>>> list(points)  
[xively.Datapoint(datetime.datetime(2013, 1, 1, 14, 14, 55, 118845), '0.25741970'), ...]
>>> # Updating a feed
>>> import datetime
>>> now = datetime.datetime.utcnow()
>>> feed.datastreams = [
...     xively.Datastream(id='sensor1', current_value=37.2, at=now),
...     xively.Datastream(id='sensor2', current_value='normal', at=now),
...     xively.Datastream(id='sensor3', current_value=19, at=now),
... ]
>>> feed.update()
>>> # Uploading new points
>>> import random
>>> randompoints = [
...     xively.Datapoint(datetime.datetime.utcnow(), random.random()),
...     xively.Datapoint(datetime.datetime.utcnow(), random.random()),
...     xively.Datapoint(datetime.datetime.utcnow(), random.random()),
... ]
>>> stream.datapoints = randompoints
>>> stream.update(fields='datapoints')

Contents:

Indices and tables

Table Of Contents

Next topic

API Reference

This Page