Skip to main content

Python SDK for the Hot Dev API

Project description

hot-dev

Official Python SDK for the Hot Dev API.

  • PyPI distribution: hot-dev
  • Import package: hot
  • Tested on Python 3.10, 3.11, 3.12, 3.13

Install

pip install hot-dev

Quick Start

import os

from hot import HotClient

hot = HotClient(token=os.environ["HOT_API_KEY"])

# base_url defaults to https://api.hot.dev.
# For local development with `hot dev`, pass base_url="http://localhost:4681".

for event in hot.streams.subscribe_with_event(
    {
        "event_type": "team-agent:ask",
        "event_data": {
            "session_id": "web:chat:demo",
            "user_id": "web:user:demo",
            "user_name": "Demo User",
            "question": "what is blocking launch?",
        },
    }
):
    if event["type"] == "stream:data":
        print(event["data_type"], event.get("payload"))

    if event["type"] == "run:stop":
        print(event.get("run", {}).get("result"))
        break

The client closes its underlying HTTP connection cleanly when used as a context manager:

with HotClient(token=os.environ["HOT_API_KEY"]) as hot:
    event = hot.events.publish(
        {
            "event_type": "team-agent:ask",
            "event_data": {"question": "what changed?"},
        }
    )
    print(event["stream_id"])

Authenticated clients should run server-side. Browser apps and public notebooks should call your own backend route instead of exposing a Hot API key. Most management endpoints require an API key. Sessions and service keys are permission-scoped and are mainly for event publishing and stream reads.

Async Usage

import os

from hot import AsyncHotClient

async with AsyncHotClient(token=os.environ["HOT_API_KEY"]) as hot:
    event = await hot.events.publish(
        {
            "event_type": "team-agent:ask",
            "event_data": {"question": "what changed?"},
        }
    )
    print(event["stream_id"])

Async streaming is supported the same way:

async with AsyncHotClient(token=os.environ["HOT_API_KEY"]) as hot:
    async for event in hot.streams.subscribe_with_event(
        {
            "event_type": "team-agent:ask",
            "event_data": {"question": "what changed?"},
        }
    ):
        print(event["type"], event)

AsyncHotClient exposes the same resource namespaces as HotClient.

Errors

Non-2xx API responses raise HotApiError with structured fields:

from hot import HotApiError

try:
    hot.projects.get("missing-project")
except HotApiError as error:
    print(error.status_code, error.code, error.request_id, error.retry_after)

Resources

HotClient mirrors the Hot API v1 resources:

  • hot.events — publish, list, get, inspect event runs, and call Hot functions with call_hot(fn, args)
  • hot.streams — subscribe to run streams, wait for run results, and publish events atomically (reconnects automatically across the 5-minute SSE timeout; pass reconnect=False to opt out)
  • hot.runs — list, inspect, and view run stats
  • hot.files — upload, download, list, and delete files (including multipart uploads)
  • hot.projects — create, list, update, activate, deactivate, and delete projects
  • hot.builds — upload, download, deploy, and look up live/deployed builds
  • hot.context — manage encrypted project context variables
  • hot.domains — register, verify, list, and delete custom domains
  • hot.sessions — create and revoke scoped sessions
  • hot.service_keys — create and revoke scoped service keys
  • hot.org — view usage and limits
  • hot.env — read environment info and subscribe to environment events

Use hot.request(...) or hot.request_raw(...) as an escape hatch for API endpoints that do not yet have a resource helper.

hot.env.subscribe() requires API key credentials and a live API pub/sub backend; local API servers without pub/sub return a 503. subscribe_with_event reconnects across the API's 5-minute SSE timeout and stops after the first terminal run:* event it sees, so keep using the stream directly if your app expects multiple independent runs on the same stream.

Customizing the HTTP Client

HotClient and AsyncHotClient accept an httpx.Client (or httpx.AsyncClient) via the client= argument. Use this to configure retries, proxies, or custom transports:

import httpx

from hot import HotClient

http_client = httpx.Client(
    timeout=httpx.Timeout(connect=5.0, read=60.0, write=30.0, pool=5.0),
    transport=httpx.HTTPTransport(retries=3),
)

hot = HotClient(token=os.environ["HOT_API_KEY"], client=http_client)

When you pass your own client, the SDK does not close it on exit.

Casing Policy

Core API request and response payloads use the Hot API wire format: event_type, event_data, stream_id, and so on. SDK-only options use Python style names such as base_url and timeout.

The SDK never transforms user-owned payloads such as event_data.

Type Hints

The package ships with py.typed, so editors and type checkers will pick up the public API. Request and response payloads are currently typed as plain dict[str, Any] — keys follow the Hot API wire format documented above. Strict TypedDict shapes generated from the Hot API OpenAPI spec are planned for a future release.

Local Development

python -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
ruff check .
pytest
python -m build

Related

License

Apache-2.0

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

hot_dev-1.1.2.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

hot_dev-1.1.2-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file hot_dev-1.1.2.tar.gz.

File metadata

  • Download URL: hot_dev-1.1.2.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hot_dev-1.1.2.tar.gz
Algorithm Hash digest
SHA256 a4744038691dce3c4a19c4997d3cc8d28a4e7b2f54c7ca8f77fb0a057839cea6
MD5 7e27b5976a856e8b7fa3f25d357c3a9a
BLAKE2b-256 cfcc6391737d8cce1656cd7e4680bb90a105deba224a7fd4d3a0800eb443f1a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hot_dev-1.1.2.tar.gz:

Publisher: release.yml on hot-dev/hot-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 hot_dev-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: hot_dev-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hot_dev-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b39e72b509cdd574babe8eed81e5d566b5d2f5fd3b210d0b89333d5ba27deb8
MD5 d81782bb84475bebc409856f9529970e
BLAKE2b-256 0d1dce701b5e82e0cf0e543a087d1c84076eed0659544e0b5020f73c0daf7859

See more details on using hashes here.

Provenance

The following attestation bundles were made for hot_dev-1.1.2-py3-none-any.whl:

Publisher: release.yml on hot-dev/hot-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