Requests

Send a message to a node that requires a response.

Obyte.js library has API helper functions for most requests that the WebSocket API supports (even some that are not documented: api.getTempPubkey, api.tempPubkey, api.deliver), but if there is anything missing, it's possible to extend it with existing internal functions. Here is quick start example written without the helper function.

Example

// API helper function
client.api.getJoint('oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=', function(err, result) {
  if (err) return console.error(err);
  console.log(result);
});

// internal function
client.client.request('get_joint', 'oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=', function(err, result) {
  if (err) return console.error(err);
  console.log(result);
});

Here is an example of a response that you may receive:

{
  "joint": {
    "unit": {Object}
  }
}

Last updated