Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json API v2 initial documentation #830

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Conversation

jarekr-da
Copy link
Collaborator

@jarekr-da jarekr-da commented Nov 8, 2024

Preview:
set env variables
ARTIFACTORY_USERNAME=...
ARTIFACTORY_PASSWORD=...

cd doc/3.1
bin/live-preview

open http://127.0.0.1:8000/json-api/index.html

@jarekr-da jarekr-da self-assigned this Nov 8, 2024
@jarekr-da jarekr-da changed the title Json API v3.0 initial documentation Json API v2 initial documentation Dec 13, 2024
@jarekr-da jarekr-da force-pushed the jarekr/json3_api_doc branch 2 times, most recently from 7fe2832 to 12406bf Compare December 16, 2024 08:21
@jarekr-da jarekr-da marked this pull request as ready for review December 16, 2024 08:45
@jarekr-da jarekr-da requested review from a team as code owners December 16, 2024 08:45
Copy link
Contributor

@carrielaben-da carrielaben-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numerous small revisions throughout.

docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/openapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/v1/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/v1/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/v1/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/v1/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/v1/index.rst Outdated Show resolved Hide resolved
@jarekr-da jarekr-da force-pushed the jarekr/json3_api_doc branch from d6cb7e3 to 5ec5c1a Compare December 19, 2024 12:03
@raphael-speyer-da
Copy link
Contributor

A general comment in looking through this, is that while the API is a lot more comprehensive, it is significantly more obtuse in terms of the request and response bodies, due to them mapping directly to the GRPC types.

I guess that's why you were emphasising the importants of having nice clients for interacting with it.

docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/asyncapi.rst Outdated Show resolved Hide resolved

The **JSON API** provides a significantly simpler way to interact with a ledger than
:doc:`the Ledger API </app-dev/ledger-api>` by providing *basic active contract set functionality*:
This section describes the new JSON API Service that is a part of Canton 3.2. If you are looking for legacy JSON API, please navigate to :doc:`JSON API V1 </json-api/v1/index>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in docs/3.1 but it says it's documenting Canton 3.2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I have no idea how to deal with that. I think we will not backport JSON V2 to 3.1. So that will be 3.2
On the other hand it probably makes no sense to create new branch of docs yet.

docs/3.1/docs/json-api/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/index.rst Outdated Show resolved Hide resolved

The sources below can be copied to `Editor swagger IO <https://editor-next.swagger.io>`_ . The editor displays a preview of the specification and generates example inputs and outputs.

The specification covers streaming (websockets) endpoints - for regular endpoints (HTTP) please see :doc:`openapi`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these work yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Websockets work normally.

docs/3.1/docs/json-api/index.rst Outdated Show resolved Hide resolved
- Content-Type: ``application/json``
.. note:: You can only query active contracts with the ``/v2/state/active-contracts`` endpoint. Archived contracts (those that were archived or consumed during an exercise operation) will not be shown in the results.

HTTP Websocket Request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean websockets? Yes.

docs/3.1/docs/json-api/index.rst Outdated Show resolved Hide resolved
docs/3.1/docs/json-api/openapi.rst Outdated Show resolved Hide resolved
@jarekr-da
Copy link
Collaborator Author

jarekr-da commented Dec 20, 2024

A general comment in looking through this, is that while the API is a lot more comprehensive, it is significantly more obtuse in terms of the request and response bodies, due to them mapping directly to the GRPC types.

I guess that's why you were emphasising the importants of having nice clients for interacting with it.

I agree - that became visible once I started to create examples - to check using curl/wscat. While I was testing from scala, using JSON encoding -> the problem was not visible. So, yest this new interface basically needs codegeneration/client lib.

docs/3.1/docs/json-api/index.rst Outdated Show resolved Hide resolved
}
}
} ],
"workflow_id" : "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think restricting the populated fields to the minimum required would make these examples a good deal more useful.

}
"commands" : [ {
"CreateCommand" : {
"template_id" : "cbed714ed61c4a30b0038ea72c9ff13de51be99aac065f61e6ae9e954375e171:Iou:Iou",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a package name in the template_id of all the requests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants