Smart Citizen Connector
This is a connector written in python to get and post data from the Smart Citizen API. It can be used in conjunction with other scripts such as scdata.
Installation
Simply do:
pip install smartcitizen-connector
Development
Clone the repo and install in editable mode:
git clone git@github.com:fablabbcn/smartcitizen-connector.git
cd smartcitizen-connector
pip install -e .
Usage
See docs for examples. a basic usage is shown below:
- Device (create and get data):
from smartcitizen_connector import SCDevice
import asyncio
d = SCDevice(16549)
print (d.json.name)
print (d.json.owner)
await d.get_data(freq = '1Min') # returns pandas dataframe
print (d.data)
- Search (see docs)
from smartcitizen_connector import search_by_query
# Users whose username contains "osc"
search_by_query(endpoint = 'users', key="username", search_matcher="cont", value="osc")
# Devices in which
search_by_query(endpoint = 'devices', key="name", search_matcher="cont", value="air")
# Devices created after (date greater than) "2023-08-11"
search_by_query(endpoint = 'devices', key="created_at", search_matcher="gt", value="2023-08-11")
- Authentication
Set the following environment variable with your Smart Citizen API token:
SC_BEARER=xxxxx
Metadata
Release files for smartcitizen-connector 1.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| smartcitizen_connector-1.5.2.tar.gz | 31.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smartcitizen_connector-1.5.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 67.3 kB
Release files / smartcitizen_connector-1.5.2.tar.gz
| Download URL | smartcitizen_connector-1.5.2.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe7537b7f0f2432d71657c2f4dcdee6ae19f71f6e55cb3acdb43697f3e5d8d4f
|
|
BLAKE2b-256 checksum How to use checksums |
4bacacd785bb6c708903171bea9ffb146c85cc69d16d1a863c0bd8ef423e17f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / smartcitizen_connector-1.5.2-py3-none-any.whl
| Download URL | smartcitizen_connector-1.5.2-py3-none-any.whl |
|---|---|
| Size | 36.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be048783daab5a2dacded7d0cd84afacf7c5e4a6da68067633a3d854fecd5b80
|
|
BLAKE2b-256 checksum How to use checksums |
49ef2810c3f78828abb417c07e60aa48f44c5da0d0efae6376d6a0b43718810d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|