Public API

A python class to send the public APIs.

The private API is a class to send API requests without authorization, e.g. get the price of some symbol in Binance spot market and etc.

It is initialized prior to your code as a variable named publicAPI.

Currently, the public API is available for terminal only for now. We will support this in analytics/python mode too in the future.

...

import PublicAPI

# `publicAPI` object is automatically initialized
# before running your code.
publicAPI = PublicAPI()

# your python code is placed here
# In your code, you can send public API requests like below:
## publicAPI.recent_price('binance', 'ETHUSDT')


Common Functions

The common functions are the methods of the public API, available for (almost) any exchanges we support. By using these functions, you can easily switch the exchanges you want to send API request to.

Every common function has its first argument as an exchange. It specifies which exchange should the request be sent to. For example, you can get the up-to-date price of BTCUSDT in Binance spot by publicAPI.recent_price('binance', 'BTCUSDT'), while publicAPI.recent_price('binance_um_futures', 'BTCUSDT') returns the price of BTCUSDT perpetual in Binance USDⓈ-M futures.

For now, the available exchanges are,

  • binance : Binance Spot

  • binance_um_futures : Binance USDⓈ-M Futures

  • binance_cm_futures : Binance COIN-M Futures

1. Get Current Price

publicAPI.recent_price(exchange :str, symbol: str) -> float

It is a function to get to the up-to-date price of a symbol in the selected exchange.

Arguments

  • exchange : (string). The name of the exchange

  • symbol : (string) The name of the symbol.

Returns

float


Last updated

Copyright © 2023, UnBlinked Co., Ltd. | All rights reserved.