From cffc3db7bcfedc02f6e7f908c88e13c2d4751917 Mon Sep 17 00:00:00 2001 From: Bogdan Teodoru Date: Mon, 12 Jul 2021 14:45:12 +0300 Subject: [PATCH] Various improvements and API updates --- README.md | 23 +++++++---------------- py3cw/config.py | 6 ++++-- py3cw/request.py | 7 +++++-- setup.py | 2 +- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9e2d640..1cc95ba 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,6 @@ pip install py3cw How to use -NOTE: Untill I manage to refactor and remove V1, please use the API with ```entity='smart_trades_v2'```. Thank you! -*** - ```python from py3cw.request import Py3CW @@ -41,7 +38,7 @@ p3cw = Py3CW( # Destruct response to error and data # and check first if we have an error, otherwise check the data error, data = p3cw.request( - entity='smart_trades', + entity='smart_trades_v2', action='' ) @@ -49,25 +46,21 @@ error, data = p3cw.request( # Destruct response to error and data # and check first if we have an error, otherwise check the data error, data = p3cw.request( - entity='smart_trades', - action='create_smart_trade', - payload={ - "account_id": 123456 - } + entity='smart_trades_v2', + action='new', + payload={} ) # With action_id replaced in URL # Destruct response to error and data # and check first if we have an error, otherwise check the data error, data = p3cw.request( - entity='smart_trades', - action='pie_chart_data', + entity='smart_trades_v2', + action='get_by_id', action_id='123456' ) ``` -*** - An `entity` represents main categories. Meaning, you have `accounts`, `bots`, `marketplace`, `deals` or `smart_trades` An `action` is represented by a ... well, an action of a specific category. There are multiple actions you can use (check 3commas API) @@ -92,9 +85,7 @@ Marketplace: https://github.com/3commas-io/3commas-official-api-docs/blob/master Grid Bots: https://github.com/3commas-io/3commas-official-api-docs/blob/master/grid_bots_api.md -Smart Trades: https://github.com/3commas-io/3commas-official-api-docs/blob/master/smart_trades_api.md - -Smart Trades V2: https://github.com/3commas-io/3commas-official-api-docs/blob/master/smart_trades_v2_api.md +Smart Trades: https://github.com/3commas-io/3commas-official-api-docs/blob/master/smart_trades_v2_api.md *** Best used with [Binance](https://www.binance.com/en/register?ref=XEK765NE). diff --git a/py3cw/config.py b/py3cw/config.py index 85badd0..d57b586 100644 --- a/py3cw/config.py +++ b/py3cw/config.py @@ -1,7 +1,7 @@ API_URL = 'https://api.3commas.io' API_VERSION_V1 = '/public/api/ver1/' API_VERSION_V2 = '/public/api/v2/' -API_VERSION_V2_ENTITIES = ['smart_trades_v2'] +API_VERSION_V2_ENTITIES = ['smart_trades', 'smart_trades_v2'] # API methods from # https://github.com/3commas-io/3commas-official-api-docs @@ -74,7 +74,9 @@ 'items': ('GET', 'items'), 'signals': ('GET', '{id}/signals') }, - 'smart_trades': { + # smart_trades has been deprecated + # Please don't use it anymore. Left here only for history reference + 'smart_trades_deprecated': { '': ('GET', ''), 'create_simple_sell': ('POST', 'create_simple_sell'), 'create_simple_buy': ('POST', 'create_simple_buy'), diff --git a/py3cw/request.py b/py3cw/request.py index 5e0259d..8153fb8 100644 --- a/py3cw/request.py +++ b/py3cw/request.py @@ -129,8 +129,11 @@ def __make_request(self, http_method: str, path: str, params: any, payload: any, return {'error': True, 'msg': 'HTTP error occurred: {0}'.format(http_err)}, None except Exception: - return {'error': True, 'msg': 'Other error occurred: {} {}.'.format( - response_json.get('error'), response_json.get('error_description'))}, None + return {'error': True, 'msg': 'Other error occurred: {} {} {}.'.format( + response_json.get('error'), + response_json.get('error_description'), + response_json.get('error_attributes') + )}, None @verify_request def request(self, entity: str, action: str = '', action_id: str = None, action_sub_id: str = None, diff --git a/setup.py b/setup.py index 551ab69..25a06d6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='py3cw', - version='0.0.21', + version='0.0.22', description='3commas Python wrapper',