Skip to main content

Onboard API SDK

Project description

Onboard Portal Python SDK

PyPI PyPI - Python Version PyPI - Status PyPI - License

This package provides Python bindings to Onboard Data's building data API. For more details, you can navigate to the API & Docs Page to read the Getting Started Documentation section in the portal. You'll have access to this page once you've signed up for our sandbox or you've been given access to your organization's account.

API Access

You'll need an API key or existing account in order to use this client. If you don't have one and would like to start prototyping against an example building please request a key here.

Once you have a key, data access is explicitly granted by attaching one or more 'scopes' to the key. Our endpoints are grouped by scope on the swagger documentation viewer.

You can also learn more about this client on our docs!

Client usage example

First, you'll need to install the client (requires Python >= 3.8)

$ pip install onboard.client

Now you can use the client to fetch timeseries data for sensors by building or based on type. This example requires an API key with the scopes general and buildings:read.

from onboard.client import OnboardClient
client = OnboardClient(api_key='ob-p-your-key-here')

client.whoami()  # verify access & connectivity

client.get_all_point_types()  # retrieve available types of sensors

# retrieve the past 6 hours of data for sensors measuring CO2 ppm
from datetime import datetime, timezone, timedelta
from onboard.client.models import PointSelector, TimeseriesQuery, PointData
from typing import List

query = PointSelector()
query.point_types = ['zone_air_co2_concentration_sensor']
query.buildings = ['Office Building']  # one of the example buildings available in the sandbox
selection = client.select_points(query)
end = datetime.utcnow().replace(tzinfo=timezone.utc)
start = end - timedelta(hours=6)

timeseries_query = TimeseriesQuery(point_ids=selection['points'], start=start, end=end)  # Or `TimeseriesQuery(selector=query, ...)`

sensor_metadata = client.get_points_by_ids(selection['points'])
sensor_data: List[PointData] = list(client.stream_point_timeseries(timeseries_query, resample_mins=5))

Retries

The OnboardClient also exposes urllib3.util.retry.Retry to allow configuring retries in the event of a network issue. An example for use would be

from onboard.client import OnboardClient
from urlilib3.util.retry import Retry

retry = Retry(total=3, backoff_factor=0.3, status_forcelist=(500, 502, 504))
client = OnboardClient(api_key='ob-p-your-key-here', retry=retry)

Staging client usage

We provide an additional client object for users who wish to modify their building equipment and points in the "staging area" before those metadata are promoted to the primary tables. API keys used with the staging client require the staging scope, and your account must be authorized to perform READ and UPDATE operations on the building itself.

The staging area provides a scratchpad interface, where arbitrary additional columns can be added to points or equipment by using the prefix p. or e.. Any un-prefixed, user-added columns will be attached to points. Each update dictionary can modify a point, equipment or both at the same time (which implicitly reparents the point to the equipment). Each update should p.topic and/or e.equip_id to identify to the system where to apply the write. If a topic and equip_id are provided together in the same object then the system will associate that point with that equipment.

Updates use PATCH semantics, so only provided fields will be written to. Check-and-set concurrency control is available. To use it, include a .cas field with a current value to verify before processing the update. Please see the update object in the example below for more details.

The staging client supports the same urllib3.util.retry.Retry support that the standard client has.

from onboard.client.staging import OnboardStagingClient

staging = OnboardStagingClient(api_key='ob-p-your-key-here')

buildings = client.get_all_buildings()  # using OnboardClient from above example
all_building_details = staging.get_staging_building_details()  # a list of building-level staging information objects

building_id: int = 0  # yours here

points = staging.get_staging_points(building_id)
equipment = staging.get_staging_equipment(building_id)

point_update = [
    # keys to identify the point we are modifying
    {
        'topic':'org/building/4242/my-sensor',
        # an update of related equipment: equip_names
        'equip_names': ["equip_name1", "equip_name2"],
        # an optional check-and-set guard for the equip relation update
        'modified.cas': '2025-03-13 14:44:24.133067+00:00'
    }
]
equip_update = [
    # keys to identify the equipment we are modifying
    {
        'name':'ahu-1',
        # an update to rename equipment
        'new_name': 'ahu-2',
    }
]
modified_point = staging.update_staging_points(building_id, point_update)
modified_equipment = staging.update_staging_equipment(building_id, equipment_update)

License

Copyright 2018-2024 Onboard Data Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

onboard_client-1.16.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

onboard_client-1.16.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file onboard_client-1.16.0.tar.gz.

File metadata

  • Download URL: onboard_client-1.16.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for onboard_client-1.16.0.tar.gz
Algorithm Hash digest
SHA256 b9f4d07efcf523f95d37ea0819b2e506a113916f30da0f09d11f7b0c975da05e
MD5 5d480c5222d74581c0ab55f0a322c5a4
BLAKE2b-256 6eebf74d3bdc9e5c0e0e4e44a53773a2b543b90cb598a6a97303188bbb2baad7

See more details on using hashes here.

File details

Details for the file onboard_client-1.16.0-py3-none-any.whl.

File metadata

File hashes

Hashes for onboard_client-1.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29a5794738cf399eec797aa02e7ec09006df1c222555571d001ffec806749683
MD5 a8c39d09648e9f753c25294e02afa9ea
BLAKE2b-256 d980dc96d32d2b7e72479426f287634d5745d5578bbc22c0150afbb4915912f7

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