REST API
You can access the Rest API through the Swagger UI from the App API section. Navigate to Network -> Deployed Apps -> App -> Rest API
base url:
https://<membership_id>.spydra.app/fabric/<app_id>
Get the base URL from Network -> Deployed Apps -> App -> Rest API page.
Select your organization at the top right of this page.
Alternatively, you can from the URL by getting the <membership_id> by navigating
to Network -> Members page and getting the <app_id> by navigating to the Network ->
Deployed Apps -> App Overview page.
Create a transaction on the blockchain
Whether to wait for the transaction to be created before returning a response or not. When async=false (default), the API will wait for the transaction to be committed on the Ledger and then return the transaction Id. If async=true, the API will return immediately with a receipt Id. The reciept Id can be used to check the status of the transaction anytime using the /receipt
endpoint.
CreateDocumentDefinitions
Transaction created
General server error.
POST /fabric/<chaincodeccid>/ledger/transact HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 106
{
"functionName": "CreateDocumentDefinitions",
"args": [
{
"id": "Invoice",
"name": "Invoice",
"idAttribute": "id"
}
]
}
{
"transactionId": "dd7817b56429532ceea32e2111faa20a7af87c945e7d8163ae2384c560b565f2",
"receiptId": "643d316fa27b8c7dcdb31c49"
}
Queries/Evaluate the transaction on the blockchain
CreateDocumentDefinitions
Transaction queried
General server error
POST /fabric/<chaincodeccid>/ledger/query HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 106
{
"functionName": "CreateDocumentDefinitions",
"args": [
{
"id": "Invoice",
"name": "Invoice",
"idAttribute": "id"
}
]
}
[
{
"ID": "asset1",
"Color": "whte",
"Size": 15,
"Owner": "Brad",
"AppraisedValue": 200
}
]
Issues the identity from the certificate authority
user1
client
10
Identity issued
Identity cannot be issued
General server error
POST /fabric/<chaincodeccid>/identity HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 105
{
"enrollmentId": "user1",
"type": "client",
"maxEnrollments": 10,
"attributes": {
"userEmail": "[email protected]"
}
}
{
"key": "-----BEGIN PRIVATE KEY-----\r\nMIGHAgEAMBM-\n----END PRIVATE KEY-----\r\n",
"certificate": "-----BEGIN CERTIFICATE-----\nMIICjDCCAjKgA\n-----END CERTIFICATE-----\n",
"rootCertificate": "-----BEGIN CERTIFICATE-----\nMIICjDCCAjKgA\n-----END CERTIFICATE-----\n"
}
ReIssue the identity from the certificate authority
Identity reissued
Identity cannot be reissued
Identity cannot be found
General server error
PATCH /fabric/<chaincodeccid>/identity/{enrollmentId} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"key": "-----BEGIN PRIVATE KEY-----\r\nMIGHAgEAMBM-\n----END PRIVATE KEY-----\r\n",
"certificate": "-----BEGIN CERTIFICATE-----\nMIICjDCCAjKgA\n-----END CERTIFICATE-----\n",
"rootCertificate": "-----BEGIN CERTIFICATE-----\nMIICjDCCAjKgA\n-----END CERTIFICATE-----\n"
}
Get the identity from the fabric certificate authority
Fetched Identity
Identity cannot be fetched
General server error
GET /fabric/<chaincodeccid>/identity/{enrollmentId} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"id": "user1",
"type": "client",
"affiliation": "",
"attrs": [
{
"name": "user1",
"value": "123",
"ecert": true
}
],
"max_enrollments": 10,
"caname": "ca-org1"
}
Revoke the identity from the certificate authority
keycompromise
Identity revoked
Identity not found
General server error
DELETE /fabric/<chaincodeccid>/identity/{enrollmentId} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 45
{
"reason": "keycompromise",
"generateCRL": true
}
{
"revokeUser": {
"RevokedCerts": [
{
"Serial": "3bf5b6",
"AKI": "3bf5b6"
}
],
"CRL": ""
},
"generatedCRL": "LS0tLS1CRUd"
}
Get all identities from the certificate authority
Identities
General server error
GET /fabric/<chaincodeccid>/identity/all HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
[
{
"id": "user1",
"type": "client",
"affiliation": "",
"attrs": [
{
"name": "user1",
"value": "123",
"ecert": true
}
],
"max_enrollments": 10,
"caname": "ca-org1"
}
]
Get Fabric Chain Information
ChainInfo
General server error
GET /fabric/<chaincodeccid>/explorer/chainInfo HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"height": "109",
"currentBlockHash": "lXNu1mBUNpNAUzucy/2CAsk0Hq586+8WRO",
"previousBlockHash": "Gob0PD5UgI38BwEQT+baD+8ei92WBbY"
}
Get Blockchan Block for a Number
Block data
cannot get block data
General server error
GET /fabric/<chaincodeccid>/explorer/block/byNumber/{blockNumber} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"header": {
"number": 10,
"previous_hash": "\u0014����2�S�q\u001ck��h",
"data_hash": "I\u0006(p�o\u0013"
},
"data": {
"data": [
{
"signature": "I\u0006(p�o\u0014",
"payload": {}
}
]
},
"metadata": {
"metadata": [
{
"value": "II\u0006(p�o\u0014345",
"signatures": [
{}
]
}
]
}
}
Get Blockchan Block for a TransactionId
Block data
General server error
GET /fabric/<chaincodeccid>/explorer/block/byTxId/{transactionId} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"header": {
"number": 10,
"previous_hash": "\u0014����2�S�q\u001ck��h",
"data_hash": "I\u0006(p�o\u0013"
},
"data": {
"data": [
{
"signature": "I\u0006(p�o\u0014",
"payload": {}
}
]
},
"metadata": {
"metadata": [
{
"value": "II\u0006(p�o\u0014345",
"signatures": [
{}
]
}
]
}
}
Get Blockchan Transaction for a TransactionId
Transaction data
General server error
GET /fabric/<chaincodeccid>/explorer/transaction/byTxId/{transactionId} HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"validationCode": 0,
"data": {
"signature": "I\u0006(p�o\u0014",
"payload": {
"header": {},
"data": {}
}
},
"transaction_hash": "dd81d0c67b75fe16c30fa113e1b3ef020cb9e92",
"created_date": "2023-05-16T11:39:46.499Z",
"transaction_type": "ENDORSER_TRANSACTION",
"chaincode_name": "document-contract",
"block_number": {
"low": 50,
"high": 0,
"unsigned": true
},
"msp_id": "Org1"
}
Get latest Blocks
Block data
cannot get block data
General server error
GET /fabric/<chaincodeccid>/explorer/block/latest HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"records": [
{
"header": {
"number": 10,
"previous_hash": "\u0014����2�S�q\u001ck��h",
"data_hash": "I\u0006(p�o\u0013"
},
"data": {
"data": [
{
"signature": "I\u0006(p�o\u0014",
"payload": {}
}
]
},
"metadata": {
"metadata": [
{
"value": "II\u0006(p�o\u0014345",
"signatures": [
{}
]
}
]
}
}
],
"bookmark": 8,
"count": 2
}
Get latest Transactions
Transaction data
cannot get transaction data
General server error
GET /fabric/<chaincodeccid>/explorer/transaction/latest HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"records": [
{
"block_number": 8,
"data": {
"signature": "I\u0006(p�o\u0014",
"payload": {
"header": {},
"data": {}
}
},
"transaction_hash": "dd81d0c67b75fe16c30fa113e1b3ef020cb9e92",
"created_date": "2023-05-16T11:39:46.499Z",
"transaction_type": "ENDORSER_TRANSACTION",
"chaincode_name": "document-contract",
"msp_id": "Org1"
}
],
"bookmark": "99_dd81d0c67b75fe16c30fa113e1b3ef020cb9e",
"count": 2,
"nextTransactionsExist": false
}
Get the status of an already submitted transaction using the returned receipt id.
The receipt id returned while submitting the transaction.
Transaction found.
Request failed due to invalid request parameters.
General server error.
GET /fabric/<chaincodeccid>/receipt?receiptId=text HTTP/1.1
Host: <networkorgid>.<publicdomain>
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"transactionId": "6c94ff55155722c28611630e7d6795145e0282e9fabf10bf3460f396e2a6218b",
"status": "COMMITTED",
"message": "Success"
}
Last updated
Was this helpful?