Websocket User API Client
WSUserClient Constructor
- class coinbase.websocket.WSUserClient(api_key: str | None = None, api_secret: str | None = None, key_file: IO | str | None = None, base_url='wss://advanced-trade-ws-user.coinbase.com', timeout: int | None = None, max_size: int | None = 10485760, on_message: Callable[[str], None] | None = None, on_open: Callable[[], None] | None = None, on_close: Callable[[], None] | None = None, retry: bool | None = True, verbose: bool | None = False)[source]
WSUserClient
Initialize using WSUserClient
Parameters:
api_key | Optional (str) - The API key
api_secret | Optional (str) - The API key secret
key_file | Optional (IO | str) - Path to API key file or file-like object
base_url | (str) - The websocket base url. Default set to “wss://advanced-trade-ws.coinbase.com”
timeout | Optional (int) - Set timeout in seconds for REST requests
max_size | Optional (int) - Max size in bytes for messages received. Default set to (10 * 1024 * 1024)
on_message | Optional (Callable[[str], None]) - Function called when a message is received
on_open | Optional ([Callable[[], None]]) - Function called when a connection is opened
on_close | Optional ([Callable[[], None]]) - Function called when a connection is closed
retry | Optional (bool) - Enables automatic reconnections. Default set to True
verbose | Optional (bool) - Enables debug logging. Default set to False
WebSocket Utils
- coinbase.websocket.WSUserClient.open(self) None
Open Websocket
Open the websocket client connection.
- async coinbase.websocket.WSUserClient.open_async(self) None
Open Websocket Async
Open the websocket client connection asynchronously.
- coinbase.websocket.WSUserClient.close(self) None
Close Websocket
Close the websocket client connection.
- async coinbase.websocket.WSUserClient.close_async(self) None
Close Websocket Async
Close the websocket client connection asynchronously.
- coinbase.websocket.WSUserClient.subscribe(self, product_ids: List[str], channels: List[str]) None
Subscribe
Subscribe to a list of channels for a list of product ids.
product_ids - product ids to subscribe to
channels - channels to subscribe to
- async coinbase.websocket.WSUserClient.subscribe_async(self, product_ids: List[str], channels: List[str]) None
Subscribe Async
Async subscribe to a list of channels for a list of product ids.
product_ids - product ids to subscribe to
channels - channels to subscribe to
- coinbase.websocket.WSUserClient.unsubscribe(self, product_ids: List[str], channels: List[str]) None
Unsubscribe
Unsubscribe to a list of channels for a list of product ids.
product_ids - product ids to unsubscribe from
channels - channels to unsubscribe from
- async coinbase.websocket.WSUserClient.unsubscribe_async(self, product_ids: List[str], channels: List[str]) None
Unsubscribe Async
Async unsubscribe to a list of channels for a list of product ids.
product_ids - product ids to unsubscribe from
channels - channels to unsubscribe from
- coinbase.websocket.WSUserClient.unsubscribe_all(self) None
Unsubscribe All
Unsubscribe from all channels you are currently subscribed to.
- async coinbase.websocket.WSUserClient.unsubscribe_all_async(self) None
Unsubscribe All Async
Async unsubscribe from all channels you are currently subscribed to.
- coinbase.websocket.WSUserClient.sleep_with_exception_check(self, sleep: int) None
Sleep with Exception Check
Sleep for a specified number of seconds and check for background exceptions.
sleep - number of seconds to sleep.
- async coinbase.websocket.WSUserClient.sleep_with_exception_check_async(self, sleep: int) None
Sleep with Exception Check Async
Async sleep for a specified number of seconds and check for background exceptions.
sleep - number of seconds to sleep.
- coinbase.websocket.WSUserClient.run_forever_with_exception_check(self) None
Run Forever with Exception Check
Runs an endless loop, checking for background exceptions every second.
Channels
- coinbase.websocket.WSUserClient.heartbeats(self) None
Heartbeats Subscribe
Description:
Subscribe to heartbeats channel.
Read more on the official documentation: Heartbeats Channel
- async coinbase.websocket.WSUserClient.heartbeats_async(self) None
Heartbeats Subscribe Async
Description:
Async subscribe to heartbeats channel.
Read more on the official documentation: Heartbeats Channel
- coinbase.websocket.WSUserClient.heartbeats_unsubscribe(self) None
Heartbeats Unsubscribe
Description:
Unsubscribe to heartbeats channel.
Read more on the official documentation: Heartbeats Channel
- async coinbase.websocket.WSUserClient.heartbeats_unsubscribe_async(self) None
Heartbeats Unsubscribe Async
Description:
Async unsubscribe to heartbeats channel.
Read more on the official documentation: Heartbeats Channel
- coinbase.websocket.WSUserClient.user(self, product_ids: List[str]) None
User Subscribe
Description:
Subscribe to user channel for a list of products_ids.
Read more on the official documentation: User Channel
- async coinbase.websocket.WSUserClient.user_async(self, product_ids: List[str]) None
User Subscribe Async
Description:
Async subscribe to user channel for a list of products_ids.
Read more on the official documentation: User Channel
- coinbase.websocket.WSUserClient.user_unsubscribe(self, product_ids: List[str]) None
User Unsubscribe
Description:
Unsubscribe to user channel for a list of products_ids.
Read more on the official documentation: User Channel
- async coinbase.websocket.WSUserClient.user_unsubscribe_async(self, product_ids: List[str]) None
User Unsubscribe Async
Description:
Async unsubscribe to user channel for a list of products_ids.
Read more on the official documentation: User Channel
- coinbase.websocket.WSUserClient.futures_balance_summary(self) None
Futures Balance Summary Subscribe
Description:
Subscribe to futures_balance_summary channel.
Read more on the official documentation: Futures Balance Summary Channel
- async coinbase.websocket.WSUserClient.futures_balance_summary_async(self) None
Futures Balance Summary Subscribe Async
Description:
Async subscribe to futures_balance_summary channel.
Read more on the official documentation: Futures Balance Summary Channel
- coinbase.websocket.WSUserClient.futures_balance_summary_unsubscribe(self) None
Futures Balance Summary Unsubscribe
Description:
Unsubscribe to futures_balance_summary channel.
Read more on the official documentation: Futures Balance Summary Channel
- async coinbase.websocket.WSUserClient.futures_balance_summary_unsubscribe_async(self) None
Futures Balance Summary Unsubscribe Async
Description:
Async unsubscribe to futures_balance_summary channel.
Read more on the official documentation: Futures Balance Summary Channel