Repository navigation
Discover realtime connection settings from the API (0.6.0) - #13
Merged
Merged
Conversation
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>
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client.realtime()no longer needs any connection settings.client_id,ws_urlandapp_keyare each taken from:DEAPI_CLIENT_ID,DEAPI_WS_URL,DEAPI_WS_APP_KEY),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
client.websocket_config()(sync and async) returningWebSocketConfig/WebSocketConnection, exported fromdeapi_sdkanddeapi_sdk.types.client_idwas discovered too) and the returned auth endpoint are used.RealtimeError. HTTP errors propagate as the usual API exceptions.rt.client_idisNoneuntil connect when it was not supplied..env.example,examples/realtime_status.pyand therealtime()docstrings.Release
client_idproperty type change).CHANGELOG.mdwith the 0.6.0 entry.client.websocket_config()added to the README account/keys overview.ChangelogURL in the project metadata.Behaviour change
Setting only
DEAPI_CLIENT_ID(withoutDEAPI_WS_URL/DEAPI_WS_APP_KEY) now triggers oneGET /websocketcall at connect time instead of falling back to built-in defaults.Tests
ruff check src tests examples: cleanmypy src tests/fake_pusher.py tests/test_request_files.py: no issuespytest -m "not integration": 701 passedNew 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 integrationagainst 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 todone)🤖 Generated with Claude Code