Skip to content

Commit

Permalink
revert API_URL and query path changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rentorm committed Jan 23, 2020
1 parent 4800872 commit a7ad4c3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
```

Expand Down
84 changes: 42 additions & 42 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down Expand Up @@ -50,179 +50,179 @@ 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 })
}

/**
* Bots methods
*/

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 })
}

/**
* Smart Trades methods
*/

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 })
}

/**
* Accounts methods
*/

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 })
}

}
Expand Down

0 comments on commit a7ad4c3

Please sign in to comment.