Skip to content

Commit

Permalink
Various improvements and API updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanteodoru authored and Bogdan Teodoru committed Jul 12, 2021
1 parent 39e686e commit cffc3db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -41,33 +38,29 @@ 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=''
)

# With payload data
# 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)
Expand All @@ -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).
Expand Down
6 changes: 4 additions & 2 deletions py3cw/config.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'),
Expand Down
7 changes: 5 additions & 2 deletions py3cw/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='py3cw',
version='0.0.21',
version='0.0.22',

description='3commas Python wrapper',

Expand Down

0 comments on commit cffc3db

Please # to comment.