# Public API

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`.

{% hint style="info" %}
&#x20;Currently, the public API is available for **terminal only** for now. We will support this in **analytics/python** mode too in the future.&#x20;
{% endhint %}

```python
...

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

{% code overflow="wrap" %}

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

{% endcode %}

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

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.unblinked.com/library/python-library/public-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
