Skip to content

Commit e574c17

Browse files
committed
Add readme and class doc
1 parent b11214a commit e574c17

4 files changed

Lines changed: 400 additions & 7 deletions

File tree

README.md

Lines changed: 226 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,226 @@
1-
# TODO
1+
# Biscoint API wrapper for python
2+
3+
This is a simple wrapper for Biscoint's API (v1). It handles all authentication stuffs so you can just worry about your killer robot.
4+
5+
## Dependencies
6+
7+
It only depends on the awesome [requests](https://requests.readthedocs.io/en/master/) package.
8+
9+
## Usage
10+
11+
```
12+
pip install biscoint-api-python
13+
```
14+
15+
### Example
16+
17+
```python
18+
import json
19+
import requests
20+
21+
from biscoint_api_python import Biscoint
22+
23+
api_data = {
24+
'api_key': '3ddc931bf25c94ff0344a2e409aa37339e400b8d4da72265f97c3a31d0cfb36e',
25+
'api_secret': 'd4c4db1567fba7dbc63b73e0a5c3a810360825a1de4530e05a77652efce91bcb',
26+
}
27+
28+
bsc = Biscoint(api_data['api_key'], api_data['api_secret'])
29+
30+
try:
31+
ticker = bsc.get_ticker()
32+
print(json.dumps(ticker, indent=4))
33+
34+
"""
35+
{
36+
"base": "BTC",
37+
"quote": "BRL",
38+
"vol": 0.07414472,
39+
"low": 36010.54,
40+
"high": 36285,
41+
"last": 36069,
42+
"ask": 35343.56,
43+
"askQuoteAmountRef": 1000,
44+
"askBaseAmountRef": 0.0282937,
45+
"bid": 35149.76,
46+
"bidQuoteAmountRef": 1000,
47+
"bidBaseAmountRef": 0.0284497,
48+
"timestamp": "2020-01-23T12:26:11.564Z"
49+
}
50+
"""
51+
52+
fees = bsc.get_fees()
53+
print(json.dumps(fees, indent=4))
54+
55+
"""
56+
{
57+
"withdrawal": {
58+
"BTC": {
59+
"rate": "0.0",
60+
"fixed": {
61+
"slow": "0.00005",
62+
"normal": "0.00013",
63+
"fast": "0.0002"
64+
}
65+
},
66+
"BRL": {
67+
"rate": "0.0",
68+
"fixed": {
69+
"ted": "14.90",
70+
"sameBankTransfer": "14.90"
71+
}
72+
}
73+
}
74+
}
75+
"""
76+
77+
meta = bsc.get_meta()
78+
print(json.dumps(meta, indent=4))
79+
80+
"""
81+
{
82+
"version": "v1",
83+
"endpoints": {
84+
"ticker": {
85+
"get": {
86+
"type": "public",
87+
"rateLimit": {
88+
"windowMs": 60000,
89+
"maxRequests": 6000,
90+
"rate": "6000 per 1 minute"
91+
}
92+
}
93+
},
94+
"fees": {
95+
"get": {
96+
"type": "public",
97+
"rateLimit": {
98+
"windowMs": 60000,
99+
"maxRequests": 2000,
100+
"rate": "2000 per 1 minute"
101+
}
102+
}
103+
},
104+
"meta": {
105+
"get": {
106+
"type": "public",
107+
"rateLimit": {
108+
"windowMs": 60000,
109+
"maxRequests": 2000,
110+
"rate": "2000 per 1 minute"
111+
}
112+
}
113+
},
114+
"balance": {
115+
"get": {
116+
"type": "private",
117+
"rateLimit": {
118+
"windowMs": 60000,
119+
"maxRequests": 12000,
120+
"rate": "12000 per 1 minute"
121+
}
122+
}
123+
},
124+
"offer": {
125+
"get": {
126+
"type": "private",
127+
"rateLimit": {
128+
"windowMs": 60000,
129+
"maxRequests": 24000,
130+
"rate": "24000 per 1 minute"
131+
}
132+
},
133+
"post": {
134+
"type": "private",
135+
"rateLimit": {
136+
"windowMs": 60000,
137+
"maxRequests": 24000,
138+
"rate": "24000 per 1 minute"
139+
}
140+
}
141+
},
142+
"trades": {
143+
"get": {
144+
"type": "private",
145+
"rateLimit": {
146+
"windowMs": 60000,
147+
"maxRequests": 12000,
148+
"rate": "12000 per 1 minute"
149+
}
150+
}
151+
}
152+
}
153+
}
154+
"""
155+
156+
balance = bsc.get_balance()
157+
print(json.dumps(balance, indent=4))
158+
159+
"""
160+
{
161+
"BRL": "9580.58",
162+
"BTC": "0.01138164"
163+
}
164+
"""
165+
166+
trades = bsc.get_trades(op='buy', length=1)
167+
print(json.dumps(trades, indent=4))
168+
169+
"""
170+
[
171+
{
172+
"id": "D6x63B3q3Mec4tggY",
173+
"op": "buy",
174+
"base": "BTC",
175+
"quote": "BRL",
176+
"baseAmount": "0.01000000",
177+
"quoteAmount": "362.82",
178+
"apiKeyId": "BdFABxNakZyxPwnRu",
179+
"efPrice": "36282.00",
180+
"date": "2020-01-22T23:25:02.785Z"
181+
}
182+
]
183+
"""
184+
185+
offer = bsc.get_offer('buy', '0.002', False)
186+
print(json.dumps(offer, indent=4))
187+
188+
"""
189+
{
190+
"offerId": "ets52q7WQLrWw79Bq",
191+
"base": "BTC",
192+
"quote": "BRL",
193+
"op": "buy",
194+
"isQuote": false,
195+
"baseAmount": "0.01000000",
196+
"quoteAmount": "353.43",
197+
"efPrice": "35343.00",
198+
"createdAt": "2020-01-23T12:26:13.454Z",
199+
"expiresAt": "2020-01-23T12:26:28.454Z",
200+
"apiKeyId": "BdFABxNakZyxPwnRu"
201+
}
202+
"""
203+
204+
# WARNING: this will actually execute the buy operation!
205+
offerConfirmation = bsc.confirm_offer(offer['offerId'])
206+
print(json.dumps(offerConfirmation, indent=4))
207+
208+
"""
209+
{
210+
"offerId": "ets52q7WQLrWw79Bq",
211+
"base": "BTC",
212+
"quote": "BRL",
213+
"op": "buy",
214+
"isQuote": false,
215+
"baseAmount": "0.01000000",
216+
"quoteAmount": "353.43",
217+
"efPrice": "35343.00",
218+
"createdAt": "2020-01-23T12:26:13.454Z",
219+
"confirmedAt": "2020-01-23T12:26:14.096Z",
220+
"apiKeyId": "BdFABxNakZyxPwnRu"
221+
}
222+
"""
223+
except requests.exceptions.HTTPError as error:
224+
print(error)
225+
print(json.dumps(error.response.json(), indent=4))
226+
```

0 commit comments

Comments
 (0)