Skip to main content

A Python SDK for interacting with Telemetry Harbor ingestion endpoints.

Project description

Telemetry Harbor Python SDK

PyPI Python Versions Downloads License Wheel Format Status

Build Last Commit Issues Pull Requests Repo Size Contributors

Made with Python PRs Welcome Stars Forks

A modern, production-ready SDK for sending telemetry data to the Telemetry Harbor service from any Python application.

This SDK simplifies data sending by handling HTTP communication, JSON serialization, and robust error handling with automatic retries.

For full details and advanced usage, please see our official documentation at docs.telemetryharbor.com.


Features

  • Pydantic Models for strong validation and ease of use.
  • 🔁 Automatic Retries with exponential backoff for network resilience.
  • 📦 Batch Support for efficient multi-reading uploads.
  • ⚙️ Simple API with intuitive methods like send and send_batch.
  • 🌐 Universal — works in any Python 3.7+ environment.

Installation

pip install telemetry-harbor-sdk

Quickstart Guide

Here is a basic example of how to use the SDK.

from telemetryharborsdk import HarborClient, GeneralReading

# 1. Initialize the client
client = HarborClient(
    endpoint="https://api.telemetry-harbor.com/v1/ingest/{harbor_id}",
    api_key="your_secret_api_key"
)

# 2. Create a reading
reading = GeneralReading(
    ship_id="MV-Explorer",
    cargo_id="C-1138",
    value=42.5
)

# 3. Send the reading
response = client.send(reading)
print("Successfully sent data!", response)

# --- Or send a batch ---
batch = [
    GeneralReading(ship_id="MV-Explorer", cargo_id="C-1138", value=42.5),
    GeneralReading(ship_id="MV-Explorer", cargo_id="temperature", value=21.7),
]
batch_response = client.send_batch(batch)
print("Successfully sent batch!", batch_response)

GPS and Cargo Data Rules

When sending GPS coordinates, send latitude and longitude as separate readings with:

  • The same ship_id and timestamp.
  • Distinct cargo_ids "latitude" and "longitude".

This allows proper grouping in the backend for time-series queries.

Example batch:

[
  {
    "ship_id": "MV-Explorer",
    "cargo_id": "latitude",
    "value": 41.123,
    "timestamp": "2025-07-17T10:00:00Z"
  },
  {
    "ship_id": "MV-Explorer",
    "cargo_id": "longitude",
    "value": 29.456,
    "timestamp": "2025-07-17T10:00:00Z"
  }
]

✅ This enables SQL queries to reconstruct full GPS points by grouping on ship_id and timestamp.

Query example (PostgreSQL/TimescaleDB):

SELECT
    time,
    MAX(value) FILTER (WHERE cargo_id = 'latitude') AS latitude,
    MAX(value) FILTER (WHERE cargo_id = 'longitude') AS longitude,
    ship_id
FROM cargo_data
WHERE $__timeFilter(time)
  AND ship_id IN (${ship_id:sqlstring})
  AND cargo_id IN ('latitude', 'longitude')
GROUP BY time, ship_id
ORDER BY time;

API Reference

HarborClient(endpoint, api_key, max_retries=5, initial_backoff=1.0)

Create a new client instance.

  • endpoint (str): Telemetry Harbor ingestion URL.
  • api_key (str): Your API key.
  • max_retries (int, optional): Retry attempts on failure (default 5).
  • initial_backoff (float, optional): Initial backoff in seconds (default 1.0).

send(reading: GeneralReading)

Send a single telemetry reading.

send_batch(readings: List[GeneralReading])

Send multiple readings in a batch.

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

telemetryharborsdk-0.1.7.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

telemetryharborsdk-0.1.7-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file telemetryharborsdk-0.1.7.tar.gz.

File metadata

  • Download URL: telemetryharborsdk-0.1.7.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for telemetryharborsdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 4223a84dcebdc94e6944302a9923302e0e2d79c383a3a853e250715472767250
MD5 5bd02d5aa9a22e7d2ca47d9f1ffb7164
BLAKE2b-256 dde28a4f1f2c6ef818a058dda1c96bc4a9acd36c2d357b5c9e2d7f49772a267f

See more details on using hashes here.

Provenance

The following attestation bundles were made for telemetryharborsdk-0.1.7.tar.gz:

Publisher: publish-to-pypi.yml on TelemetryHarbor/harbor-sdk-python

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

File details

Details for the file telemetryharborsdk-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for telemetryharborsdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8091fbf9b58b9e9d101e07b0dd477570348980d8c57c3c513573c396e1830de7
MD5 72d00040d4e88d6734195d452104d43d
BLAKE2b-256 82266c88759f60b9bae4f471a91651239cc665a06a89dedc14fc32a53e86a5e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for telemetryharborsdk-0.1.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on TelemetryHarbor/harbor-sdk-python

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