Usage
Here are some snippets to get you started.
Initiate
Initiate client.
Authentication
You can pass api_key
and api_secret
to client or set them as environment variables.
When you pass them to client, they will override environment variables.
If api_key
and api_secret
are provided, client will login automatically and get access and refresh tokens.
You can also pass access_token
and refresh_token
to client to skip login.
Environment variables are also supported.
-
BITPIN_API_KEY
- API key. -
BITPIN_API_SECRET
- API secret. -
BITPIN_ACCESS_TOKEN
- Access token. -
BITPIN_REFRESH_TOKEN
- Refresh token.
Background relogin and background refresh access token is supported
You can pass below variables to client to enable background relogin and background refresh access token.
-
background_relogin=bool
- IfTrue
, client will relogin automatically in background. -
background_refresh_access_token=int
- IfTrue
, client will refresh access token automatically in background. -
background_relogin_interval=bool
- Interval between each relogin in seconds. -
background_refresh_access_token_interval=int
- Interval between each refresh access token in seconds.
Note
It uses threading.Thread in synchronous client and asyncio.create_task in asynchronous client.
Reference
- Code Reference: Client
With Request Params
You can pass requests OR aiohttp params to client.
Login
Login to get access and refresh tokens.
Warning
Access token is valid for 15 minutes and refresh token is valid for 7 days.
Reference
- Sync Code Reference: Client.login
- Async Code Reference: AsyncClient.login
- API Documentation Reference: Login
output | |
---|---|
Refresh Token
Refresh access token.
Reference
- Sync Code Reference: Client.refresh_access_token
- Async Code Reference: AsyncClient.refresh_access_token
- API Documentation Reference: Refresh Token
Get User Info
Get user info.
Reference
- Sync Code Reference: Client.get_user_info
- Async Code Reference: AsyncClient.get_user_info
- API Documentation Reference: Get User Info
Get Currencies List
Get currencies list.
Warning
10000/day or 200/minute if you are authenticated.
Reference
- Sync Code Reference: Client.get_currencies_list
- Async Code Reference: AsyncClient.get_currencies_list
- API Documentation Reference: Get Currencies List
Get Markets Info
Get markets info.
Warning
10000/day or 200/minute if you are authenticated.
Reference
- Sync Code Reference: Client.get_markets_info
- Async Code Reference: AsyncClient.get_markets_info
- API Documentation Reference: Get Markets Info
Get Wallets
Get wallets and balances.
Warning
10000/day.
Reference
- Sync Code Reference: Client.get_wallets
- Async Code Reference: AsyncClient.get_wallets
- API Documentation Reference: Get Wallets
Get Orderbook
Get orderbook.
Reference
- Sync Code Reference: Client.get_orderbook
- Async Code Reference: AsyncClient.get_orderbook
- API Documentation Reference: Get Orderbook
Get Recent Trades
Get recent trades.
Reference
- Sync Code Reference: Client.get_recent_trades
- Async Code Reference: AsyncClient.get_recent_trades
- API Documentation Reference: Get Recent Trades
Get User Orders
Get user orders.
Warning
1000/hour.
Reference
- Sync Code Reference: Client.get_user_orders
- Async Code Reference: AsyncClient.get_user_orders
- API Documentation Reference: Get User Orders
Create Order
Create New Order.
Warning
1000/hour.
Reference
- Sync Code Reference: Client.create_order
- Async Code Reference: AsyncClient.create_order
- API Documentation Reference: Create Order
create_order.py | |
---|---|
create_order_async.py | |
---|---|
Cancel Order
Cancel Order.
Warning
1000/hour.
Reference
- Sync Code Reference: Client.cancel_order
- Async Code Reference: AsyncClient.cancel_order
- API Documentation Reference: Cancel Order
output | |
---|---|
Get User Recent Trades
Get user recent trades.
Warning
1000/hour.
Reference
- Sync Code Reference: Client.get_user_trades
- Async Code Reference: AsyncClient.get_user_trades
- API Documentation Reference: Get User Recent Trades