Skip to main content

Python client for FleetGlue API

Project description

FleetGlue API Python Client

A Python library for interfacing with the FleetGlue REST API in a Pythonic way, presenting Accounts, Devices, Alerts, and other objects as instances of Python classes. Currently only supports reading from the API ("GET" requests).

Installation

$ pip(3) install fleetglue-client

Simple API examples

Instantiating the API

With a token and secret:

from fleetglue_client import FleetGlueClient
client = FleetGlueClient(token = "TXXX", secret = "Sxxx")

With a username and password:

from fleetglue_client import FleetGlueClient
client = FleetGlueClient(username = "your@email.com", password = "foo")

With a saved credentials file:

from fleetglue_client import FleetGlueClient
client = FleetGlueClient()

The file should be in ~/.fleetglue/credentials and contain a JSON structure with token and secret fields, e.g. {"token":"TXXX", "secret":"SXXX"}.

Manipulating accounts

Getting a list of accounts you have access to:

for account in client.accounts:
    print(account)

Manipulating devices

Getting a list of devices in the first account you have access to:

for device in client.accounts[0].devices:
    print(device.name)

You can fetch a specific device by its ID:

device = client.accounts[0].device("Dxxxxxxxxxxxx")

or search for it by its name, assuming that name is unique:

device = client.accounts[0].find_device("myrobot")

Getting data from devices

Getting the most recent value from a ROS topic:

device = client.accounts[0].find_device("myrobot")
print(device.last_data("/gps/fix"))

Getting full data from a time interval:

device = client.accounts[0].find_device("myrobot")

# fetch last 1000 s of data
for message in device.data("/gps/fix", start = time.time() - 1000, end = time.time()):
    print(message)

Advanced API examples

See the demo_.py files. (TODO: more data analysis demos.)

Distribution

First you will need to have a local ~/.pypirc file with the configurations for both Test PyPi and the production one. E.g.

[testpypi]
  username = __token__
  password = <request for original token>

[pypi]
  username = __token__
  password = <request for original token>

Steps

  • Publish to testpypi:
REPOSITORY=testpypi ./publish_to_pypi.sh
  • Check that it's working properly:
pip install --index-url https://test.pypi.org/simple fleetglue_client
  • Push to actual PyPi
REPOSITORY=pypi ./publish_to_pypi.sh

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

fleetglue_client-2.0.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

fleetglue_client-2.0.1-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file fleetglue_client-2.0.1.tar.gz.

File metadata

  • Download URL: fleetglue_client-2.0.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-45-generic

File hashes

Hashes for fleetglue_client-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3ea583018a2a0ba56110e0ee6961fbe512330ff35294dfd0c10396cb2ce169b3
MD5 356e6b680c1986bff424f2934f7ad5eb
BLAKE2b-256 c5b9a2ab11e5a3b47b24cbf3df7a68e67950aba8bd108286308f31a60e208d2a

See more details on using hashes here.

File details

Details for the file fleetglue_client-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: fleetglue_client-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-45-generic

File hashes

Hashes for fleetglue_client-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1bad41348f81083d3ad501a1dbcaf6550601b4426d082da7e695b2c4f2c665a0
MD5 b14373e77e619ba48d3c5f6903349b81
BLAKE2b-256 b126fbc1635375de90b4907c625fd1203e06dce84feefba7ca16e3ce08250152

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