How to call private endpoints
Practical guide on how to easily get started with Kuna Core private endpoints.
First of all, you need to decide whether to use a JWT token or an API key for authentication. We will help with these questions in the authentication guide.
Header settings with JWT token
Header | Value | Description |
---|---|---|
accept | application/json | The client expects response data as JSON. |
content-type | application/json | The client sends data as JSON in the request body. |
authorization | "Bearer ${JWT_token}" | Generated a JWT token via the "Login" endpoint. |
merchant_id | "YOUR_MERCHANT_ID" | You have gotten your merchant_id with your login and password.(only for the ”Login” endpoint.) |
Header settings with API key
Header | Value | Description |
---|---|---|
accept | application/json | The client expects response data as JSON. |
content-type | application/json | The client sends data as JSON in the request body. |
api-key | "YOU_API_KEY" | A single API keys string to authenticate. |
Example. Get subaccount balance
const url = BASE_URL;
const path = "/v2/balance";
const body = {
"assets": [
"BTC"
],
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5"
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
// Instead of "Authorization" you can use "Api-key":
// "Api-key": "YOUR_API_KEY"
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
import requests
url = BASE_URL
path = "/v2/balance"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
# Instead of "Authorization" you can use "Api-key":
# "Api-key": "YOUR_API_KEY"
}
body = {
"assets": [
"BTC"
],
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5"
};
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
Example. Crypto withdraw operation
const url = BASE_URL;
const path = "/v2/withdraw/crypto";
const body = {
"paymentMethodCode": "BTC",
"amount": "0.34",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
"externalId": "withdrawal-001",
"callbackUrl": "https://webhook.site/c5067c6d-c6a8-454f-8ebe-17459591b6dc"
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // Generated a JWT token via /v2/auth/login.
// Instead of "Authorization" you can use "Api-key":
// "Api-key": "YOUR_API_KEY"
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
import requests
url = BASE_URL
path = "/v2/withdraw/crypto"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
# Instead of "Authorization" you can use "Api-key":
# "Api-key": "YOUR_API_KEY"
}
body = {
"paymentMethodCode": "BTC",
"amount": "0.34",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
"externalId": "withdrawal-001",
"callbackUrl": "https://webhook.site/c5067c6d-c6a8-454f-8ebe-17459591b6dc"
};
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
Updated 11 months ago