Skip to main content

SDK officiel Python pour GeoTrack Pro — GPS, logistique et géofencing

Project description

GeoTrack Pro Python SDK

SDK officiel Python pour l'API GeoTrack Pro — plateforme de géolocalisation de flotte, logistique et géofencing.

PyPI version Python 3.10+ License: MIT

Installation

pip install geotrack-sdk

Démarrage rapide

import asyncio
from geotrack import GeoTrackClient

async def main():
    async with GeoTrackClient(api_key="gt_votre_cle_api") as client:

        # Lister les véhicules en ligne
        devices = await client.devices.list(is_online=True)
        print(f"{devices.total} véhicules en ligne")

        for device in devices.items:
            print(f"  {device.name}{device.last_position}")

        # Historique de positions des dernières 24h
        from datetime import datetime, timedelta, timezone
        now = datetime.now(timezone.utc)
        positions = await client.devices.get_positions(
            device_id=devices.items[0].id,
            from_dt=(now - timedelta(hours=24)).isoformat(),
            to_dt=now.isoformat(),
        )
        print(f"{len(positions)} positions récupérées")

asyncio.run(main())

Ressources disponibles

Devices

# Lister avec filtres
devices = await client.devices.list(page=1, page_size=50, is_online=True)

# Détail d'un device
device = await client.devices.get("uuid-du-device")

# Positions sur une plage
positions = await client.devices.get_positions("uuid", from_dt="...", to_dt="...")

# Résumé de trajets
trips = await client.devices.get_trip_summary("uuid", from_dt="...", to_dt="...")

Alertes

# Lister les alertes récentes
alerts = await client.alerts.list(page=1, alert_type="overspeed")

# Marquer comme lue
await client.alerts.acknowledge("alert-uuid")

Colis (Last-Mile)

# Créer un colis
parcel = await client.parcels.create(
    tracking_code="TRACK-001",
    recipient_name="Jean Dupont",
    recipient_phone="+22891000000",
    destination_address="Lomé, Togo",
)

# Mettre à jour le statut
await client.parcels.update_status(parcel.id, status="out_for_delivery")

# Lister par statut
parcels = await client.parcels.list(status="pending")

Webhooks

from geotrack import WebhookHandler

handler = WebhookHandler(secret="votre_secret_webhook")

# Dans votre endpoint FastAPI / Flask :
@app.post("/webhook/geotrack")
async def handle_webhook(request: Request):
    payload = await request.body()
    signature = request.headers.get("X-GeoTrack-Signature")

    event = handler.parse(payload, signature)
    print(f"Événement : {event.type} — Device : {event.device_id}")
    return {"ok": True}

Gestion des erreurs

from geotrack import GeoTrackError, AuthError, RateLimitError, QuotaError, NotFoundError

try:
    device = await client.devices.get("uuid-invalide")
except NotFoundError:
    print("Device introuvable")
except RateLimitError as e:
    print(f"Rate limit — réessayer dans {e.retry_after}s")
except AuthError:
    print("Clé API invalide ou expirée")
except QuotaError:
    print("Quota mensuel dépassé — mettre à niveau le plan")
except GeoTrackError as e:
    print(f"Erreur API : {e}")

Auto-hébergement

client = GeoTrackClient(
    api_key="gt_...",
    base_url="https://votre-instance.com/api/v1",
)

Générer une clé API

  1. Connectez-vous sur geo.lsgrouptogo.com
  2. Paramètres → API Keys → Créer une clé
  3. Copiez la clé (affichée une seule fois)

Liens

Licence

MIT — voir LICENSE

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

geotrack_sdk-1.0.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

geotrack_sdk-1.0.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file geotrack_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: geotrack_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for geotrack_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8cde780bacb8661b2fc4ae66f7c9d617a2d0153c8a464b229ad6423addc4836f
MD5 c6375f143bc9c4147842a63bf3a00cf0
BLAKE2b-256 3dccd4cdff51ee64c7b2b5c5f43dea339430b9aa680434d614d0fb33c2473cca

See more details on using hashes here.

File details

Details for the file geotrack_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: geotrack_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for geotrack_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1203a899f3c7f77d7d150b2bde0e317f840677db4b039c81e0672c729b74a9cc
MD5 04a9510c9dd40e99fcd0d59e1e614647
BLAKE2b-256 e434594bd3c42b5c507f4183743f832fe064a424529746c0af05538d72e4b92c

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