Async Network Clients¶
Asynchronous network clients for interacting with the XRPL.
- class xrpl.asyncio.clients.AsyncJsonRpcClient(url: str)¶
An async client for interacting with the rippled JSON RPC.
- async request(request: xrpl.models.requests.request.Request) → xrpl.models.response.Response¶
Makes a request with this client.
- Parameters
request – The Request to send.
- Returns
The Response for the given Request.
- class xrpl.asyncio.clients.AsyncWebsocketClient(url: str)¶
A client for interacting with the rippled WebSocket API.
Instead of calling
open
andclose
yourself, you can use a context like so:async with AsyncWebsocketClient(url) as client: # do stuff with client
Doing this will open and close the client for you and is preferred.
To read messages from the client, you can iterate over the client like so:
async with AsyncWebsocketClient(url) as client: async for message in client: # do something with a message
The recommended way to use this client is to set up a Task using the
asyncio
library to listen to incoming messages and do something with them, but the above will work fine if you want to listen indefinitely.- async close() → None¶
Closes the connection.
- is_open() → bool¶
Returns whether the client is currently open.
- Returns
Whether the client is currently open.
- async open() → None¶
Connects the client to the Web Socket API at the given URL.
- async request(request: xrpl.models.requests.request.Request) → xrpl.models.response.Response¶
Makes a request with this client.
- Parameters
request – The Request to send.
- Returns
The Response for the given Request.
- async send(request: xrpl.models.requests.request.Request) → None¶
Submit the request represented by the request to the rippled node specified by this client’s URL.
- Parameters
request – A Request object representing information about a rippled request.
- Raises
XRPLWebsocketException – If there is already an open request by the request’s ID, or if this WebsocketBase is not open.
- exception xrpl.asyncio.clients.XRPLRequestFailureException(result: Dict[str, Any])¶
XRPL Request Exception, when the request fails.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- xrpl.asyncio.clients.json_to_response(json: Dict[str, Any]) → xrpl.models.response.Response¶
Converts a JSON response from the rippled server into a Response object.
- Parameters
json – A dictionary representing the contents of the json response from the rippled server.
- Returns
A Response object containing the information in the rippled server’s response.
- xrpl.asyncio.clients.request_to_json_rpc(request_object: xrpl.models.requests.request.Request) → Dict[str, Any]¶
Converts a request model object to the appropriate JSON format for interacting with the rippled API.
- Parameters
request_object – A Request object representing the parameters of a request to the rippled JSON RPC.
- Returns
A dictionary containing the attributes of this Request object formatted for submission to the rippled JSON RPC.