How to Execute REST APIs for IBM Blockchain Platform for Anywhere

1 min read

IBM Blockchain Platform (IBP) provides a managed and full-stack Blockchain-as-a-Service (BaaS) offering that allows you to deploy blockchain components on any Kubernetes cluster.

Recently, we expanded its capability to allow IBP to run on multiple Kubernetes distributions on a private, public, or hybrid multicloud. We call this IBM Blockchain Platform for anywhere.

Goal

The IBM Blockchain Platform exposes RESTful APIs for you to create, import, edit, and delete your blockchain components, as well as to manage logging, notifications, and console settings. The linked document mentions API keys, but it is independent from the IBM Cloud platform, so we must use the username and password used to log in to IBP for anywhere. I am going to introduce how to run simple REST APIs against your IBP for anywhere instance.

ibp

Get all the components

IBM Blockchain Platform is comprised of three major components: Peers, Orderers, and Certificate Authorities (CAs). Each component has its own pod in the Kubernetes nodes and we have an API to show the component details. This API shows all the components (Peers, CAs, Orderers, and a service to manage identities) in your network:

curl -k -L -X GET --user USERNAME:PASSWORD 
'https://IBPanywhereURL:443/ak/api/v2/components'

You will use this command to obtain all the components available. Please make sure you replace the USERNAME and PASSWORD to the username and password used to log in to the above portal. Here is the sample output:

{
    "components": [
        {
            "api_url": "grpcs://URL:443",
            "cluster_id": "XXX",
            "cluster_name": "XXX",
            "config_override": {},
            "consenter_proposal_fin": true,
            "display_name": "COMPONENT NAME 1",
            "grpcwp_url": "URL",
            "id": "COMPONENT ID1",
            "location": "XXX",
            "msp_id": "MSP ID",
            "operations_url": "URL:443",
            "orderer_type": "raft",
            "scheme_version": "v1",
            "system_channel_id": "CHANNEL ID",
            "tags": [
                "XXX",
                "YYY",
                "ZZZ"
            ],
            "timestamp": 1592199822514,
            "tls_ca_root_cert": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "tls_cert": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "type": "fabric-orderer"
        },
        {
            "api_url": "https://URL:443",
            "ca_name": "XXX",
            "config_override": {
                "ca": {
                    "debug": false,
                    "registry": {
                        "identities": [
                            {
                                "attrs": {
                                    "hf.AffiliationMgr": true,
                                    "hf.GenCRL": true, 
                                    }}]}}}
        ...
            "display_name": "COMPONENT NAME 2",
            "id": "COMPONENT ID 2",
            "location": "XXX",
        ...
            "scheme_version": "v1",
            "tags": [
                "XXX",
                "YYY"
            ],
            "timestamp": 1591609080093,
            "tlsca_name": "XXX",
            "type": "fabric-ca"
        }]
}

Get a specific component 

By specifying the ID of the component in the same API, you can filter the result:

curl -k -L -X GET --user USERNAME:PASSWORD 
'https://IBPanywhereURL:443/ak/api/v2/components/COMPONENT ID'

You will obtain information about a specific component using its ID. Please make sure you replace the USERNAME and PASSWORD with the username and password you use to log in to the portal. Here is the sample output:

{
    "api_url": "grpcs://URL:443",
    "cluster_id": "XXX",
    "cluster_name": "XXX",
    "config_override": {},
    "consenter_proposal_fin": true,
    "display_name": "COMPONENT NAME",
    "grpcwp_url": "https://URL:443",
    "id": "COMPONENT ID",
    "location": "XXX",
    "msp_id": "MSP ID",
    "operations_url": "https://URL:443",
    "orderer_type": "raft",
    "scheme_version": "v1",
    "system_channel_id": "CHANNEL ID",
    "tags": [
        "XXX",
        "YYY",
        "ZZZ"
    ],
    "timestamp": 1592199822514,
    "tls_ca_root_cert": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "tls_cert": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "type": "fabric-orderer"
}

What's next?

By using REST APIs, you can obtain in-depth information about your components and even manipulate components. One example would be deleting a specific component using the same API with a different API method.

IBM Blockchain Platform for anywhere accepts the same set of APIs, so you can explore more in the documentation for IBP on IBM Cloud

Be the first to hear about news, product updates, and innovation from IBM Cloud