The `mygeotab` library is a Python client for the MyGeotab SDK, providing a clean, Pythonic API for interacting with the MyGeotab telematics platform. It handles automatic serialization and deserialization of API call results and is compatible with Python 3.9+. As of version 0.9.4, it continues to be actively developed with frequent releases addressing improvements and bug fixes.
pip install mygeotabVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `mygeotab` client, authenticate using environment variables, and perform basic API calls such as retrieving devices and checking API version information. It handles potential authentication failures gracefully.
Upgrade your Python environment to 3.7+ and then upgrade the `mygeotab` library to 0.9.0 or later: `pip install --upgrade mygeotab`.
Replace calls like `client.search('Device', name='%Test Dev%')` with `client.get('Device', search={'name': '%Test Dev%'})`.Always use double quotes for JSON keys and string values within your API call parameters, for example: `client.get('Device', search={'name': 'MyDevice'})`.Implement logic to check for session validity before authenticating. If `session_id` is present and valid, proceed directly to API calls. Only call `authenticate()` when starting a new session or re-authenticating after an `InvalidUserException`. The `mygeotab` library's `client.authenticate()` should handle the standard username/password flow correctly, but be mindful when integrating with existing session IDs.
Verify that the username, password, database name, and server URL are precisely correct. Ensure the MyGeotab account is not locked out. In `mygeotab`, these parameters are passed to the `API` constructor: `api = mygeotab.API(username='your_username', password='your_password', database='your_database', server='my.geotab.com')` then `api.authenticate()`.
Instead of re-authenticating with an existing session ID, use the `extend_session` method to refresh an active session. `api.extend_session(database='your_database', session_id=existing_session_id, user_name='your_username')`.
Implement a retry mechanism with exponential backoff to reduce the frequency of API calls after receiving this error. Review Geotab API documentation for specific rate limits and adjust the application's call frequency accordingly.
Re-authenticate to obtain a new valid session ID. If maintaining long-lived sessions, regularly call `api.extend_session()` before the session expires to keep it active.