kuna-sdk-origin2
v0.6.7
Published
This library is used to connect and trade with cryptocurrency exchange - [kuna.io](https://kuna.io)
Downloads
2
Readme
KUNA API SDK
This library is used to connect and trade with cryptocurrency exchange - kuna.io
Installation
You can install kuna-sdk-origin with NPM using:
npm install kuna-sdk-origin
Usage
import { Kuna } from 'kuna-sdk-origin';
const kuna = new Kuna({
apiUrl: 'https://api.kuna.io',
apiKey: 'YOUR_PUBLIC_API_KEY',
secretKey: 'YOUR_SECRET_PRIVATE_KEY',
});
CallPublicApi
Typescript
type Timestamp = {
timestamp: number;
timestamp_miliseconds: number;
};
const timestamp = kuna.callPublicApi<Timestamp>(
'/v3/timestamp',
);
Javascript
const timestamp = kuna.callPublicApi(
'/v3/timestamp',
{}
);
CallPrivateApi
Typescript import
type KunaCode = {
id: number;
sn: string;
code: string;
recipient: string | 'all';
amount: string;
currency: string;
status: string;
non_refundable_before: string | null;
created_at: string;
redeemed_at: string | null;
comment: string;
private_comment: string;
};
const code = 'ASD_SADSADD-UAH-KCode'
const kunaCode = kuna.callPrivateApi<KunaCode>(
'/v3/auth/kuna_codes/redeem',
{ code },
{
method: 'PUT',
},
);
Javascript
const code = 'ASD_SADSADD-UAH-KCode'
const kunaCode = kuna.callPrivateApi(
'/v3/auth/kuna_codes/redeem',
{ code },
{
method: 'PUT',
},
);
Order Methods (Not fully documented but wrote on typescript, just see type)
Creating
import { OrderType } from 'kuna-sdk-origin';
const data = await kuna.order.create({
symbol: 'xrpuah',
type: OrderType.LIMIT,
amount: 0.01,
price: 0.01,
});
Get order details
const id = 111111;
const orderDetail = await kuna.order.details({ id });
Withdraw methods
Creating
import { CreateWithdrawInputDto } from 'kuna-sdk-origin';
const withdrawCryptoParams: CreateWithdrawInputDto = {
withdrawType: 'eth',
address: 'ADDRESS_HERE',
amount: 0.01,
};
const withdrawFiatParams: CreateWithdrawInputDto = {
withdrawType: 'uah',
amount: 250,
gateway: 'payment_card_uah',
fields: {
cardNumber: '5111111111111111',
},
};
// create crypto withdraw
const dataC = await kuna.withdraw.create(withdrawCryptoParams);
// create fiat withdraw
const dataF = await kuna.withdraw.create(withdrawFiatParams);
Get withdraw details
const id = 111111;
const data = await kuna.withdraw.details({
id
});
Get withdraw fee
const currency = 'eth';
const data = await kuna.withdraw.fee({
currency,
});
Deposit methods
Create fiat deposit
import { CreateFiatDepositInput } from 'kuna-sdk-origin';
const deposit: CreateFiatDepositInput = {
createInvoice: true,
currency: 'uah',
amount: 100,
paymentService: 'default',
};
const data = await kuna.deposit.createFiat(deposit);
Orderbook
const market = 'btcuah';
const data = await kuna.orderBook.get({
market
});