> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hoplynk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Official Python SDK for the Hoplynk API.

## Install

```bash theme={null}
pip install hoplynk
```

<Info>
  The package requires Python 3.10+.
</Info>

## Initialize

```python theme={null}
import os
from hoplynk import HoplynkClient

client = HoplynkClient(api_key=os.environ["HOPLYNK_API_KEY"])
```

***

## Kits

```python theme={null}
# List all kits
kits = client.get_kits()
kit_id = kits[0]["id"]

# Full telemetry snapshot
data = client.get_kit_telemetry(kit_id)

# GPS
loc = client.get_kit_location(kit_id)
print(loc.lat, loc.lon, loc.source)

# Battery
battery = client.get_battery(kit_id)
print(battery["level"], battery["charging"])

# Gateway
gateway = client.get_gateway(kit_id)
print(gateway["model"], gateway["cpu_pct"])

# Connected clients
clients = client.get_clients(kit_id)

# Speedtest
speedtest = client.get_speedtest(kit_id)
```

***

## Links

```python theme={null}
# All WAN links
links = client.get_links(kit_id)
for link in links:
    print(link.name, link.type, link.status, link.latency_ms)

# Single link by type
cellular = client.get_link(kit_id, "cellular")
starlink  = client.get_link(kit_id, "starlink")
```

***

## Assets

```python theme={null}
# List all assets
assets = client.get_assets(kit_id)

# Single asset
asset = client.get_asset(kit_id, asset_id)

# Asset telemetry
snap = client.get_telemetry(kit_id, asset_id)
if snap.gps:
    print(snap.gps.lat, snap.gps.lon)
```

***

## Pushing locations (partner assets)

Register a partner-managed asset once, then push GPS fixes as often as you like.
No connector process required — just REST calls.

```python theme={null}
# 1. Create the asset (once)
asset = client.create_asset(
    kit_id,
    name="Skydio X10",
    type="drone",
    vendor="Skydio",
)

# 2. Push location whenever you have a fix
client.push_location(
    kit_id, asset["id"],
    lat=31.1234, lon=-93.4567,
    alt_m=120.5, bearing=245.0,
)

# Continuous loop at 1 Hz
import time
while True:
    lat, lon = gps.read()
    client.push_location(kit_id, asset["id"], lat=lat, lon=lon)
    time.sleep(1)
```

***

## Streaming

```python theme={null}
# Kit-level stream (GPS, Starlink)
with client.kit_stream(kit_id, feeds=["gps", "starlink"]) as stream:
    for event in stream:
        print(event["feed"], event["payload"])

# Asset-level stream (drone GPS, attitude)
with client.stream(kit_id, asset_id, feeds=["gps", "attitude"]) as stream:
    for event in stream:
        print(event["feed"], event["payload"])
```

***

## Reference

| Method                                              | Returns             | Description                    |
| --------------------------------------------------- | ------------------- | ------------------------------ |
| `get_kits()`                                        | `list[dict]`        | All kits for this API key      |
| `get_kit_telemetry(kit_id)`                         | `dict`              | Full telemetry snapshot        |
| `get_kit_location(kit_id)`                          | `GpsPayload`        | Starlink GPS fix               |
| `get_battery(kit_id)`                               | `dict`              | Battery level + charging state |
| `get_gateway(kit_id)`                               | `dict`              | UniFi gateway info             |
| `get_clients(kit_id)`                               | `list[dict]`        | Connected devices              |
| `get_speedtest(kit_id)`                             | `dict`              | Last speedtest result          |
| `get_links(kit_id)`                                 | `list[LinkStatus]`  | All WAN links                  |
| `get_link(kit_id, name)`                            | `LinkStatus`        | Single link by name/type       |
| `get_assets(kit_id)`                                | `list[dict]`        | All assets                     |
| `get_asset(kit_id, asset_id)`                       | `dict`              | Single asset                   |
| `get_telemetry(kit_id, asset_id)`                   | `TelemetrySnapshot` | Asset feeds                    |
| `create_asset(kit_id, *, name, type, ...)`          | `dict`              | Create a partner asset         |
| `push_location(kit_id, asset_id, *, lat, lon, ...)` | `None`              | Push a GPS fix                 |
| `kit_stream(kit_id, feeds=[])`                      | `HoplynkStream`     | Kit-level WS stream            |
| `stream(kit_id, asset_id, feeds=[])`                | `HoplynkStream`     | Asset-level WS stream          |
