This nodejs module connects to surbtc api in order to get quotes and execute orders.
npm install surbtc-rest-client
var surBtcRestClient = require("surbtc-rest-client");
var client = new surBtcRestClient({
api: 'http://surbtc.com/api/v1',
secret: 'apiKey',
params: {}
});
client.getMarkets(function(err, res){
})
Response:
{
success: true,
markets: [
{ name: , base_currency: , quote_currency: }
],
statusCode: 200
}
-
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
}
client.generateUUID(function(err, res){
})
-
marketId: string - required
client.getOrderBook(marketId, function (err, res){ })
Response:
{
success: true,
order_book: {
asks: [amount, limit],
bids: [amount, limit]
}
}
Returns the number of fiat cents equivalent to amount
BTC satoshis on the marketId
market.
-
type=ask => fiat cents that I would get for
amount
satoshis -
type=bid => fiat cents I have to pay to get
amount
satoshis -
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
}
Returns the number of BTC satoshis equivalent to amount
cent of fiat on the marketId
market.
-
type=ask => BTC satoshis I would get for
amount
fiat cents -
type=bid => BTC satoshis I have to pay to get
amount
fiat cents -
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
}
-
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:
}
}
client.getOrders(marketId, function(err, res){
})
Response:
{
success: true,
orders: [],
meta: {}
}
client.getOrdersByState(marketId, state, function(err, res){
})
Response:
{
success: true,
orders: [],
meta: {}
}
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:
}
}
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:
}
}
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:
}
}
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 }
Should cancel order if not traded after X seconds?