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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fleetglue_client-2.0.2.tar.gz.
File metadata
- Download URL: fleetglue_client-2.0.2.tar.gz
- Upload date:
- Size: 22.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15447ee9191e85388644064e5c58e467bd39b144ccb1979af6e23a3ed59b9e99
|
|
| MD5 |
de430f5ce6de94a473a3980a285b5431
|
|
| BLAKE2b-256 |
7f0a4f470fda91291b222ad4add5ea0d804336d86e6a5077a6ca67ae2f105566
|
File details
Details for the file fleetglue_client-2.0.2-py3-none-any.whl.
File metadata
- Download URL: fleetglue_client-2.0.2-py3-none-any.whl
- Upload date:
- Size: 30.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa21614bcd289b0fac765795baac4fbf3ba8440c618fa1ed678c0ad2d61f7514
|
|
| MD5 |
0b6940b7132e462b5f486f5b742b4553
|
|
| BLAKE2b-256 |
1ba25b5bf06139a4f815096474a34f600e92687cd0e1bbd0604e0cf84fccef4b
|