diff --git a/README.md b/README.md index 7cefb6e..b1fdaf4 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ const threeCommasAPI = require('3commas-api-node') const api = new threeCommasAPI({ apiKey: '', apiSecret: '', - // url: 'https://api.3commas.io/public/api' // this is optional in case of defining other endpoint + // url: 'https://api.3commas.io' // this is optional in case of defining other endpoint }) ``` diff --git a/index.js b/index.js index 2aca2c7..1e820a1 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ const querystring = require('querystring'); const crypto = require('crypto') const fetch = require('node-fetch') -const API_URL = 'https://api.3commas.io/public/api' +const API_URL = 'https://api.3commas.io' class threeCommasAPI { constructor(opts = {}) { @@ -50,27 +50,27 @@ class threeCommasAPI { */ async getDeals (params) { - return await this.makeRequest('GET', '/ver1/deals?', params) + return await this.makeRequest('GET', '/public/api/ver1/deals?', params) } async dealUpdateMaxSafetyOrders (deal_id, max_safety_orders) { - return await this.makeRequest('POST', `/ver1/deals/${deal_id}/update_max_safety_orders?`, { deal_id, max_safety_orders }) + return await this.makeRequest('POST', `/public/api/ver1/deals/${deal_id}/update_max_safety_orders?`, { deal_id, max_safety_orders }) } async dealPanicSell (deal_id) { - return await this.makeRequest('POST', `/ver1/deals/${deal_id}/panic_sell?`, { deal_id }) + return await this.makeRequest('POST', `/public/api/ver1/deals/${deal_id}/panic_sell?`, { deal_id }) } async dealCancel (deal_id) { - return await this.makeRequest('POST', `/ver1/deals/${deal_id}/cancel?`, { deal_id }) + return await this.makeRequest('POST', `/public/api/ver1/deals/${deal_id}/cancel?`, { deal_id }) } async dealUpdateTp (deal_id, new_take_profit_percentage) { - return await this.makeRequest('POST', `/ver1/deals/${deal_id}/update_tp?`, { deal_id, new_take_profit_percentage }) + return await this.makeRequest('POST', `/public/api/ver1/deals/${deal_id}/update_tp?`, { deal_id, new_take_profit_percentage }) } async getDeal (deal_id) { - return await this.makeRequest('GET', `/ver1/deals/${deal_id}/show?`, { deal_id }) + return await this.makeRequest('GET', `/public/api/ver1/deals/${deal_id}/show?`, { deal_id }) } /** @@ -78,55 +78,55 @@ class threeCommasAPI { */ async getBotsBlackList () { - return await this.makeRequest('GET', `/ver1/bots/pairs_black_list?`, null) + return await this.makeRequest('GET', `/public/api/ver1/bots/pairs_black_list?`, null) } async botsUpdateBlackList (params) { - return await this.makeRequest('POST', '/ver1/bots/update_pairs_black_list?', params) + return await this.makeRequest('POST', '/public/api/ver1/bots/update_pairs_black_list?', params) } async botCreate (params) { - return await this.makeRequest('POST', '/ver1/bots/create_bot?', params) + return await this.makeRequest('POST', '/public/api/ver1/bots/create_bot?', params) } async getBots (params) { - return await this.makeRequest('GET', `/ver1/bots?`, params) + return await this.makeRequest('GET', `/public/api/ver1/bots?`, params) } async getBotsStats (params) { - return await this.makeRequest('GET', `/ver1/bots/stats?`, params) + return await this.makeRequest('GET', `/public/api/ver1/bots/stats?`, params) } async botUpdate (params) { - return await this.makeRequest('PATCH', `/ver1/bots/${params.bot_id}/update?`, params) + return await this.makeRequest('PATCH', `/public/api/ver1/bots/${params.bot_id}/update?`, params) } async botDisable (bot_id) { - return await this.makeRequest('POST', `/ver1/bots/${bot_id}/disable?`, { bot_id }) + return await this.makeRequest('POST', `/public/api/ver1/bots/${bot_id}/disable?`, { bot_id }) } async botEnable (bot_id) { - return await this.makeRequest('POST', `/ver1/bots/${bot_id}/enable?`, { bot_id }) + return await this.makeRequest('POST', `/public/api/ver1/bots/${bot_id}/enable?`, { bot_id }) } async botStartNewDeal (params) { - return await this.makeRequest('POST', `/ver1/bots/${params.bot_id}/start_new_deal?`, params) + return await this.makeRequest('POST', `/public/api/ver1/bots/${params.bot_id}/start_new_deal?`, params) } async botDelete (bot_id) { - return await this.makeRequest('POST', `/ver1/bots/${bot_id}/delete?`, { bot_id }) + return await this.makeRequest('POST', `/public/api/ver1/bots/${bot_id}/delete?`, { bot_id }) } async botPaniceSellAllDeals (bot_id) { - return await this.makeRequest('POST', `/ver1/bots/${bot_id}/panic_sell_all_deals?`, { bot_id }) + return await this.makeRequest('POST', `/public/api/ver1/bots/${bot_id}/panic_sell_all_deals?`, { bot_id }) } async botCancelAllDeals (bot_id) { - return await this.makeRequest('POST', `/ver1/bots/${bot_id}/cancel_all_deals?`, { bot_id }) + return await this.makeRequest('POST', `/public/api/ver1/bots/${bot_id}/cancel_all_deals?`, { bot_id }) } async botShow (bot_id) { - return await this.makeRequest('GET', `/ver1/bots/${bot_id}/show?`, { bot_id }) + return await this.makeRequest('GET', `/public/api/ver1/bots/${bot_id}/show?`, { bot_id }) } /** @@ -134,47 +134,47 @@ class threeCommasAPI { */ async smartTradesCreateSimpleSell (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/create_simple_sell?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/create_simple_sell?`, params) } async smartTradesCreateSimpleBuy (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/create_simple_buy?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/create_simple_buy?`, params) } async smartTradesCreateSmartSell (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/create_smart_sell?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/create_smart_sell?`, params) } async smartTradesCreateSmartCover (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/create_smart_cover?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/create_smart_cover?`, params) } async smartTradesCreateSmartTrade (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/create_smart_trade?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/create_smart_trade?`, params) } async smartTrades (params) { - return await this.makeRequest('GET', `/ver1/smart_trades?`, params) + return await this.makeRequest('GET', `/public/api/ver1/smart_trades?`, params) } async smartTradesStepPanicSell (params) { - return await this.makeRequest('POST', `/ver1/smart_trades/${params.smart_trade_id}/step_panic_sell?`, params) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/${params.smart_trade_id}/step_panic_sell?`, params) } async smartTradesUpdate (params) { - return await this.makeRequest('PATCH', `/ver1/smart_trades/${params.smart_trade_id}/update?`, params) + return await this.makeRequest('PATCH', `/public/api/ver1/smart_trades/${params.smart_trade_id}/update?`, params) } async smartTradesCancel (smart_trade_id) { - return await this.makeRequest('POST', `/ver1/smart_trades/${smart_trade_id}/cancel?`, { smart_trade_id }) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/${smart_trade_id}/cancel?`, { smart_trade_id }) } async smartTradesPanicSell (smart_trade_id) { - return await this.makeRequest('POST', `/ver1/smart_trades/${smart_trade_id}/panic_sell?`, { smart_trade_id }) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/${smart_trade_id}/panic_sell?`, { smart_trade_id }) } async smartTradesForceProcess (smart_trade_id) { - return await this.makeRequest('POST', `/ver1/smart_trades/${smart_trade_id}/force_process?`, { smart_trade_id }) + return await this.makeRequest('POST', `/public/api/ver1/smart_trades/${smart_trade_id}/force_process?`, { smart_trade_id }) } /** @@ -182,47 +182,47 @@ class threeCommasAPI { */ async accountsNew (params) { - return await this.makeRequest('POST', `/ver1/accounts/new?`, params) + return await this.makeRequest('POST', `/public/api/ver1/accounts/new?`, params) } async accounts () { - return await this.makeRequest('GET', `/ver1/accounts?`, null) + return await this.makeRequest('GET', `/public/api/ver1/accounts?`, null) } async accountsMarketList () { - return await this.makeRequest('GET', `/ver1/accounts/market_list?`, null) + return await this.makeRequest('GET', `/public/api/ver1/accounts/market_list?`, null) } async accountsCurrencyRates () { - return await this.makeRequest('GET', `/ver1/accounts/currency_rates?`, null) + return await this.makeRequest('GET', `/public/api/ver1/accounts/currency_rates?`, null) } async accountSellAllToUsd (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/sell_all_to_usd?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/sell_all_to_usd?`, { account_id }) } async accountSellAllToBtc (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/sell_all_to_btc?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/sell_all_to_btc?`, { account_id }) } async accountLoadBalances (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/load_balances?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/load_balances?`, { account_id }) } async accountRename (params) { - return await this.makeRequest('POST', `/ver1/accounts/${params.account_id}/rename?`, params) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${params.account_id}/rename?`, params) } async accountPieChartData (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/pie_chart_data?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/pie_chart_data?`, { account_id }) } async accountTableData (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/account_table_data?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/account_table_data?`, { account_id }) } async accountRemove (account_id) { - return await this.makeRequest('POST', `/ver1/accounts/${account_id}/remove?`, { account_id }) + return await this.makeRequest('POST', `/public/api/ver1/accounts/${account_id}/remove?`, { account_id }) } }