Call private endpoints

Practical guide on how to start calling Kuna's private endpoints

Call private endpoint

First of all, please generate API keys, so you may start calling private endpoints.

For the start, we recommend using the single API key.
This option is better for rapid exploration.
You may find out more in the Authorizing requests section.

After the exploration is completed, we highly recommend using signed requests option.

Header settings if a single API key is used

HeaderValueDescription
acceptapplication/jsonThe client expects response data as JSON
content-typeapplication/jsonThe client sends data as JSON in the request body
api-key{{SINGLE_API_KEY}}A single API keys string to authenticate

Header settings if public + private keys are used

HeaderValueDescription
acceptapplication/jsonThe client expects response data as JSON
content-typeapplication/jsonThe client sends data as JSON in the request body
kun-nonce{{KUNA_NONCE}}TBD {{baseURL}}/v4/private/getNonce
kun-apikey{{API_PUBLIC_KEY}}Public key string to authenticate
kun-signature{{API_SIGNATURE}}Unique signature for your request. Check authorization section for more info.
GET: URL + nonce hashed using your private key
POST URL + nonce + BODY-JSON hashed using your private key

Example. Get account balance

Please open preferred API client, select GET method and call {{baseURL}}/v4/private/getBalance endpoint:

Alt text

While testing, lets use single api-key for authorization for private endpoints.
For this request we need no parameters, no body.

You should see something like this in your API client:

!!! Embed:
https://ttprivatenew.s3.amazonaws.com/pulse/dspro/attachments/20360831/TinyTake13-10-2022-05-26-59.mp4

Example. Get public order book

Let's check the market state before creating an order.
To do that, please, open preferred API client, select GET method and call {{baseURL}}/v4/order/public/book/DAY_NIGHT?level=5

📘

Kuna Exchange has special trading pair designed for testing. It's called DAY_NIGHT

This is a public endpoint, no need for authorization.
Let's set DAY_NIGHT for pair PATH parameter and 5 for level QUERY parameter.
No body required:

drawing drawing

As this is a live environment, it is hard to replicate the exact state of the response.
You should receive a JSON like this in the response:

{
    "asks": [
        [
            "124.275",
            "7.951"
        ],
        [
            "125.41",
            "9.01"
        ],
        [
            "125.45",
            "0.34"
        ]
    ],
    "bids": [
        [
            "123.275",
            "1"
        ],
        [
            "123.175",
            "1"
        ]
    ]
}

Let's assume we want to grab an opportunity, and to do that we will create an order next.

Example. Create order

To create a new order, please open preferred API client, select POST method and call {{baseURL}}/v4/order/private/create endpoint:
drawing drawing

Here we used single api-key for authorization, no parameters, and we send this JSON in the request body:

{
  "type": "Limit",
  "orderSide": "Bid",
  "pair": "DAY_NIGHT",
  "quantity": "1",
  "price": "124.275",
  "amount": "124.275"
}

If successful, the response should contain order UUID which we can use to further monitor related trades.
It is advisable to save it to a variable to use in testing endpoints that require order id as a parameter, like order details one.

Example. Review order info with related trades

After creating an order, we can review it's state alongside associated trades info.
To do that, please open preferred API client, select GET method and call {{baseURL}}/v4/order/private/details/:uuid?withTrades=true endpoint:

drawing drawing

Here we used single api-key for authorization, PATH parameter uuid, QUERY parameter withTrades, no body:

The response will contain the information of the order and its trades.

⚠️ It is advised to use websocket for receiving trade updates for your orders.
Please, use Setting up WebSocket API guide to start.