Library reference

class openplantbook_sdk.OpenPlantBookApi(client_id, secret, base_url='https://open.plantbook.io/api/v1')[source]

Open Plantbook SDK class

async async_plant_data_upload(jts_doc: JtsDocument, dry_run=False, params: dict = None, request_kwargs: dict = None)[source]

Upload plant’s sensor data

Parameters:
  • dry_run (bool) – It instructs API to only validate JTS payload and does not commit values to the database.

  • jts_doc (JtsDocument) – One or multiple sensors data as JtsDocument object

  • params – Optional dict of additional query parameters to pass through to the API request. The ‘dry_run’ value from the dedicated argument will be merged into this dict (and can be overridden here if needed).

  • request_kwargs – Optional dict of extra keyword arguments forwarded to aiohttp request call (e.g., timeout, ssl, proxy, allow_redirects). These are passed to session.post(…).

Returns:

True if successful

Return type:

bool

Raises:
  • [MissingClientIdOrSecret] – Client ID or Secret is missing

  • [PermissionError] – Authentication failed

  • [RateLimitError] – API returns 429 Too Many Requests

async async_plant_detail_get(pid: str, lang: str = None, params: dict = None, request_kwargs: dict = None)[source]

Retrieve plant details using Plant ID (or PID)

Parameters:
  • pid – Plant ID string (PID)

  • lang – ISO 639-1 language code (e.g., ‘en’, ‘de’); forwarded as ‘lang’ query parameter

  • params – Optional dict of additional query parameters to pass through to the API request. The ‘lang’ value from the dedicated argument will be merged into this dict (and can be overridden here if needed).

  • request_kwargs – Optional dict of extra keyword arguments forwarded to aiohttp request call (e.g., timeout, ssl, proxy, allow_redirects). These are passed to session.get(…).

Returns:

API response as dict of JSON structure

Return type:

dict

Raises:
  • [MissingClientIdOrSecret] – Client ID or Secret is missing

  • [PermissionError] – Authentication failed

  • [RateLimitError] – API returns 429 Too Many Requests

async async_plant_instance_register(sensor_pid_map: dict, location_by_ip: bool = None, location_country: str = None, location_lon: float = None, location_lat: float = None, extra_json: dict = None, params: dict = None, request_kwargs: dict = None)[source]

Register a plant sensor

Parameters:
  • sensor_pid_map – Plant Instance to PlantID map. Dictionary id-pid. ONLY 1 item is currently supported.

  • location_by_ip – Allow to take location from IP address

  • location_country – Country location of the plant

  • location_lon – Location longitude of the plant

  • location_lat – Location latitude of the plant

  • extra_json – Optional dict merged into the JSON payload. Useful for passing additional fields supported by the API (e.g., location_name, location_region).

  • params – Optional dict of additional query parameters to pass through to the API request.

  • request_kwargs – Optional dict of extra keyword arguments forwarded to aiohttp request call (e.g., timeout, ssl, proxy, allow_redirects). These are passed to session.post(…).

Returns:

List of JSON dicts with API response, or None if a network error occurs.

Return type:

list

Raises:
  • [ValidationError] – API could not validate JSON payload due to some errors which are returned within the exception’s attribute ‘errors’

  • [MissingClientIdOrSecret] – Client ID or Secret is missing

  • [PermissionError] – Authentication failed

  • [RateLimitError] – API returns 429 Too Many Requests

Search plant by search string

Parameters:
  • params – Optional dict of additional query parameters to pass through to the API request.

  • request_kwargs – Optional dict of extra keyword arguments forwarded to aiohttp request call (e.g., timeout, ssl, proxy, allow_redirects). These are passed to session.get(…).

Returns:

API response as dict of JSON structure

Return type:

dict

Raises:
  • [MissingClientIdOrSecret] – Client ID or Secret is missing

  • [PermissionError] – Authentication failed

  • [RateLimitError] – API returns 429 Too Many Requests