Library for connecting to iobeam, the data analysis platform for the Internet of Things.
Project description
`iobeam <http://iobeam.com>`__ is a data platform for connected devices.
Please note that we are currently invite-only. You will need an invite to generate a valid token and use our APIs. (Sign up `here <http://iobeam.com>`__ for an invite.)
Before you start
pip install requests
Installation
To install with pip:
pip install iobeam
To install from source:
git clone https://github.com/iobeam/iobeam-client-python.git
Then make sure that the iobeam-client-python folder is in your PYTHONPATH.
Overview
This library allows Python clients to send data to the iobeam Cloud.
At a high-level, here’s how it works:
- Build an iobeam client object with your project_id andproject_token
- Register your device to get an auto-generated device_id. Optionally,you can initialize the object with a previously registered device_id inthe previous step and skip this step
- Create a iobeam.DataPoint object for each time-series data point. Or,for a collection of data points, create a iobeam.DataSeries object.
Add the DataPoint under your series_name (e.g., “temperature”)
When you’re ready, send your data to the iobeam Cloud
Getting Started
iobeam Initialization
Without a registered ``device_id``
Let iobeam generate one for you:
from iobeam import iobeam
...
builder = iobeam.ClientBuilder(PROJECT_ID, PROJECT_TOKEN) \
.saveToDisk().registerDevice()
iobeamClient = builder.build()
Provide your own (must be unique to your project):
from iobeam import iobeam
...
builder = iobeam.ClientBuilder(PROJECT_ID, PROJECT_TOKEN) \
.saveToDisk().registerDevice(deviceId="my_desired_id")
iobeamClient = builder.build()
With a registered ``device_id``
from iobeam import iobeam
...
builder = iobeam.ClientBuilder(PROJECT_ID, PROJECT_TOKEN) \
.saveToDisk().setDeviceId(DEVICE_ID)
iobeamClient = builder.build()
Advanced: not saving to disk
builder = iobeam.ClientBuilder(PROJECT_ID, PROJECT_TOKEN).registerDevice() iobeamClient = builder.build()
Tracking Time-series Data
For each time-series data point, create a iobeam.DataPoint object:
t = getTemperature() d = iobeam.DataPoint(t) # You can also pass a specific timestamp now = ... # e.g., now = int(time.time()*1000) (import time first) d = iobeam.DataPoint(t, timestamp=now)
iobeamClient.addDataPoint("temperature", d)
now = ... # current time
dt = iobeam.DataPoint(getTemperature(), timestamp=now)
dh = iobeam.DataPoint(getHumidity(), timestamp=now)
iobeamClient.addDataPoint("temperature", dt)
iobeamClient.addDataPoint("humidity", dh)
Connecting to the iobeam Cloud
iobeamClient.send()
Full Example
Here’s the full source code for our example:
from iobeam import iobeam
import time
# Constants initialization
PATH = ... # Can be None if you don't want to persist device_id to disk
PROJECT_ID = ... # int
PROJECT_TOKEN = ... # String
...
# Init iobeam
builder = iobeam.ClientBuilder(PROJECT_ID, PROJECT_TOKEN) \
.saveToDisk().registerDevice()
iobeamClient = builder.build()
...
# Data gathering
now = int(time.time()*1000)
dt = iobeam.DataPoint(getTemperature(), timestamp=now)
dh = iobeam.DataPoint(getHumidity(), timestamp=now)
iobeamClient.addDataPoint("temperature", dt)
iobeamClient.addDataPoint("humidity", dh)
...
# Data transmission
iobeamClient.send()
Retrieving Data
In the simplest form, here is how you make a few different queries:
# all series from all devices in project PROJECT_ID q = iobeam.QueryReq(PROJECT_ID) # all series from device DEVICE_ID in project PROJECT_ID q = iobeam.QueryReq(PROJECT_ID, deviceId=DEVICE_ID) # series "temp" from device DEVICE_ID in project PROJECT_ID q = iobeam.QueryReq(PROJECT_ID, deviceId=DEVICE_ID, seriesName="temp")
Then to actually execute the query:
# token is a project token with read access res = iobeam.MakeQuery(token, q)
Your result will look something like this:
{ "result": [
{
"project_id": "<PROJECT_ID>",
"device_id": "<DEVICE_ID>",
"name": "temp",
"data": [
{
"time": 1427316488000,
"value": 22.23
},
{
"time": 1427316489000,
"value": 22.22
}, ...
]
}, ...
],
"timefmt": "msec"
}
Adjusting Your Query
# start with this basic query q = iobeam.QueryReq(PROJECT_ID, deviceId=DEVICE_ID, seriesName="temp") # Last 5 results after a given START_TIME: q = q.limit(5).fromTime(START_TIME) # All results between two times, START and END q = q.fromTime(START).toTime(END) # All results where the value is greater than 0 q = q.greaterThan(0)
The full list of (chainable) parameters:
limit(limit) fromTime(time) toTime(time) greaterThan(value) lessThan(value) equals(value)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iobeam-0.2.0.zip.
File metadata
- Download URL: iobeam-0.2.0.zip
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4923a0ae20d4ab2830f680fcd48fe96c959d647b19fa0eb56478ebb93bcf16
|
|
| MD5 |
4fc30a88c8c7bd161a5fa0a124031182
|
|
| BLAKE2b-256 |
7aeb19d512a2947919f8732ede56f11357407999ef8d2e2d14f3cfeb1157a6f2
|
File details
Details for the file iobeam-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: iobeam-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3da0b10ba1557c3496259577ce6fe9e4e3ec479d25c3b17fe48f21ac122d4345
|
|
| MD5 |
902221f288673e05871c57e42b0131af
|
|
| BLAKE2b-256 |
f055f0d720455a4deae4e782cfac74c71a730c2952872fca2da3d733da847c81
|