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_latest_sequences() Response[source]#

List the latest sequences accessible to the authenticated user

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_latest_sequences()
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_sequences_detections(sequence_id: int) Response[source]#

List the detections of a sequence

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

HTTP response

fetch_sequences_from_date(from_date: str) Response[source]#

List the sequences accessible to the authenticated user for a specific date

>>> from pyroclient import client
>>> api_client = Client("MY_USER_TOKEN")
>>> response = api_client.fetch_sequences_from_date("2023-07-04")
Parameters

from_date – date of the sequences to fetch

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_sequence(sequence_id: int, is_wildfire: bool) Response[source]#

Update the label of a sequence made by a camera

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

  • is_wildfire – whether this sequence 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