MyGeotab#

Build Status Documentation Code Coverage PyPI Version Python Versions License

A Python client for the MyGeotab SDK.

Features#

  • Automatic serializing and deserializing of API call results

  • Clean, Pythonic API for querying data

  • Cross-platform and compatible with Python 3.7+

  • A myg command-line tool for interactively working with data in a terminal

Usage#

It’s very easy to get started once you’ve registered a MyGeotab database:

import mygeotab

client = mygeotab.API(username='hello@example.com', password='mypass', database='MyDatabase')
client.authenticate()

devices = client.get('Device', name='%Test Dev%')

print(devices)

# [{'maxSecondsBetweenLogs': 200.0,
#   'activeTo': '2050-01-01',
#   'minAccidentSpeed': 3.0,
#   'ignoreDownloadsUntil': '1986-01-01',
#   'name': 'Test Device',
#   'idleMinutes': 3.0,
#   ......

You can also make calls asynchronously via asyncio:

import asyncio
import mygeotab

client = mygeotab.API(username='hello@example.com', password='mypass', database='MyDatabase')
client.authenticate()

async def get_device():
  return await client.get_async('Device', name='%Test Dev%')

devices = loop.run_until_complete(get_device())
print(devices)

# [{'maxSecondsBetweenLogs': 200.0,
#   'activeTo': '2050-01-01',
#   'minAccidentSpeed': 3.0,
#   'ignoreDownloadsUntil': '1986-01-01',
#   'name': 'Test Device',
#   'idleMinutes': 3.0,
#   ......

Installation#

To install the MyGeotab library and command line tool:

$ pip install mygeotab

or for the bleeding-edge version:

$ pip install git+https://github.com/geotab/mygeotab-python

Documentation#

Read the docs at http://mygeotab-python.readthedocs.org

Changes#

0.9.0 (2024-02-23)#

Improvements

  • Removed all Python 2 handling code and packages (six).

  • Simplified code based on removing support for Python 2 and Python 3.6 and lower.

Bug Fixes

  • Support results limit in get requests #11.

  • Handles ArgumentException when extending the session #19.

Housecleaning

  • Changed linter to ruff and enabled additional linters.

  • Ensured proper mypy types installed for 3rd party packages.

0.8.8 (2022-09-14)#

Improvements

  • Use the highest TLS version available (at least TLS 1.2) when making calls.

Bug Fixes

  • Fix for recursive hasattr call when serializing objects #7.

0.8.7 (2021-11-11)#

Improvements

  • Added support for client-side certificates #1.

  • Console improvements using ptpython (if installed) and better handling of sessions.

0.8.6 (2021-03-15)#

Improvements

  • Added new experimental API class (in the mygeotab.ext module) for more intuitive ways of using results from client.get() like get_dataframe() to easily get a Pandas DataFrame from the result set.

  • Adds support for using with proxies #327.

  • Calling authenticate() on an API instance more than once no longer results in an error #328.

Bug Fixes

  • Handle ConnectionError as errors in feed extension rather than crashing #130.

  • Remove extraneous “search” parameter from API.get().

0.8.5 (2019-10-07)#

Bug Fixes

  • Fixes issue with warnings from Arrow about date parsing #306.

0.8.4 (2019-08-22)#

Bug Fixes

  • Fixes issue with serialization of datetime.date objects #284.

0.8.3 (2019-08-19)#

Improvements

  • Use the high-performance python-rapidjson library to serialize and deserialize JSON parameters and responses in Python 3.5+ #268.

Bug Fixes

  • Silence warnings from arrow parsing when the library is used interactively or in a Jupyter notebook.

Housecleaning

  • Added serialization benchmarking in CircleCI tests.

  • Remove PyPy test config.

0.8.2 (2019-06-10)#

Bug Fixes

  • Remove asyncio-specific default arguments preventing from importing this pacakge in a Python 3.5+ thread #236.

0.8.1 (2019-06-03)#

Improvements

  • Return content with a non-JSON content type as text

Bug Fixes

  • Handle serialization of very old dates #121.

0.8.0 (2018-06-18)#

Improvements

  • Python 3.7 support.

  • Raises an exception when request was not successful.

  • Documentation improvements.

Bug Fixes

  • Since all MyGeotab servers enforce the use of TLS1.2, Python 2.7.9 or greater is required.

  • Fix issue where the password was not provided when retrying authentication. Should better handle #92.

0.6.2 (2017-07-04)#

Bug Fixes

  • Revert the change to stop compilation in setup.cfg.

0.6.1 (2017-07-03)#

Bug Fixes

  • Don’t compile to prevent issues when installing via setup.py on Python 2.7.

0.6.0 (2017-06-29)#

Improvements

  • Configurable timeouts when making calls.

  • Removed verify parameter from API objects as SSL is required when calling a MyGeotab server.

  • Removed run command from the CLI.

  • Removed deprecated API.search and API.search_async methods.

  • Refactored setup.py for async API. The async/awaitable methods are now automatically a part of the API object if using Python 3.5 or higher

  • Code linting and cleanup

0.5.4 (2017-06-05)#

Bug Fixes

  • Ensure all dates are timezone aware and are always UTC-localized.

0.5.3 (2017-05-30)#

Bug Fixes

  • Fixed intermittent timeout errors due to upstream changes in the ‘requests’ module

0.5.2 (2017-02-02)#

Bug Fixes

  • Switched back to using abstract dependencies in setup.py (recommended by this guide)

0.5.1 (2017-01-04)#

Bug Fixes

  • Fix for search parameter not being properly handled in ‘get()’ call

0.5 (2017-01-02)#

Enhancements

  • Deprecated the ‘search()’ and ‘search_async()’ functions. Replaced by folding the previous functionality into ‘run()’.

  • Removed ‘tzlocal’ dependency. Always deal with dates in UTC by default.

  • Prefer functions instead of making static methods in classes.

  • Added helper to run async calls and collect their results

  • Add ability to quickly run simple python scripts from the ‘myg’ console with no need for any authentication handling. Similar to ‘console’, but for running scripts rather than creating an interactive console.

0.4.4 (2016-07-10)#

Enhancements

  • Added the ability to make unauthenticated calls (like “GetVersion”) with the static “API.server_call” method

  • Added asyncio-based API query methods (Python 3.5+ only) into the “ext” package

  • Moved the datafeed to the “ext” package, as well

Bug Fixes

  • MyGeotab never returns 3 digits of milliseconds, so follow that format as well to allow the use of “dates.format_iso_datetime” to create MyGeotab URLs

0.4.2 (2016-03-17)#

Bug Fixes

  • Use a custom User-Agent when making requests

0.4 (2016-02-25)#

Enhancements

  • Extension for facilitating use of the MyGeotab Data Feed

  • Allow Pythonic underscore-separated parameters mapped to camelcase ones

  • Force the use of TLS 1.2 for upcoming strict security requirements in MyGeotab (Note that TLS 1.2 is only supported in Python 2.7.9+ and 3.4+)

Bug Fixes

  • Fixed issue with CLI console startup

  • Use the system’s default user location for config files

User Guide#

How to use this library, and more information about bundled tools and examples.

API Reference#

The full API reference for all public classes and functions.