Spydra Docs
For Developers
Spydra Platform
Spydra Platform
  • GETTING STARTED
    • Introduction
    • Why Spydra?
    • Blockchain fundamentals
      • Why Blockchain?
      • Private Blockchain
      • Public Chain
    • 🎧Getting started with a Private Network
      • Creating an account
      • Creating an organization
      • Creating a Network
      • Apps
    • 🔊Getting started with a Token Store on Public Chain
      • Token store
      • Customise token store front
      • List a real world asset and issue tokens
      • Manage token lifecycle
    • Intro to Hyperledger Fabric
  • Products Overview
    • 🎧Private Network
      • Organizations
        • Users and Organizations
        • Organisation Hosting - Spydra Hosted and BYOC
        • Organization Statuses
        • Organization Roles & Permissions
        • Organization Dashboard
        • Organization Entities
      • Networks
        • Network Statuses
        • Network Roles & Permissions
        • Network Configurations
        • Mandatory Card Addition
        • Nodes: Peer, Orderer & CA
        • Network Hosting Type
        • Network Dashboard
        • Network Operations
        • Nodes
      • Channels
      • Apps
        • Pre-Configured Apps
        • Custom Apps
      • Asset Tokenization
        • Use cases
        • Asset types
        • References
        • Asset Owners
        • Permissions
      • Tokens & Vault
      • Listeners
        • Network Listeners
        • App Listeners
        • Token Listeners
      • Workflow Builder
      • Oracles
      • GraphQL
      • Block Explorer
      • IPFS
      • Fabric Debug Plugin
    • 🔊Public Chain
      • Token Store
      • Tokenize Real World Assets
      • Tokenomics: Token & Token Sale
      • Trade & Payout
  • How to
    • 🎧Private Network
      • Account
        • Create an Account
        • Edit Profile details
        • Update email & Password
        • Forgot password
        • Google OAuth Signup - Update Email & Password
        • Deactivating or deleting your account?
      • Organizations
        • Create an Organization
        • Create & Manage BYOC Hosting
        • Invite members to an organisation
        • Edit Organization details
        • Manage Org members
        • Leave an Organization
        • Update Organization member roles
        • Pay Organisation Invoice
        • Update Billing Address
        • View Invoices
        • Organization Dashboard
        • Delete an Organisation
      • Networks
        • Create a Network
        • Advance Settings: Key Vault Store
        • View and edit Network details
          • Update Permissions for Network Members
          • Update Network Configuration
          • Update Key Vault
          • Manage API Keys
          • Delete a network
        • Inviting an organisation to a Network
        • Network Roles & Permissions
        • Joining a Network
        • Network Dashboard
      • Apps
        • Explore Apps
        • Deploy App
          • Deploying Asset Tokenization App
        • Manage Apps
        • Application Dashboard
      • Channels
        • Creating a Channel
        • Create a Consensus Policy
        • Update Channel
        • Channel Members
        • Delete channel
      • Nodes
        • Create Node
        • Node Dashboard
        • Delete Node
      • Pre-configured Apps
        • Deploy Asset Tokenization App
        • Asset Data
      • Custom Apps
        • Deploy Custom Chaincode
        • Chaincode as external service
        • Supported File Formats - ZIP format
        • Building in Binary format
          • Golang - Binary Format
          • Java Jar files
        • Chaincode Logs
      • Workflow
        • Triggers
        • Condition
        • Read
        • Actions
        • End
        • Variables & Identifiers
        • Calculations & Formulas
      • Oracles
        • Create an Oracle
        • Oracle with Asset tokenisation
        • Oracle with Custom Chaincode
      • Listeners
        • Create a Listener
        • Manage Listeners
    • 🔊Public Chain
      • Account
        • Create an Account
        • Edit Profile details
        • Update email & Password
        • Forgot password
        • Google OAuth Signup - Update Email & Password
        • Deactivating or deleting your account?
      • Token Store
        • Create a Token Store
        • Design Store Front
        • Custom Domain Hosting
        • Google Analytics Integration
        • Create & Manage Store Users
          • Store User KYC
        • Accreditation Management
        • Store Payments
        • Token Store Customers
      • Tokenise a Real World Asset
        • Real Estate
        • Other Asset Categories
      • Create a token
        • Define your token
        • Investor & Buyback Settings
        • Configure token returns & payouts
        • Create token sale
      • Additional Configurations
        • Create a Document Workflow
      • Publish Asset
      • Tokenise on TestNet
        • Polygon Amoy
      • Manage Token lifecycle
        • Returns & Payouts
          • Initiate an equity payout
          • Authorise Debt Payouts
          • View all payouts
        • View token investors
        • View token transactions
        • View signed documents
        • View/ Create a token sale
        • Post Token Updates
        • Update Price
        • Buyback Requests
  • Billing & Pricing
    • Pricing
    • Billing
      • Opt-in Billing
      • Opt-out Billing
    • Adding a Card & Autopay
    • Invoice Payments
    • Billing forecast
    • Unpaid Invoices
    • Credits
  • Developers
    • API Reference
      • Asset Tokenization
        • REST API
        • Testing REST API
        • GraphQL
          • Quickstart
          • Simple queries
          • Nested object queries
          • Complex queries
          • Aggregate queries
          • Operators
          • Built-in attributes
          • Pagination
      • Custom Chaincode
        • REST API
        • Testing REST API
        • GraphQL
          • Quickstart
          • Simple queries
          • Complex queries
          • Operators
          • Pagination
      • Token Store (Public Chain)
        • Token Issuer
        • Investor
      • IPFS
    • Developer Tools
      • Monitoring [Coming Soon]
    • API Key
  • Support
    • FAQs
    • My account is banned [D]
    • Why is it recommended to have an Odd number of Orderer nodes on a Network?
    • Support
  • Others
    • Glossary
  • Policies
    • Terms & Conditions
    • Privacy Policies
    • Open Spydra
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. API Reference
  3. Custom Chaincode

