Reading Data from the Ledger

GET /:ledgerId/v1/query

Description

(This endpoint is a replacement of deprecated endpoint: GET /:ledgerId/contracts/search)
The following example demonstrates fetch all contracts for given party token

HTTP GET request

GET /data/:ledgerId/v1/query HTTP/1.1
Host: api.projectdabl.com
Authorization: Bearer YOUR_TOKEN

HTTP success Response

{
    "result": [
        {
            "agreementText": "",
            "contractId": "#48:0",
            "observers": [],
            "payload": {
                "issuer": "f8htpbsywu4nef6x",
                "owner": "f8htpbsywu4nef6x",
                "name": "squidly"
            },
            "signatories": [
                "f8htpbsywu4nef6x"
            ],
            "templateId": "b3488a9041bb7994eb9ec629cb700e78c1c619e9be7d711ff22b0cadfcce3fbe:Main:Asset"
        }
    ],
    "status": 200
}

POST /:ledgerId/v1/query

Description

(This endpoint is a replacement of deprecated endpoint: POST /:ledgerId/contracts/search)
POST request with search query in JSON body for matching contracts based on user-defined criteria.
Please see detailed reference for contract search language

The following will fetch all contracts with templateId Iou.Iou

HTTP POST request

POST /data/:ledgerId/v1/query HTTP/1.1
Host: api.projectdabl.com
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
    "templateIds": ["Iou:Iou"],
    "query": {"amount": 100.0}
}

HTTP success response

{
    "result": [
        {
            "agreementText": "",
            "contractId": "#470:0",
            "observers": [],
            "payload": {
                "observers": [],
                "issuer": "rztds0vfs6hgd1np",
                "amount": "100.0",
                "currency": "USD",
                "owner": "rztds0vfs6hgd1np"
            },
            "signatories": [
                "rztds0vfs6hgd1np"
            ],
            "templateId": "ec4ff7a9c2adb530faf269fac0678b700aa0f99faa7624f3fdb97536b544830f:Iou:Iou"
        }
    ],
    "status": 200
}

Empty Response

{
    "status": 200,
    "result": []
}

HTTP Error Response

{
    "status": 400,
    "errors": [
        "JsonReaderError. Cannot read JSON: <{\"%templates\":[{\"moduleName\":\"Iou\"}]}>. Cause: Object is missing required member 'entityName'"
    ]
}

POST /:ledgerId/v1/fetch

Description

(This endpoint is a replacement of deprecated endpoint: POST /:ledgerId/contracts/lookup)
POST request to lookup contract by contractID or contractKey

The following will lookup contracts with contractId #1:0

HTTP POST request

POST /data/:ledgerId/v1/fetch HTTP/1.1
Host: api.projectdabl.com
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
  "contractId": "#1:0"
}

Contract Found response

{
    "result": {
        "agreementText": "",
        "contractId": "#1:0",
        "observers": [],
        "payload": {
            "observers": [],
            "issuer": "rztds0vfs6hgd1np",
            "amount": "100.0",
            "currency": "USD",
            "owner": "rztds0vfs6hgd1np"
        },
        "signatories": [
            "rztds0vfs6hgd1np"
        ],
        "templateId": "ec4ff7a9c2adb530faf269fac0678b700aa0f99faa7624f3fdb97536b544830f:Iou:Iou"
    },
    "status": 200
}

Contract Not Found Response

{
    "status": 200,
    "result": null
}

The following will lookup contracts with contractKey:

POST /data/:ledgerId/v1/fetch HTTP/1.1
Host: api.projectdabl.com
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
    "templateId": "Account:Account",
    "key": [
        "Alice",
        "abc123"
    ]
}

Contrac Found Response

{
    "status": 200,
    "result": {
        "observers": [],
        "agreementText": "",
        "payload": {
            "owner": "Alice",
            "number": "abc123",
            "status": {
                "tag": "Enabled",
                "value": "2020-01-01T00:00:01Z"
            }
        },
        "signatories": [
            "Alice"
        ],
        "key": {
            "_1": "Alice",
            "_2": "abc123"
        },
        "contractId": "#697:0",
        "templateId": "11c8f3ace75868d28136adc5cfc1de265a9ee5ad73fe8f2db97510e3631096a2:Account:Account"
    }
}

Contract Not Found Response

{
    "status": 200,
    "result": null
}

(deprecated) GET /:ledgerId/contracts

Description The following example demonstrates fetch all contracts for given party token
(We will keep this endpoint until DAML SDK's json-api become stable)

HTTP GET request

GET /data/:ledgerId/contracts HTTP/1.1
Host: api.projectdabl.com
Authorization: Bearer YOUR_TOKEN

HTTP success Response

{
    "result": [
        {
            "argument": {
                "observers": [],
                "issuer": "rztds0vfs6hgd1np",
                "amount": "100.0",
                "currency": "USD",
                "owner": "rztds0vfs6hgd1np"
            },
            "contractId": "#470:0",
            "effectiveAt": "1970-01-01T00:00:00Z",
            "parties": {
                "rztds0vfs6hgd1np": "created"
            },
            "templateId": "Iou:Iou@ec4ff7a9c2adb530faf269fac0678b700aa0f99faa7624f3fdb97536b544830f",
            "workflowId": null
        }
    ],
    "status": 200,
    "success": true,
    "description": null,
    "commandId": null
}