How to call public endpoints
Practical guide into an easy start with Kuna's public endpoints
All public endpoints do not need authorization and body parameters to be sent. The headers config is pretty simple.
Header settings for public endpoints
The following headers config should work for any public endpoint:
Header | Value | Description |
---|---|---|
accept | application/json | The client expects response data as JSON. |
Example. Get all trading pairs
No auth, no parameters, no body required for this request.
const url = "https://api.kuna.io";
const path = "/v4/markets/public/getAll";
const options = {
headers: {
accept: "application/json",
},
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
import requests
url = "https://api.kuna.io"
path = "/v4/markets/public/getAll"
headers = {
"accept": "application/json",
}
request = requests.get(url + path, headers=headers)
print(request.json())
Example. Get public order book for BTC_USDT
No auth and body required. We need to provide two parameters, though,- trading pair (1) and level (2).
const url = "https://api.kuna.io";
const path = "/v4/order/public/book/BTC_USDT?level=5";
const options = {
headers: {
accept: "application/json",
},
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
import requests
url = "https://api.kuna.io"
path = "/v4/order/public/book/BTC_USDT?level=5"
headers = {
"accept": "application/json",
}
request = requests.get(url + path, headers=headers)
print(request.json())
Updated over 1 year ago