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.0.tar.gz (22.4 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.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fleetglue_client-2.0.0.tar.gz
  • Upload date:
  • Size: 22.4 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.0.tar.gz
Algorithm Hash digest
SHA256 8f916934fa0575f45040c96e2854ec1d4a3aa9a39a8ac24add8d84a977d975e4
MD5 2623cdb2824e5c15f1c6116af2b3b638
BLAKE2b-256 8b4ee095b1ed5642ad0504f797500ccc9558b3765b149a79f4dd03ee570155ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fleetglue_client-2.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 258bcd9b75551655af69e1020419caa636a63735a3a34d0f7e296b98598fd065
MD5 2788e5c5577c747eaf6ec57993988bd4
BLAKE2b-256 b95fddfa9b041e48d654973f911ad35c7f43b9ef8b98d2e7e3bd9fc561161a91

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