Skip to content
Discussions/App Development/What components does the JSON API pass its data to?Forum ↗

What components does the JSON API pass its data to?

App Development4 posts385 views3 likesLast activity Aug 2020
AN
anthonyOP
Aug 2020

So as I understand it the JSON API itself is fairly simple, it doesn’t do any validation, nor authorization. It receives commands and passes them on to other parts of the DAML stack. Is it essentially a translation layer for the Ledger API or does it talk to any other components?

ST
Stephen
Aug 2020

That’s right. It’s best to think of it as something any ordinary gRPC client could do.

The only special thing it does from downstream perspective is to keep a list of templates so that package IDs may be inferred. That list, too, is maintained over an ordinary gRPC client connection, as described here.

However, you should not take the corollary that there is an obvious 1-1 mapping between a gRPC call and a JSON API request. Each endpoint tries to add some value to the underlying gRPC call[s]

  1. by simplifying the protocol, e.g. removing uncommonly used arguments or trying to infer required arguments such as with package IDs, or
  2. by doing something nice internally, such as the query language that helps you filter what might otherwise be a firehose of contracts.
LE
Leonid_Shlyapnikov
Aug 2020

Just for the references, here is the list of all Ledger API calls that JSON API relies on (scroll down to find the implementations):

github.com

digital-asset/daml/blob/15350a7bc2cf796057b27432e1a525aa7ea366bd/ledger-service/http-json/src/main/scala/com/digitalasset/http/LedgerClientJwt.scala#L29-L60

  1. type SubmitAndWaitForTransaction =
  2. (Jwt, SubmitAndWaitRequest) => Future[SubmitAndWaitForTransactionResponse]
  3. type SubmitAndWaitForTransactionTree =
  4. (Jwt, SubmitAndWaitRequest) => Future[SubmitAndWaitForTransactionTreeResponse]
  5. type GetTermination =
  6. Jwt => Future[Option[Terminates.AtAbsolute]]
  7. type GetActiveContracts =
  8. (Jwt, TransactionFilter, Boolean) => Source[GetActiveContractsResponse, NotUsed]
  9. type GetCreatesAndArchivesSince =
  10. (Jwt, TransactionFilter, LedgerOffset, Terminates) => Source[Transaction, NotUsed]
  11. type ListKnownParties =
  12. Jwt => Future[List[api.domain.PartyDetails]]
  13. type GetParties =
  14. (Jwt, OneAnd[Set, Ref.Party]) => Future[List[api.domain.PartyDetails]]
This file has been truncated. show original
AN
anthony
Aug 2020

Thanks for the answers. These are very helpful!

← Back to Discussions