Interact with the API

There are various tools available to interact with a REST API. Curl is a free, open source command line utility that can be used to interact with URLs including those defined in the MultiBaas API. You can also use another tool like Postman, or directly use the HTTP libraries in any number of programming languages such as Golang's Package http.

Using curl

The API keys used by MultiBaas are bearer tokens. To use it when accessing the API, include it in the authorization header as:

Copy
Copied
Authorization: Bearer [token]

A basic curl request would appear as follows:

Request:

Copy
Copied
curl -H "Authorization: Bearer [token]" \
     -X POST \
     [host]/api/[api_version]/chains/ethereum/addresses/[address_label]/contracts/[contract_label]/methods/[method_name]

Example

Using the following example token:

Copy
Copied
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1ODE2NDkxNjgsInN1YiI6IjEifQ.v9RtjorEh9vb1anu6vC67IZ63ka_h_JWtjh1f6NKoFI

You can make a curl request like this:

Request:

Copy
Copied
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1ODE2NDkxNjgsInN1YiI6IjEifQ.v9RtjorEh9vb1anu6vC67IZ63ka_h_JWtjh1f6NKoFI" \
     -X POST \
     https://example.multibaas.com/api/v0/chains/ethereum/addresses/curvetoken/contracts/mltitoken/methods/totalSupply

Response:

Copy
Copied
{
    "status": 200,
    "message": "success",
    "result": {
        "output": "2001.000",
        "summarizedInputs": []
    }
}
Copyright © Curvegrid 2022. All right reserved.