npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

surbtc-rest-client

v2.0.0

Published

A Node.js client library for interacting with surbtc REST API.

Downloads

3

Readme

surbtc-rest-client

This nodejs module connects to surbtc api in order to get quotes and execute orders.

JavaScript Style Guide

Installation

npm install surbtc-rest-client

Usage

var surBtcRestClient = require("surbtc-rest-client");

var client = new surBtcRestClient({
  api: 'http://surbtc.com/api/v1',
  secret: 'apiKey',
  params: {}
  });

Primary functions

Get Markets

client.getMarkets(function(err, res){

})

Response:

  {
    success: true,
    markets: [
      { name: , base_currency: , quote_currency:  }
    ],
    statusCode: 200
  }

Get Exchange Fee

  • marketId: string - required

  • type: string - required

  • marketOrder: boolean - optional

      client.getExchangeFee(marketId, type, marketOrder, function(err, res){
    
      })

Response:

  {
    success: true,
    fee_percentage: { value: },
    statusCode: 200
  }

Generate UUID

client.generateUUID(function(err, res){

})

Get Order Book

  • marketId: string - required

      client.getOrderBook(marketId, function (err, res){
    
      })

Response:

  {
    success: true,
    order_book: {
      asks: [amount, limit],
      bids: [amount, limit]
    }
  }

Get Quotation

Returns the number of fiat equivalent to amount BTC on the marketId market.

  • type=ask => fiat that I would get for amount BTC

  • type=bid => fiat I have to pay to get amount BTC

  • marketId: string - required

  • type: string - required

  • amount: Number - required

      client.getQuotation(marketId, type, amount, function(err, res){
    
      })

Response:

  {
    success: true,
    quotation: {
      type: type,
      reverse: false,
      amount: amount,
      order_amount: [ amount, currency ],
      base_balance_change: [ amount, currency ],
      quote_balance_change: [ -amount, currency ],
      fee: [ fee, currency ],
      incomplete: false
    },
    statusCode: 200
  }

Get Reverse Quotation

Returns the number of BTC equivalent to amount of fiat on the marketId market.

  • type=ask => BTC I would get for amount fiat

  • type=bid => BTC I have to pay to get amount fiat

  • marketId: string - required

  • type: string - required

  • amount: Number - required

      client.getReverseQuotation(marketId, type, amount, function(err, res){
    
      })

Response:

  {
    success: true,
    quotation: {
      type: type,
      reverse: true,
      amount: amount,
      order_amount: [ amount, currency ],
      base_balance_change: [ amount, currency ],
      quote_balance_change: [ -amount, currency ],
      fee: [ fee, currency ],
      incomplete: false
    },
    statusCode: 200
  }

Create Order

  • marketId: string - required

  • order: order: { type:, limit:, amount:, original_amount:, price_type: }

      client.createOrder(marketId, order, function(err, res){
    
      })

Response:

{
  success: true,
  order: {
    id: ,
    type: ,
    state: ,
    limit: ,
    amount: ,
    original_amount: ,
    created_at: ,
    market_id: ,
    paid_fee: ,
    total_exchanged: ,
    fee_currency: ,
    price_type: ,
    weighted_quotation: ,
    account_id:
  }
}

Get Orders

client.getOrders(marketId, function(err, res){

})

Response:

{
  success: true,
  orders: [],
  meta: {}
}

Get Orders by State

client.getOrdersByState(marketId, state, function(err, res){

})

Response:

{
  success: true,
  orders: [],
  meta: {}
}

Get Order Id

client.getOrderId(orderId, function(err, res){

})

Response:

{
  success: true,
  order: {
    id:
    type:
    state:
    limit:
    amount:
    original_amount:
    created_at:
    market_id:
    paid_fee:
    total_exchanged:
    fee_currency:
    price_type:
    weighted_quotation:
    account_id:
  }
}

Cancel Order Id

client.cancelOrderId(orderId, function(err, res){

})

Response:

{
  success: true,
  order: {
    id:
    type:
    state:
    limit:
    amount:
    original_amount:
    created_at:
    market_id:
    paid_fee:
    total_exchanged:
    fee_currency:
    price_type:
    weighted_quotation:
    account_id:
  }
}

Create and Trade Order

client.createAndConfirmOrder(marketId, order, function(err, res){

})

Response:

 {
    success: true,
    order: {
      id:
      type:
      state:
      limit:
      amount:
      original_amount:
      created_at:
      market_id:
      paid_fee:
      total_exchanged:
      fee_currency:
      price_type:
      weighted_quotation:
      account_id:
    }
  }

registerBankAccount

var opts = {
  bank_name: 'Banco Santander',
  bank_account_holder_name: 'jaime echegaray',
  bank_account_holder_id: '157715003',
  bank_account_type: 'Cuenta Corriente',
  bank_account_number: 123456,
  bank_currency: 'cop',
  email: '',
  phone: ''
}

client.registerBankAccount(opts, function(err, res){

})

Response:

{ success: true,
  fiat_account: 
   { id: 943,
     account_number: '123456',
     account_type: 'Cuenta Corriente',
     bank_id: 56,
     created_at: '2016-09-06T18:13:16.864Z',
     currency: 'COP',
     document_number: '157715003',
     email: '',
     full_name: 'jaime echegaray',
     national_number_identifier: null,
     phone: '',
     updated_at: '2016-09-06T18:13:16.864Z',
     bank_name: 'Banco Santander' },
  statusCode: 200 }

registerDeposit

  • amount in currency standard precision

      var opts = {
        amount: 1000,
        currency: 'CLP',
      }
    
      client.registerDeposit(opts, function(err, res){
    
      })

Response:

{ success: true,    
  deposit:       
    { id: 2869,        
    state: 'pending_confirmation',
    amount: 1000000,
    currency: 'CLP',
    created_at: '2016-10-05T19:02:49.696Z',
    deposit_data: 
    { type: 'FiatDepositData',        
      id: 1530,
      created_at: '2016-10-05T19:02:49.673Z',
      updated_at: '2016-10-05T19:02:49.673Z' } 
    },
  statusCode: 200 }

requestWithdrawal

  • amount in currency standard precision

      var opts = {
        amount: 1,
        currency: 'BTC',
        target_address: ''
      }
    
      client.requestWithdrawal(opts, function(err, res){
    
      })

Response:

{ success: true,    
  withdrawal:       
    { id: 2869,        
    state: 'pending_preparation',
    amount: 100000000,
    currency: 'BTC',
    created_at: '2016-10-05T19:02:49.696Z',
    require_manual_approval: false, 
  statusCode: 200 }

To Do:

Should we promisify or promisifyAll this?

http://bluebirdjs.com/docs/api/promise.promisify.html http://bluebirdjs.com/docs/api/promise.promisifyall.html

createAndTradeOrder

Should cancel order if not traded after X seconds?

get pending withdrawals https://stg.surbtc.com/api/v1/withdrawals/current_unconfirmed?currency=COP

get bitcoin pending withdrawals https://stg.surbtc.com/api/v1/withdrawals/current_unconfirmed?currency=BTC

Los withdrawals se limpian cuando la transaccion tiene una confirmacion. ~6 minutos en testnet

get per currency account (retrieves last only) https://stg.surbtc.com/api/v1/fiat_accounts/CLP?api_key=a061fc555331d1285a89b012676d6e7c

https://stg.surbtc.com/api/v1/balance_events?currencies[]=BTC&api_key=a061fc555331d1285a89b012676d6e7c&event_names[]=withdrawal_confirm