Skip to main content

A Python library to interact with the PAJ GPS API.

Project description

pajgps-api

A Python library for communicating with the PAJ GPS API.

Installation

pip install pajgps-api

Usage

All API methods are async and must be awaited. Use asyncio.run() or an existing event loop.

import asyncio
from pajgps_api import PajGpsApi

async def main():
    # Initialize the API (can also be used as an async context manager)
    async with PajGpsApi(email="your_email@example.com", password="your_password") as api:
        # Log in
        try:
            await api.login()
            print(f"Logged in successfully! User ID: {api.user_id}")
        except Exception as e:
            print(f"Login failed: {e}")

        # Subsequent requests will automatically use the token and refresh it if needed.

        # Reading Devices
        devices = await api.get_devices()
        for device in devices:
            print(f"ID: {device.id}, Name: {device.name}, IMEI: {device.imei}")

        # Current Positions for all devices
        device_ids = [device.id for device in devices]
        if device_ids:
            last_positions = await api.get_all_last_positions(device_ids)
            for pos in last_positions:
                print(f"Device {pos.iddevice}: Lat {pos.lat}, Lng {pos.lng}, Speed {pos.speed}")

        # Voltage Sensor (for the first device)
        if devices:
            sensor_data = await api.get_last_sensor_data(devices[0].id)
            if hasattr(sensor_data, "volt"):
                print(f"Voltage: {sensor_data.volt} mV")

asyncio.run(main())

API Endpoint Coverage

✅ Supported

Category Method Endpoint Library method
Login POST /api/v1/login login()
Login POST /api/v1/updatetoken update_token()
Device GET /api/v1/device get_devices()
Device GET /api/v1/device/{DeviceID} get_device()
Device PUT /api/v1/device/{DeviceID} update_device()
Tracking Data GET /api/v1/trackerdata/{DeviceID}/last_minutes get_tracking_data_last_minutes()
Tracking Data GET /api/v1/trackerdata/{DeviceID}/last_points get_tracking_data_last_points()
Tracking Data GET /api/v1/trackerdata/{DeviceID}/date_range get_tracking_data_date_range()
Tracking Data POST /api/v1/trackerdata/getalllastpositions get_all_last_positions()
Tracking Data GET /api/v1/sensordata/last/{DeviceID} get_last_sensor_data()
Notifications GET /api/v1/notifications get_notifications()
Notifications GET /api/v1/notifications/{deviceID} get_device_notifications()
Notifications GET /api/v1/customnotifications/{deviceID} get_custom_notifications()
Notifications PUT /api/v1/notifications/markReadByDevice/{deviceID} mark_notifications_read_by_device()
Notifications PUT /api/v1/notifications/markReadByCustomer mark_notifications_read_by_customer()

❌ Not Yet Supported

