5.2 Using curl

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, however we will use curl for our examples.

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

Authorization: Bearer [token]

A basic curl request would appear as follows:

Request
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:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1ODE2NDkxNjgsInN1YiI6IjEifQ.v9RtjorEh9vb1anu6vC67IZ63ka_h_JWtjh1f6NKoFI

You can make a curl request like this:

Request
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
{
    "status": 200,
    "message": "success",
    "result": {
        "output": "2001.000",
        "summarizedInputs": []
    }
}