Skip to main content

Python connector to download information collected in SmartCitizen API

Project description

Python application

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)
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartcitizen_connector-1.4.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartcitizen_connector-1.4.0-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file smartcitizen_connector-1.4.0.tar.gz.

File metadata

  • Download URL: smartcitizen_connector-1.4.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for smartcitizen_connector-1.4.0.tar.gz
Algorithm Hash digest
SHA256 03c644e9053729568196862c811e1b3070c60c83441aeb8ac791b678fb60834e
MD5 41610436b6f3a572fbd3bc4fa430074c
BLAKE2b-256 ded0311f1bf6bc8515030ec4f5370f39eab9a4d0dd0b9742d35f69e91562caf6

See more details on using hashes here.

File details

Details for the file smartcitizen_connector-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for smartcitizen_connector-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af8fa96185a856a44a8e97017ad2cac9eb7bfffd45ac000a746e5918866f4272
MD5 83cf21c52a4736e16c480267d53e582c
BLAKE2b-256 73496aaac207567c02273ec2b9a01c98fb0e1021600d7c452aad92c13678dfb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page