Skip to content

Discover realtime connection settings from the API (0.6.0) - #13

Merged
dawidope merged 3 commits into
mainfrom
feature/websocket-config-discovery
Nov 19, 2026
Merged

dawidope merged 3 commits into
mainfrom
feature/websocket-config-discovery

Conversation

@dawidope

@dawidope dawidope commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

client.realtime() no longer needs any connection settings. client_id, ws_url and app_key are each taken from:

  1. the argument,
  2. the environment variable (DEAPI_CLIENT_ID, DEAPI_WS_URL, DEAPI_WS_APP_KEY),
  3. GET /websocket, the account's realtime parameters.

The discovery call is made once, at connect() / with (never in the constructor), and only when something is still missing. With all three values set, no extra request is made. Reconnects reuse the cached result.

Changes

  • New client.websocket_config() (sync and async) returning WebSocketConfig / WebSocketConnection, exported from deapi_sdk and deapi_sdk.types.
  • When discovery ran, the returned channel (if client_id was discovered too) and the returned auth endpoint are used.
  • An unusable discovery response (missing fields, unsupported protocol, unexpected event name, invalid auth endpoint) raises RealtimeError. HTTP errors propagate as the usual API exceptions.
  • rt.client_id is None until connect when it was not supplied.
  • Removed the hard-coded production WebSocket URL and app key defaults; the API is now the source of truth.
  • Updated README, API reference, .env.example, examples/realtime_status.py and the realtime() docstrings.

Release

  • Version bumped to 0.6.0 (new public API, client_id property type change).
  • New CHANGELOG.md with the 0.6.0 entry.
  • client.websocket_config() added to the README account/keys overview.
  • Changelog URL in the project metadata.

Behaviour change

Setting only DEAPI_CLIENT_ID (without DEAPI_WS_URL / DEAPI_WS_APP_KEY) now triggers one GET /websocket call at connect time instead of falling back to built-in defaults.

Tests

  • ruff check src tests examples: clean
  • mypy src tests/fake_pusher.py tests/test_request_files.py: no issues
  • pytest -m "not integration": 701 passed

New tests cover discovery for sync and async, no request when everything is set (args or env), partial settings, no re-fetch on reconnect, auth endpoint fallback, HTTP error followed by a successful retry, malformed responses and URL building for every tls/port combination.

  • pytest -m integration against a non-production environment: 20 passed, including the new realtime tests (websocket_config(), sync/async connect with discovered settings, a job followed over the WebSocket to done)

🤖 Generated with Claude Code

dawidope and others added 2 commits November 19, 2026 11:08
client_id, ws_url and app_key are now optional for client.realtime().
Each is taken from the argument, then the environment variable, then
GET /websocket, which the SDK calls once at connect time (never in the
constructor) only when something is still missing. With all three set,
no extra request is made.

- add client.websocket_config() (sync and async) returning the new
  WebSocketConfig / WebSocketConnection models
- use the returned channel and auth endpoint when discovery ran
- reject unusable discovery responses with RealtimeError
- drop the hard-coded production WebSocket URL and app key defaults
- update README, API reference, .env.example and the realtime example

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dawidope dawidope changed the title Discover realtime connection settings from the API Discover realtime connection settings from the API (0.6.0) Nov 19, 2026
- integration tests for websocket_config() and for realtime sessions
  that discover their settings (sync, async, and a job followed over
  the WebSocket to completion)
- Changelog URL in the project metadata

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dawidope
dawidope merged commit b5ab4ae into main Nov 19, 2026
5 checks passed
@dawidope
dawidope deleted the feature/websocket-config-discovery branch November 19, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant