'call' API Method

POST https://api.bws.ninja/v1/call

BWS marketplace solutions use a single API endpoint to call BWS Solutions: https://api.bws.ninja/v1/call

CODE EXAMPLE

The following javascript code shows how to use BWS.Blockchain.Save to write "Hello World!" to the mumbai blockchain network using the save operation.

const response = await fetch("https://api.bws.ninja/v1/call", {
  method: "post",
  body: JSON.stringify({
    solution: "BWS.Blockchain.Save",
    version: 1,
    network: "mumbai",
    operation: "save",
    parameters: {
      value: "Hello World!",
    },
  }),
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": "your api key",
  },
});
const result = await response.json();

if (result.statusCode != 200) throw new Error(result.statusMessage);

return result;

Method Parameters

Please include the following parameters on each API call in the Body part of a POST request message using JSON format (Content-Type header attribute must be set to application/json)

Please note:

  • The solution, operation and parameters attributes are used to call any of the Blockchain Web Services available solutions.

  • network is the blockchain network you want to use (for example, use the mumbainetwork to test without requiring any funds).

  • Check the available networks for the selected solution you plan to use.

API call Response

Whenever you execute a call to run a BWS solution, please note the following:

  • If your call is correctly received, you will get a 200 status code.

  • If your call is asynchronous, the info attribute of the response will contain the jobId you can use to call the fetch operation to get the call status and results.

  • If your call is synchronous, the info part will contain the call result values.

API RESPONSE EXAMPLE

Response example when running a call to an asynchronous operation.

{
  "statusCode": 200,
  "info": {
    "jobId": "aacee908-3a85-4966-945c-ab8f09ebabf9"
  }
}

Last updated