0.9.0 • Published 3 years ago

bitspider v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

BitSpider REST API

Note that BitSpider API is currently in BETA phase and may not be available to all users!

Official Node.js library for accessing BitSpider REST API.

Getting Started

Log in to BitSpider to get the API key and the API secret.

Install required dependencies

npm install

Test API key and secret by making a user info request

const { BitSpider } = require('bitspider');

let bitspider = new BitSpider({
  apiKey: "your_api_key_goes_here",
  apiSecret: "your_api_secret_goes_here",
});

bitspider
.getUserInfo()
.then(user => console.log(user))
.catch(err => console.error(err));

Using Promise

Example using async-await approach

const { BitSpider } = require('bitspider');

(async () => {
  //Create a new instance
  let bitspider = new BitSpider({
    apiKey: "your_api_key_goes_here",
    apiSecret: "your_api_secret_goes_here",
  });

  //Estimate the exchange amount from Euro to Bitcoin
  let estimated = await bitspider.estimatePrice({
    requestedCurrency: "EUR",
    requestedAmount: 120.0,
    intermediateCurrency: "BTC"
  });
  console.log(estimated);

  //Create a new payment request with Bitcoin as intermediate currency
  let created = await bitspider.createPaymentRequest({
    requestedCurrency: "EUR",
    requestedAmount: 120.0,
    intermediateCurrency: "BTC"
  });
  console.log(created);

  //Verify the payment request status
  let result = await bitspider.getPaymentRequestById(created.id);
  console.log(result);
})();

List of methods

The following methods correspond to API calls.

Payment request

Method and argumentsCorresponds toDescription
getPaymentRequests(query)GET /merchant/paymentList payment requests
getPaymentRequestById(id)GET /merchant/payment/:idGet payment request by id
createPaymentRequest(data)POST /merchant/paymentCreate payment request
cancelPaymentRequest(id)DELETE /merchant/payment/:idDelete payment request

Withdrawal request

Method and argumentsCorresponds toDescription
getWithdrawalRequests(query)GET /merchant/withdrawalList withdrawal requests
getWithdrawalRequestById(id)GET /merchant/withdrawal/:idGet withdrawal request by id
createWithdrawalRequest(data)POST /merchant/withdrawalCreate withdrawal request
cancelWithdrawalRequest(id)DELETE /merchant/withdrawal/:idDelete withdrawal request

Miscellaneous

Method and argumentsCorresponds toDescription
estimatePrice(data)POST /merchant/estimateEstimate price in cryptocurrency
getBalance()GET /merchant/balanceGet user's balance
getUserInfo()GET /user/meGet user info

Please refer to unit tests for more info.

Unit Test

First set API_KEY and API_SECRET as environment variables, then run

npm run test

On Unix system

#!/bin/bash
VERBOSE=0
API_KEY=your_api_key_goes_here
API_SECRET=your_api_secret_goes_here
npm run test

On Windows system

@echo off
setlocal
set VERBOSE=0
set API_KEY=your_api_key_goes_here
set API_SECRET=your_api_secret_goes_here
npm run test
endlocal
0.9.0

3 years ago