Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Can I fetch all parties via the streaming api?Forum ↗

Can I fetch all parties via the streaming api?

App Development3 posts304 views4 likesLast activity Jan 2021
GY
gyorgybalazsiOP
Jan 2021

I would like to use the streaming equivalent of the /v1/parties endpoint.

I cannot see any hint on this in the documentation: https://docs.daml.com/json-api/index.html#streaming-api

And the v1/stream/parties endpoint doesn’t seem to work. I was trying with this code, as an analogy to the example code snippet in the docs:

const tokenPrefix = "jwt.token.";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJjcmVhdGUtZGFtbC1hcHAtc2FuZGJveCIsImFwcGxpY2F0aW9uSWQiOiJmb29iYXIiLCJhY3RBcyI6WyJBbGljZSJdfX0.ahT0RApOdZlrC5u0BH7ybdQcYY_DKLDQkdPCK8dz3R4";
const subprotocols = [`${tokenPrefix}${jwt}`, wsProtocol];
const ws = new WebSocket("ws://localhost:7575/v1/stream/parties", subprotocols);
 
ws.addEventListener("message", function incoming(data) {
		app.ports.partiesStream.send(event.data);

	});

The error message is:

WebSocket connection to 'ws://localhost:7575/v1/stream/parties' failed: Unexpected response code: 404

The v1/stream/query end point works.

Is this streaming endpoint not supported?

CO
cocreature
Jan 2021

There is no streaming version of the parties endpoint at this point. This applies to both the gRPC Ledger API as well as to the JSON API. So for now, you have to keep polling to discover new parties.

GY
gyorgybalazsi
Jan 2021

Thank you!

← Back to Discussions