Category Method Endpoint Description
Customer GET /api/v1/customer Get customer data
Customer GET /api/v1/customer/{CustomerID} Get customer data by ID
Customer PUT /api/v1/customer/{CustomerID} Update customer by ID
Dashboard POST /api/v1/customer/dashboard/dataDistance Data and distance calculation
Dashboard POST /api/v1/customer/dashboard/downloadpdf Trip and rest PDF download
Dashboard POST /api/v1/customer/dashboard/triprest_data Trip and rest data
Geofence POST /api/v1/geofences Get all geofences for given devices
Geofence POST /api/v1/geofence/{DeviceID} Create geofence for a device
Geofence PUT /api/v1/geofence/{DeviceID}/{GeofenceID} Update a geofence
Geofence DELETE /api/v1/geofence/{DeviceID}/{GeofenceID} Delete a geofence
Car Manufacturer GET /api/v1/cars Get all car manufacturers
Car Manufacturer POST /api/v1/addcar Add car manufacturer
Car Manufacturer PUT /api/v1/cars/{carManufacturerID} Update car manufacturer
Car Manufacturer DELETE /api/v1/cars/{carManufacturerID} Delete car manufacturer
Car Model GET /api/v1/carmodels/{Make_ID} Get car models of a manufacturer
Car Model POST /api/v1/addcarmodel Add car model
Car Model PUT /api/v1/carmodels/{carModelID} Update car model
Car Model DELETE /api/v1/carmodels/{carModelID} Delete car model
Car Device Data GET /api/v1/sdevice/car Get car-device linked data
Car Device Data POST /api/v1/sdevice/car Link car to device
Car Device Data GET /api/v1/sdevice/car/{CarDevice_id} Get single car-device link
Car Device Data PUT /api/v1/sdevice/car/{CarDevice_id} Update car-device link
Car Device Data DELETE /api/v1/sdevice/car/{CarDevice_id} Delete car-device link
Logbook Routes GET /api/v1/logbook/getAllRoutes/{DeviceID} Get all routes of a device
Logbook Routes GET /api/v1/logbook/getAllRoutes/{DeviceID}/{CarDevice_id} Get routes with linked car
Logbook Routes GET /api/v1/logbook/generateSingleDeviceRoutes/{DeviceID} Generate logbook routes
Logbook Routes GET /api/v1/logbook/generateSingleDeviceAddress/{DeviceID} Generate route addresses
Logbook Driver GET /api/v1/logbook/driver Get drivers
Logbook Driver POST /api/v1/logbook/driver Create driver
Logbook Driver PUT /api/v1/logbook/driver/{DriverID} Update driver
Logbook Driver DELETE /api/v1/logbook/driver/{DriverID} Delete driver
Logbook Reason GET /api/v1/logbook/reason Get reasons
Logbook Reason POST /api/v1/logbook/reason Create reason
Logbook Reason PUT /api/v1/logbook/reason/{ReasonID} Update reason
Logbook Reason DELETE /api/v1/logbook/reason/{ReasonID} Delete reason
Logbook Contact GET /api/v1/logbook/contact Get contacts
Logbook Contact POST /api/logbook/contact Create contact
Logbook Contact PUT /api/v1/logbook/contact/{ContactID} Update contact
Logbook Contact DELETE /api/v1/logbook/contact/{ContactID} Delete contact

Timeouts and Retries

By default, every HTTP request made by PajGpsApi uses incremental timeouts and automatic retries:

  • Attempts: 3
  • Timeouts per attempt: 5s, 10s, 15s (each attempt adds the base timeout)
  • Retries on: network timeouts/connection errors and HTTP status codes 500, 502, 503, 504, 429
  • Not retried: 4xx client errors like 404
  • 401 handling: for authenticated endpoints, a token refresh is attempted once automatically, then the request is retried within the same attempt.

You can configure these via the constructor:

from pajgps_api import PajGpsApi

api = PajGpsApi(
    email="your_email@example.com",
    password="your_password",
    timeout=5,       # base timeout (seconds) for the first attempt
    max_retries=3,   # total number of attempts
    base_url="https://connect.paj-gps.de/",  # optional, override if the API URL changes
)

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

pajgps_api-0.3.1.tar.gz (53.9 kB view details)

Uploaded Source

Built Distribution

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

pajgps_api-0.3.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file pajgps_api-0.3.1.tar.gz.

File metadata

  • Download URL: pajgps_api-0.3.1.tar.gz
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pajgps_api-0.3.1.tar.gz
Algorithm Hash digest
SHA256 185aa85591d5d134c591deb05c1dc116879467fb81e601d5f6338b1d4e6a3fdf
MD5 f3da3b3f877ed99996bb87acde5e3363
BLAKE2b-256 fbf42bca48bc1af2c8872da3288b0fa03267319e11d8b3af60a86d67cd4476cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pajgps_api-0.3.1.tar.gz:

Publisher: python-publish.yml on skipperro/pajgps-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pajgps_api-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pajgps_api-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pajgps_api-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb15542c570f3c969bdf53266fa356e8753842199b8d4b3793f16299b64eb7ea
MD5 6d7dc2e8ac1ed6100a6d05754ba1e9e6
BLAKE2b-256 8d4187519e00f188607e6ab7900e2be7e1d76f3619e0ac5534e3efdd988beb5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pajgps_api-0.3.1-py3-none-any.whl:

Publisher: python-publish.yml on skipperro/pajgps-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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