pyroclient.client#

The client subpackage contains the core definition of the API client.

API Client#

class pyroclient.client.Client(token: str, host: str = 'https://api.pyronear.org', timeout: int = 10, **kwargs)[source]#

Isometric Python client for Pyronear wildfire detection API

Parameters
  • token – your personal API token

  • endpoint – the host for your instance of pyronear API

  • timeout (int) – number of seconds before request timeout

  • kwargs – optional parameters of requests.post

create_detection(media: bytes, azimuth: float, bboxes: List[Tuple[float, float, float, float, float]]) Response[source]#

Notify the detection of a wildfire on the picture taken by a camera.

>>> from pyroclient import Client
>>> api_client = Client("MY_CAM_TOKEN")
>>> with open("path/to/my/file.ext", "rb") as f: data = f.read()
>>> response = api_client.create_detection(data, azimuth=124.2, bboxes=[(.1,.1,.5,.8,.5)])
Parameters
  • media – byte data of the picture

  • azimuth – the azimuth of the camera when the picture was taken

  • bboxes – list of tuples where each tuple is a relative coordinate in order xmin, ymin, xmax, ymax, conf

Returns

HTTP response

fetch_cameras() Response[source]#

List the cameras accessible to the authenticated user

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_cameras()
Returns

HTTP response

fetch_detections() Response[source]#

List the detections accessible to the authenticated user

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_detections()
Returns

HTTP response

fetch_organizations() Response[source]#

List the organizations accessible to the authenticated user

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_organizations()
Returns

HTTP response

fetch_unlabeled_detections(from_date: str) Response[source]#

List the detections accessible to the authenticated user

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_unacknowledged_detections("2023-07-04T00:00:00")
Returns

HTTP response

get_detection_url(detection_id: int) Response[source]#

Retrieve the URL of the media linked to a detection

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.get_detection_url(1)
Parameters

detection_id – ID of the associated detection entry

Returns

HTTP response

heartbeat() Response[source]#

Update the last ping of the camera

>>> from pyroclient import Client
>>> api_client = Client("MY_CAM_TOKEN")
>>> response = api_client.heartbeat()
Returns

HTTP response containing the update device info

label_detection(detection_id: int, is_wildfire: bool) Response[source]#

Update the label of a detection made by a camera

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.label_detection(1, is_wildfire=True)
Parameters
  • detection_id – ID of the associated detection entry

  • is_wildfire – whether this detection is confirmed as a wildfire

Returns

HTTP response

update_last_image(media: bytes) Response[source]#

Update the last image of the camera

>>> from pyroclient import Client
>>> api_client = Client("MY_CAM_TOKEN")
>>> with open("path/to/my/file.ext", "rb") as f: data = f.read()
>>> response = api_client.update_last_image(data)
Returns

HTTP response containing the update device info