reserve-sdk
v2.0.24
Published
Simple sdk for reserve
Downloads
29
Readme
Reserve SDK
Installation
npm i reserve-sdk
Usage
Custom headers
// auth headers
Sdk_Instance.setAuthToken('auth_token')
Sdk_Instance.setXReserveAuth('x_reserve_auth_value');
console.log(Sdk_Instance.getHeaders());
// custom headers
Sdk_Instance.setCustomHeader('x-reserve-auth', 'value');
Sdk_Instance.setCustomHeader('custom_header', 'custom_value');
console.log(Sdk_Instance.getHeaders());
Methods
- health check
- check-in
- trader demo signin
- admin demo signin
- service demo signin
- get users
- get user info
- update user
- get account balances
- create conversion quote
- create conversion order
- create account transaction
- get instruments
- get instruments price bars
- generate deposit address crypto
- create withdrawal fiat
- get conversions
- get payments
- get payments routes
Health check
Allows to perform a healthcheck request
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.healthcheck();
Check-in
Allows AUTHENTICATED users to perform check-in request
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_or_trader_token");
const res = await Sdk_Instance.checkin();
Trader demo signin
Allows to obtain demo TRADER authentication token for specified username
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.trader_demo_signin({username:"example_1_2_3"});
Admin demo signin
Allows to obtain demo ADMIN authentication token for specified username
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.admin_demo_signin({username:"example_1_2_3"});
Service demo signin
Allows to obtain demo SERVICE authentication token for specified username
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.service_signin({service_api_key:"example_1_2_3",service_api_secret:"example_4_5_6"});
Get users
Allows ADMINS to get users that can be filtered by multiple parameters
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token");
const users = await Sdk_Instance.get_users({username: 'y', pager: {limit: 3}});
Get user info
Update user
Get account balances
Allows AUTHENTICATED users to get account balance
Trader - no args are required
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("trader_token");
const accounts_balances_trader = await Sdk_Instance.get_account_balances();
Admin - user_id arg is required
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token")
const accounts_balances_admin = await Sdk_Instance.get_account_balances({user_id: '3e8a836f-9bf5-4915-8c0b-e628396740bf'});
Create conversion quote
Allows AUTHENTICATED users to get estimated conversion quote
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_or_trader_token");
const conversion_quote = await Sdk_Instance.create_conversion_quote({source_currency_id: 'BTC', target_currency_id: 'USDT', source_currency_amount: 30});
Create conversion order
Allows AUTHENTICATED to execute estimated conversion_quote
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_or_trader_token");
const res = await Sdk_Instance.create_conversion_order({conversion_quote_id: 'your_conversion_quote_id'});
Create account transaction
Allows ADMINS to create new transactions
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken('your_admin_token');
const res = await Sdk_Instance.create_account_transaction({
items: [
{
user_id: '3e8a836f-9bf5-4915-8c0b-e628396740bf',
currency_id: 'USDT',
amount: 150,
transaction_class: 'payment',
comment: 'Example 1 2 3',
type: 'credit',
},
{
user_id: '3e8a836f-9bf5-4915-8c0b-e628396740bf',
currency_id: 'USDT',
amount: 100,
transaction_class: 'reward',
comment: 'Example 1 2 3',
type: 'debit',
},
],
});
Get instruments
Allows to get detailed data about instruments
import {Reserve_SDK, InstrumentHistoryPeriodicity} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.get_instruments({
periodicity: InstrumentHistoryPeriodicity['day'],
limit: 3,
});
Get instruments price bars
Allows to get detailed price bars data about specified instrument
import {Reserve_SDK, InstrumentHistoryPeriodicity} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
const res = await Sdk_Instance.get_instrument_price_bars({
instrument_id: 'BTCUSDT',
periodicity: InstrumentHistoryPeriodicity.day,
limit: 3,
});
Generate deposit address crypto
Allows AUTHENTICATED users to create generate new crypto deposit addresses
Trader
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("trader_token");
const res = await Sdk_Instance.deposit_address_crypto({network: 'example_network', currency_id: 'BTC'});
Admin - user_id arg is required
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token")
const res = await Sdk_Instance.deposit_address_crypto({
currency_id: 'BTC',
user_id: 'example_user_id',
network: 'example_network',
});
Create fiat withdrawal
Allows AUTHENTICATED users to create fiat withdrawals
Trader
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("trader_token");
const res = await Sdk_Instance.create_withdrawal_fiat({
amount: 0.5,
currency_id: 'USD',
fiat_bank_bic: 'example_fiat_bank_bic',
fiat_bank_name: 'example_fiat_bank_name',
fiat_beneficiary_name: 'example_fiat_beneficiary_name',
fiat_beneficiary_account_number: 'example_fiat_beneficiary_account_number',
});
Admin - user_id arg is required
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token")
const res = await Sdk_Instance.create_withdrawal_fiat({
user_id: 'example_user_id',
amount: 0.5,
currency_id: 'USD',
fiat_bank_bic: 'example_fiat_bank_bic',
fiat_bank_name: 'example_fiat_bank_name',
fiat_beneficiary_name: 'example_fiat_beneficiary_name',
fiat_beneficiary_account_number: 'example_fiat_beneficiary_account_number',
});
Get conversions
Allows AUTHENTICATED users to get conversions history
Trader
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("trader_token");
const res = await Sdk_Instance.get_conversions({
source_currency_id: 'BTC',
target_currency_id: 'ETH',
pager: {limit:3,offset:1},
dateRange: {
time_from: '2022-07-28 16:20:01',
time_to: '2022-08-02 18:40:05',
}
});
Admin
import {Reserve_SDK} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token")
const res = await Sdk_Instance.get_conversions({
user_id:'example_user_id',
source_currency_id: 'BTC',
target_currency_id: 'ETH',
pager: {limit:3,offset:1},
dateRange: {
time_from: '2022-07-28 16:20:01',
time_to: '2022-08-02 18:40:05',
}
});
Get payments
Allows AUTHENTICATED users to get payments history
Trader
import {Reserve_SDK,PaymentType,PaymentStatus} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("trader_token");
const res = await Sdk_Instance.get_payments({
currency_id: 'ETH',
type: PaymentType.deposit,
status: [PaymentStatus.completed, PaymentStatus.rejected],
pager: {limit:3,offset:1},
dateRange: {
time_from: '2022-07-28 16:20:01',
time_to: '2022-08-02 18:40:05',
}
});
Admin
import {Reserve_SDK,PaymentType,PaymentStatus} from 'reserve-sdk';
const Sdk_Instance = new Reserve_SDK("your_graphQL_endpoint");
Sdk_Instance.setAuthToken("admin_token");
const res = await Sdk_Instance.get_payments({
user_id: 'example_user_id',
currency_id: 'ETH',
type: PaymentType.deposit,
status: [PaymentStatus.completed, PaymentStatus.rejected],
pager: {limit:3,offset:1},
dateRange: {
time_from: '2022-07-28 16:20:01',
time_to: '2022-08-02 18:40:05',
}
});