BTCTurk API REFERENCE¶
btcturk_api.client module¶
-
class
btcturk_api.client.
Client
(api_key: Optional[str] = None, api_secret: Optional[str] = None)¶ Bases:
object
API Client Class
Methods
get_exchange_info:
Method for getting exchange info of any given pair
get_server_time:
Gets Current Server Time
tick:
Gets price related information of any given pair
get_ohlc_data:
Gets daily OHLC data for given pair
get_order_book:
Gets the order book of given pair
get_trades:
Gets a list of Trades for given pair
get_account_balance:
Gets the list of balances which user have
get_trade_history:
Gets the history of user’s trades.
get_crypto_history:
Gets the history of user’s crypto transactions.
get_fiat_history:
Gets the history of user’s fiat transactions.
get_open_orders:
Get’s list of user’s open orders for given pair
get_all_orders:
Get’s users all orders for given pair
cancel_order:
Deletes The Order
submit_market_order:
Submits an order in type of ‘market order’
submit_limit_order:
Submits an order in type of ‘limit order’
submit_stop_order:
Submits an order in type of ‘stop order’
-
API_BASE
= 'https://api.btcturk.com'¶
-
API_ENDPOINT_AUTH
= '/api/v1/'¶
-
API_ENDPOINT_NON_AUTH
= '/api/v2/'¶
-
API_ENDPOINT_TRANSACTIONS
= '/api/v1/users/transactions/'¶
-
cancel_order
(order_id=None)¶ Deletes The Order
- Parameters
- order_idint, mandatory
- Returns
- bool
Success value if there is no exception raised by handler
-
get_account_balance
(assets=None)¶ Gets the list of balances which user have
- Parameters
- assets: optional
List of assets like [‘BTC’, ‘TRY’, …]
- Returns
- list
Example of Response Format
[ { 'asset': 'EUR', 'assetname': 'Euro', 'balance': '0', 'locked': '0', 'free': '0', 'orderFund': '0', 'requestFund': '0', 'precision': 2 }, ... ]
-
get_all_orders
(order_id: int = 0, pair_symbol=None, start_date=None, end_date=None, page=None, limit=100, **kwargs)¶ Get’s users all orders for given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query.
Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
If start_date not specified, it will get orders for last 30 days.
- Parameters
- order_id: int, optional
If orderId set, it will return all orders greater than or equals to this order id
- pair_symbol: str, mandatory
Like BTC_TRY, XRP_USDT..
- start_date: int, optional
start date as timestamp in milliseconds
- end_date: int, optional
end date as timestamp in milliseconds
- page: int, optional
page number
- limit: int, optional
limit number
- kwargs
- Returns
- list
List of data dictionaries
Example Of Response Format
[ { 'id': '<Order id>', 'price': '<Price of the order>', 'amount': '<Amount of the order>', 'quantity': '<Quantity of the order>', 'pairsymbol': '<Pair of the order>', 'pairSymbolNormalized': '<Pair of the order with "_" in between>', 'type': '<Type of order. Buy or Sell>', 'method': '<Method of order. Limit, Stop Limit..>', 'orderClientId': '<Order client id created with>', 'time': '<Unix time the order was inserted at>', 'updateTime': '<Unix time last updated>', 'status': '<Status of the order. Untouched, Partial..>', }, ... ]
-
get_crypto_history
(symbol=None, transaction_type=None, start_date=None, end_date=None, **kwargs)¶ Gets the history of user’s crypto transactions.
If symbol not specified, all crypto symbols will be used
If transaction_type not specified, both ‘withdrawal’ and ‘deposit’ types will be used
If start_date not specified, it will get trades for last 30 days.
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- symbollist, optional
[“btc”, “try”, …etc.]
- transaction_typelist , optional
[“deposit”, “withdrawal”], [“deposit”] or [“withdrawal”]
- start_datetimestamp, optional
- end_datetimestamp, optional
- kwargs
- Returns
- list
List of trade data dictionaries,
Example of Response Format
[ { 'balanceType': '<Type of transaction (deposit, withdrawal)>', 'currencySymbol': '<Transaction currency symbol>', 'id': '<Transaction id>', 'timestamp': '<Unix timestamp>', 'funds': '<Funds>', 'orderFund': '<Transaction Amount>', 'fee': '<Transaction fee>', 'tax': <Transaction tax> }, ... ]
-
get_exchange_info
(symbol_list=None)¶ Method for getting exchange info of any given pair
- Parameters
- symbol_listlist, optional
In format of [‘BTCUSDT’, ‘XRPUSDT’, ‘ETHTRY’ …]
- Returns
- list
If symbol_list is None, list of data dictionaries of all pairs. Otherwise, that list filtered down to given symbol list
Example of Response Format
[ { 'id': '', 'name': '', 'nameNormalized': '', 'status': '', 'numerator': '', 'denominator': '', 'numeratorScale': '', 'denominatorScale': '', 'hasFraction': '', 'filters': '' 'orderMethods': ['MARKET', 'LIMIT', 'STOP_MARKET', 'STOP_LIMIT'], # IMPORTANT 'displayFormat': '#,###', 'commissionFromNumerator': False, 'order': 999, 'priceRounding': False }, ... ]
-
get_fiat_history
(balance_types=None, currency_symbols=None, start_date=None, end_date=None, **kwargs)¶ Gets the history of user’s fiat transactions.
If balance_types not specified, both ‘withdrawal’ and ‘deposit’ types will be used
If currency_symbols not specified, all currency symbols will be used
If start_date not specified, it will get trades for last 30 days.
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- balance_typeslist, optional
[“buy”, “sell”]
- currency_symbolslist, optional
[“try”, …etc.]
- start_datetimestamp, optional
- end_datetimestamp, optional
- kwargs
- Returns
- list
List of trade data dictionaries,
Example of Response Format
[ { 'balanceType': '<Type of transaction (deposit, withdrawal)>', 'currencySymbol': '<Transaction currency symbol>', 'id': '<Transaction id>', 'timestamp': '<Unix timestamp>', 'funds': '<Funds>', 'orderFund': '<Transaction Amount>', 'fee': '<Transaction fee>', 'tax': <Transaction tax> }, ... ]
-
get_ohlc_data
(pair=None, last=10, **kwargs)¶ Gets daily OHLC data for given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- pairstr, optional
pair symbol like ‘BTC_TRY’, ‘ETH_BTC’, …
- lastint, optional
number of days
- kwargs
- Returns
- list
a list of data dictionary for given pair
Example of Response Format
[ { 'pairSymbol': '<Requested pair symbol>', 'pairSymbolNormalized': '<Requested pair symbol with "_" in between.>', 'time': '<Current Unix time in milliseconds>' 'open': '<Price of the opening trade on the time>', 'high': '<Highest trade price on the time>', 'low': '<Lowest trade price on the time>', 'close': '<Price of the closing trade on the time>', 'volume': '<Total volume on the time>', 'average': '<Average price on the time>', 'dailyChangeAmount': '<Amount of difference between Close and Open on the Date>', 'dailyChangePercentage': '<Percentage of difference between Close and Open on the Date>', }, ... ]
-
get_open_orders
(pair=None, **kwargs)¶ Get’s list of user’s open orders for given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- pairstr, optional
if not set returns all pairs open orders
- kwargs
- Returns
- dict
Data dictionary
Example of Response Format
{ 'id': '<Order id>', 'price': '<Price of the order>', 'amount': '<Quantity of the order>', 'pairsymbol': '<Pair of the order>', 'pairSymbolNormalized': '<Pair of the order with "_" in between.>', 'type': '<Type of order. Buy or Sell>', 'method': '<Method of order. Limit, Stop Limit..>', 'orderClientId': <Order client id created with>, 'time': '<Unix time the order was inserted at>', 'updateTime': '<Unix time last updated>', 'status': <Status of the order. Untouched, Partial> },
-
get_order_book
(pair=None, limit=100, **kwargs)¶ Gets the order book of given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- pairstr, mandatory
pair symbol like ‘BTC_TRY’, ‘ETH_BTC’, …
- limitint, optional
default 100 max 1000
- kwargs
- Returns
- dict
data dictionary
Example of Response Format
[ { 'timestamp': '<Current Unix time in milliseconds>', 'bids': '<Array of current open bids on the orderbook>', 'asks': '<Array of current open asks on the orderbook>', }, ... ]
-
get_server_time
()¶ Gets Current Server Time
- Returns
- dictionary
Example of Response Format
{ 'serverTime': '<Unix Timestamp as int>', 'serverTime2': '<Datetime string>', }
-
get_trade_history
(trade_type=None, symbol=None, start_date=None, end_date=None, **kwargs)¶ Gets the history of user’s trades.
If trade_type not specified, both ‘buy’ and ‘sell’ types will be used
If symbol not specified, all crypto symbols will be used
If start_date not specified, it will get trades for last 30 days.
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- trade_typelist, optional
[“buy”, “sell”], [“buy”] or [“sell”]
- symbollist -> str, optional
[“btc”, “try”, …etc.],
- start_datetimestamp, optional
- end_datetimestamp, optional
- kwargs
- Returns
- list
List of trade data dictionaries,
Example of Response Format
[ { 'price': '<Trade price>', 'numeratorSymbol': '<Trade pair numerator symbol>', 'denominatorSymbol': '<Trade pair denominator symbol>', 'orderType': '<Trade type (buy,sell)>', 'id': '<Trade id>', 'timestamp': '<Unix timestamp>', 'amount': '<Trade Amount (always negative if order type is sell)>', 'fee': '<Trade fee>', 'tax': '<Trade tax>' }, ... ]
-
get_trades
(pair=None, last=50, **kwargs)¶ Gets a list of Trades for given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- pairstr, mandatory
pair symbol like ‘BTC_TRY’, ‘ETH_BTC’..
- lastint, optional
default 50 max 1000
- Returns
- dict
Data dictionary
Example of Response Format
{ 'pair': '<Requested pair symbol>', 'pairNormalized': '<Request Pair symbol with "_" in between.>', 'numerator': '<Numerator currency for the requested pair>', 'denominator': '<Denominator currency for the requested pair>', 'date': '<Unix time of the trade in milliseconds>', 'tid': '<Trade ID>', 'price': '<Price of the trade>', 'amount': '<Amount of the trade>', },
-
submit_limit_order
(quantity=0.0, price=0.0, order_type=None, pair_symbol=None, new_order_client_id=None)¶ Submits an order in type of ‘limit order’
- Parameters
- quantityfloat, mandatory
Mandatory for market or limit orders.
- pricefloat, mandatory
Price field will be ignored for market orders.
- order_typestr, mandatory
‘buy’ or ‘sell’
- pair_symbolstr, mandatory
Like ‘BTC_TRY’, ‘XRP_USDT’..
- new_order_client_idstr, optional
- Returns
- dict
Dictionary of order information
Example of Response Format
{ 'id': '<order id>', 'datetime': '<timestamp>', 'type': '<Buy or sell>', 'method': '<method of order (limit,stop,market)>', 'price': '<price>', 'stopPrice': '<stop price>', 'quantity': '<quantity>', 'pairSymbol': '<pair symbol>', 'pairSymbolNormalized': '<normalized pair symbol>', 'newOrderClientId': '<guid>', },
- Raises
- ValueError
If wrong pair_symbol entered
-
submit_market_order
(quantity=0.0, order_type=None, pair_symbol=None, new_order_client_id=None)¶ Submits an order in type of ‘market order’
- Parameters
- quantityfloat, mandatory
Mandatory for market or limit orders.
- order_typestr, mandatory
‘buy’ or ‘sell’
- pair_symbolstr, mandatory
- new_order_client_idstr, optional
- Returns
- dict
Dictionary of order information
Example of Response Format
{ 'id': '<order id>', 'datetime': '<timestamp>', 'type': '<Buy or sell>', 'method': '<method of order (limit,stop,market)>', 'price': '<price>', 'stopPrice': '<stop price>', 'quantity': '<quantity>', 'pairSymbol': '<pair symbol>', 'pairSymbolNormalized': '<normalized pair symbol>', 'newOrderClientId': '<guid>', },
- Raises
- ValueError
If wrong pair_symbol entered or file cache for scales hasn’t been updated
-
submit_stop_order
(stop_price=0.0, quantity=0.0, price=0.0, order_type=None, order_method=None, pair_symbol=None, new_order_client_id=None)¶ Submits an order in type of ‘stop order’
- Parameters
- stop_price: float, mandatory
For stop orders
- quantityfloat, mandatory
Mandatory for market or limit orders.
- pricefloat, mandatory
Price field will be ignored for market orders.
- order_typestr, mandatory
‘buy’ or ‘sell’
- order_method: str, mandatory
Either ‘stopLimit’ or ‘stopMarket’
- pair_symbolstr, mandatory
- new_order_client_idstr, optional
- Returns
- dict
Dictionary of order information
Example of Response Format
{ 'id': '<order id>', 'datetime': '<timestamp>', 'type': '<Buy or sell>', 'method': '<method of order (limit,stop,market)>', 'price': '<price>', 'stopPrice': '<stop price>', 'quantity': '<quantity>', 'pairSymbol': '<pair symbol>', 'pairSymbolNormalized': '<normalized pair symbol>', 'newOrderClientId': '<guid>', },
- Raises
- ValueError
If wrong pair_symbol entered
-
tick
(pair=None, **kwargs)¶ Gets price related information of any given pair
If you specify kwargs, the other parameters will be overridden. Only keyword arguments you specified will be used to construct a query. Therefore, it is your choice to use kwargs.
But i strongly discourage you to use that for avoiding any invalid requests
- Parameters
- pairstr, optional
pair symbol like ‘BTC_TRY’, ‘ETH_BTC’, …
- kwargs
- Returns
- list
If pair is set, a list of data dictionary with given pair, (length=1) Otherwise, a list of data dictionaries of all pairs.
Example of Response Format
[ { 'pairSymbol': '<Requested pair symbol>', 'pairSymbolNormalized': '<Requested pair symbol with "_" in between.>', 'timestamp': '<Current Unix time in milliseconds>' 'last': '<Last price>', 'high': '<Highest trade price in last 24 hours>', 'low': '<Lowest trade price in last 24 hours>', 'bid': '<Highest current bid>', 'ask': '<Lowest current ask>', 'open': '<Price of the opening trade in last 24 hours>', 'volume': '<Total volume in last 24 hours>', 'average': '<Average Price in last 24 hours>', 'daily': '<Price change in last 24 hours>', 'dailyPercent': '<Price change percent in last 24 hours>', 'denominatorSymbol': '<Denominator currency symbol of the pair>', 'numeratorSymbol': '<Numerator currency symbol of the pair>', }, ... ]
-