Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitwala

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitwala

Node client for the Bitwala API (docs.bitwala.apiary.io)

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

API Node Client

Node client for the Bitwala.

For a detailed explanation of our API routes, please check out the documentation

Quick Start

  1. Go to https://my.bitwala.io/api-apps
  2. Create an app and store your token ID and secret
  3. yarn add bitwala
import bitwala from 'bitwala';

const token = {
  _id: 'SuBnyc6d564P49Uuls',
  secret: 'LTdFE6hw725yh0aM4m4azACEZSpNrtl4aowFjCZetSAAPBaGN3Ecq7FgMSR5b3Va'
};

const client = bitwala.client({
  token: token,
  env: 'sandbox'
});

client.info('inputs')
  .then(data => console.log(data))
  .catch(err => console.error(err));

/*
[
    {
        "collection": "BitcoinInvoices",
        "currency": "XBT"
    }
]
*/

Environments

The client can be initialised with the sandbox or production env.

For a breakdown of the differences, see our docs.

Methods

EndpointMethodClient
/infoGET.info()
/info/inputsGET.info('inputs')
/info/outputsGET.info('outputs')
/authGET.auth()
/transactions?page=1GET.transactions.get({page: 1})
/transactions?transactionId=transactionIdGET.transactions.get({transactionId: 'YRTvEJxAEm3MB1GI'})
/transactions?ref=refGET.transactions.get({ref: 'YRTvEJxAEm3MB1GI'})
/transactionsPOST.transactions.create(yourTransactionObj})
/transactions/refreshPOST.transactions.refresh({transactionId: transactionId}})
/transactions/refreshPOST.transactions.refresh({transactionId: transactionId}})

Promises / Callbacks

All api calls can be used with promises or callbacks.

With callbacks

client.info((e, data) => {
  if (e) {
    return console.error(e);
  }
  console.log(data);
})

With promises

client.info()
  .then(data => console.log(data));

With await and async (if you're using ES7)

(async function () {
  let data;

  try {
    await data = client.info();
  } catch (err) {
    console.error(err);
  }

  console.log(data);
})();

Examples

Get a transaction by ref

client.transactions.get({ref: 'My custom id'});
  .then(r => console.log(r))
  .catch(err => console.log(err));

Create a transfer to Germany

client.transactions.create({
  ref: 'My custom id',
  webhookUrl: '...', // example: https://test.com/callbacks/bitwala
  inputs: [{
    collection: 'BitcoinInvoices',
    doc: {
      currency: 'XBT',
      convertedCurrency: 'EUR',
      convertedAmount: 100
    }
  }],
  outputs: [{
    collection: 'BankTransfers',
    doc: {
      amount: 100,
      currency: 'EUR',
      reference: 'January Salary',
      bankAccount: {
        recipientType: 'INDIVIDUAL',
        firstName: 'Satoshi',
        lastName: 'Nakamoto',
        iban: 'DE89370400440532013000',
        currency: 'EUR'
      }
    }
  }]
}).then(r => console.log(r))
  .catch(err => console.log(err));

Receive and verify webhooks

import bitwala from 'bitwala';
import express from 'express';
import bodyParser from 'body-parser';

const token = {
  _id: 'SuBnyc6d564P49Uuls',
  secret: 'LTdFE6hw725yh0aM4m4azACEZSpNrtl4aowFjCZetSAAPBaGN3Ecq7FgMSR5b3Va'
};

const router = express.Router();

router.use(bodyParser.json({
  limit: '100kb',
  type: 'application/*+json'
}));

router.post('/callbacks/bitwala', function (req, res, next) {
  // !important: use body-parser
  const signatureOk = bitwala.verifications.verifyCallback(req, token.secret);
  ...
  res.success();
});
...

Keywords

FAQs

Package last updated on 30 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc