8

I'm reading the JSON RPC API documentation but I cannot understand what is the id that should be specified in the request (and that is also returned in the answer).

Is this simply a nonce that indicates that the given reply corresponds to a given request?

Briomkez
  • 1,894
  • 1
  • 11
  • 33

2 Answers2

8

It is part of the JSON RPC specs:

http://www.jsonrpc.org/specification

id An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]

It's basically an identifier for your client to know which response corresponds to which request - in case you're using something like a WebSocket endpoint, where you're getting a stream of replies instead of just one reply per request like HTTP POST.

Martin Kou
  • 118
  • 4
1

Yes. Depending on how your application communicates with the API/node, this may help you to match queries to responses.

n1cK
  • 3,378
  • 2
  • 12
  • 18