REST API

PreviousCustom ChaincodeNextTesting REST API

Last updated 1 year ago

Was this helpful?

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.

patch

ReIssue the identity from the certificate authority

Authorizations
Path parameters
enrollmentIdstringRequired
Responses
201
Identity reissued
application/json
400
Identity cannot be reissued
application/json
404
Identity cannot be found
application/json
500
General server error
application/json
patch
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

Get the identity from the fabric certificate authority

Authorizations
Path parameters
enrollmentIdstringRequired
Responses
200
Fetched Identity
application/json
404
Identity cannot be fetched
application/json
500
General server error
application/json
get
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"
}
get

Get all identities from the certificate authority

Authorizations
Responses
200
Identities
application/json
500
General server error
application/json
get
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

Get Fabric Chain Information

Authorizations
Responses
200
ChainInfo
application/json
500
General server error
application/json
get
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

Get Blockchan Block for a Number

Authorizations
Path parameters
blockNumbernumberRequired
Responses
200
Block data
application/json
400
cannot get block data
application/json
500
General server error
application/json
get
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

Get Blockchan Block for a TransactionId

Authorizations
Path parameters
transactionIdstringRequired
Responses
200
Block data
application/json
500
General server error
application/json
get
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

Get Blockchan Transaction for a TransactionId

Authorizations
Path parameters
transactionIdstringRequired
Responses
200
Transaction data
application/json
500
General server error
application/json
get
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

Get latest Blocks

Authorizations
Query parameters
limitstringOptional
bookmarkstringOptional
Responses
200
Block data
application/json
400
cannot get block data
application/json
500
General server error
application/json
get
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

Get latest Transactions

Authorizations
Query parameters
limitstringOptional
bookmarkstringOptional
block_numberstringOptional
Responses
200
Transaction data
application/json
400
cannot get transaction data
application/json
500
General server error
application/json
get
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

Get the status of an already submitted transaction using the returned receipt id.

Authorizations
Query parameters
receiptIdstringRequired

The receipt id returned while submitting the transaction.

Responses
200
Transaction found.
application/json
400
Request failed due to invalid request parameters.
application/json
500
General server error.
application/json
get
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"
}
  • POST/ledger/transact
  • POST/ledger/query
  • POST/identity
  • PATCH/identity/{enrollmentId}
  • GET/identity/{enrollmentId}
  • DELETE/identity/{enrollmentId}
  • GET/identity/all
  • GET/explorer/chainInfo
  • GET/explorer/block/byNumber/{blockNumber}
  • GET/explorer/block/byTxId/{transactionId}
  • GET/explorer/transaction/byTxId/{transactionId}
  • GET/explorer/block/latest
  • GET/explorer/transaction/latest
  • GET/receipt
post

Create a transaction on the blockchain

Authorizations
Query parameters
asyncstringOptional

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.

Body
functionNamestringOptionalExample: CreateDocumentDefinitions
Responses
200
Transaction created
application/json
Responseone of
or
500
General server error.
application/json
post
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"
}
post

Queries/Evaluate the transaction on the blockchain

Authorizations
Body
functionNamestringOptionalExample: CreateDocumentDefinitions
Responses
200
Transaction queried
application/json
500
General server error
application/json
post
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
  }
]
post

Issues the identity from the certificate authority

Authorizations
Body
enrollmentIdstringOptionalExample: user1
typestringOptionalExample: client
maxEnrollmentsnumberOptionalExample: 10
Responses
201
Identity issued
application/json
400
Identity cannot be issued
application/json
500
General server error
application/json
post
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": "user1@email.com"
  }
}
{
  "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"
}
delete

Revoke the identity from the certificate authority

Authorizations
Path parameters
enrollmentIdstringRequired
Body
reasonstringOptionalExample: keycompromise
generateCRLbooleanOptional
Responses
202
Identity revoked
application/json
404
Identity not found
application/json
500
General server error
application/json
delete
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"
}