Python SDK for reading and writing signals to Clarify.
Project description
PyClarify
Useful tutorials and documentation
- PyClarify SDK
- PyClarify documentation
- Clarify Developer documentation
- Basic tutorial on using Python with Clarify
- Clarify Forecast tutorial
- Pattern Recognition tutorial
- Google Cloud Hosting tutorial
Prerequisites
In order to start using the Python SDK, you need
- To know a bit of Python. For a refresher, see the Official Python tutorial.
- Python3 (>= 3.7) and pip.
- Credentials from a Clarify integration. See the introduction notebook for a complete introduction.
Install and import PyClarify
To install this package:
$ pip install pyclarify
import pyclarify
Interact with Clarify
PyClarify provides a fast and easy way to interact with Clarify using the APIClient
and ClarifyClient
class.
This class takes as an argument the path of your credentials in string format, which should always be the first step when starting to interact with PyClarify.
The APIClient
and ClarifyClient
class can do the almost the same operations, but the ClarifyClient
provides a more pythonic way.
For information about the Clarify Developer documentation click here.
Using Python with Clarify
Use colab to learn fast end easy how to interact with Clarify using Python. In this introduction tutorial you will learn all the basics to get you started.
Quickstart
Save signals
Example:
from pyclarify import ClarifyClient, SignalInfo
client = ClarifyClient("./clarify-credentials.json")
signal = SignalInfo(
name = "Home temperature",
description = "Temperature in the bedroom",
labels = {"data-source": ["Raspberry Pi"], "location": ["Home"]}
)
response = client.save_signals(input_ids=["<INPUT_ID>"], signals=[signal], create_only=False)
print(response.json())
Insert data into a signal
Example:
from pyclarify import DataFrame, ClarifyClient
client = APIClient("./clarify-credentials.json")
date = ["2021-11-01T21:50:06Z", "2021-11-02T21:50:06Z"]
data = DataFrame(
series={"<INPUT_ID_1>": [1, None], "<INPUT_ID_2>": [None, 5]},
times = date,
)
response = client.insert(data)
print(response.json())
Get metadata from signals and/or items
Example:
from pyclarify import ClarifyClient
client = ClarifyClient("./clarify-credentials.json")
response = client.select_signals(
ids = ['<SIGNAL_ID>'],
name = "Electricity",
labels = {"city": "Trondheim"},
limit = 10,
skip = 0,
include_items = False
)
print(response.json())
Publish signals
Example:
from pyclarify import ClarifyClient, Item
client = ClarifyClient("./clarify-credentials.json")
item = Item(
name = "Home temperature",
description = "Temperature in the bedroom",
labels = {"data-source": ["Raspberry Pi"], "location": ["Home"]},
visible=True
)
response = client.publish_signals(signal_ids=['<SIGNAL_ID>'], items=[item], create_only=False)
print(response.json())
Get Item data
Example:
from pyclarify import ClarifyClient
client = ClarifyClient("./clarify-credentials.json")
response = client.select_items_data(
ids = ['<ITEM_ID>'],
limit = 10,
skip = 0,
not_before = "2021-10-01T12:00:00Z",
before = "2021-11-10T12:00:00Z",
rollup = "P1DT"
)
print(response.json())
Get Item metadata
Example:
from pyclarify import ClarifyClient
client = ClarifyClient("./clarify-credentials.json")
response = client.select_items_metadata(
ids = ['<ITEM_ID>'],
name = "Electricity",
labels = {"city": "Trondheim"},
limit = 10,
skip = 0
)
print(response.json())
Changelog
Wondering about upcoming or previous changes to the SDK? Take a look at the CHANGELOG.
Contributing
Want to contribute? Check out CONTRIBUTING.
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
Hashes for pyclarify-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7c5f3add49d428c76568e69dd96c5e89990907e1553bc1f56e7b7844dfef82a |
|
MD5 | 05e3b7038ce77c38811041eb53055776 |
|
BLAKE2b-256 | 0d66de83d19313309fd8552ecf049086615e57b2177f25fe164b9b2e8a948469 |