Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deposit-api): add deposit api #11

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,24 @@ wrapper for upbit API
- [postWithdrawsKrw](/docs/exchange-api/withdraw/post-withdraws-krw.md)
- Request an Withdraw Krw
- Deposit
- [ ] `GET /v1/deposits`
- [ ] `GET /v1/deposit`
- [ ] `POST /v1/deposit/generate_coin_address`
- [ ] `GET /v1/deposits/coin_addresses`
- [ ] `GET /v1/deposits/coin_address`
- [ ] `GET /v1/deposits/krw`
- [x] `GET /v1/deposits`
- [getDeposits](/docs/exchange-api/deposit/get-deposits.md)
- Deposits List
- [x] `GET /v1/deposit`
- [getDeposit](/docs/exchange-api/deposit/get-deposit.md)
- Deposit Detail
- [x] `POST /v1/deposit/generate_coin_address`
- [postDepositCoinAddress](/docs/exchange-api/deposit/post-deposit-coin-address.md)
- Request an Deposit Address
- [x] `GET /v1/deposits/coin_addresses`
- [getDepositCoinAddresses](/docs/exchange-api/deposit/get-deposit-coin-addresses.md)
- Show The List of Assets You Have.
- [x] `GET /v1/deposits/coin_address`
- [getDepositCoinAddress](/docs/exchange-api/deposit/get-deposit-coin-address.md)
- Show The Detail of Assets You Have.
- [x] `POST /v1/deposits/krw`
- [postDepositKrw](/docs/exchange-api/deposit/post-deposit-krw.md)
- Request a Deposit of KRW.
- Quotation API
- Coin List
- [ ] `GET /v1/market/all`
Expand Down
30 changes: 30 additions & 0 deletions docs/exchange-api/deposit/get-deposit-coin-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Example
```typescript

const param = {
/** required */
/** Crypto Currency Code */
currenecy: 'XRP',
};

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddress(param);
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddress(param).then(res => console.log(res));

// console.log(res)
{
/** Crypto Currency Code */
currency: 'XRP',
/** Deposit Address */
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
/** Secondary Deposit Address nullable Field */
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
}
```
26 changes: 26 additions & 0 deletions docs/exchange-api/deposit/get-deposit-coin-addresses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### Example
```typescript

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddresses();
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddresses().then(res => console.log(res));

// console.log(res)
[
{
/** Crypto Currency Code */
currency: 'XRP',
/** Deposit Address */
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
/** Secondary Deposit Address nullable Field */
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
}
]
```
51 changes: 51 additions & 0 deletions docs/exchange-api/deposit/get-deposit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Example
```typescript

/** Either (uuid, txid) value must be included. */
const param = {
/** required */
/** Crypto Currency Code */
currenecy: 'XRP',
/** optional */
/** Deposit Unique ID */
uuids: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
/** optional */
/** Deposit TX ID */
txids: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc',
};

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').getDepoit(param);
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').getDepoit(param).then(res => console.log(res));

// console.log(res)
{
/** Deposit And Withdrawal Type */
type: 'deposit',
/** Deposit Unique ID */
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
/** Crypto Currenecy Code */
currency: 'XRP';
/** Deposit TX ID */
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
/** Deposital Status */
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
/** Create Datetime */
created_at: '2019-02-28T15:17:51+09:00';
/** Done Datetime */
done_at: '2019-02-28T15:22:12+09:00';
/** Deposit Price/Count */
amount: '1.0';
/** Deposit Fee */
fee: '0.0';
/** Deposit Type */
transaction_type: 'default' | 'internal';
}
```
64 changes: 64 additions & 0 deletions docs/exchange-api/deposit/get-deposits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
### Example
```typescript

const param = {
/** required */
/** Crypto Currency Code */
currenecy: 'XRP';
/** required */
/** Deposit Status */
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
/** required */
/** Deposit Unique ID */
uuids: [];
/** required */
/** Deposit TX ID */
txids: [];
/** optional */
/** Default 100, Max 100 */
limit: 100;
/** optional */
/** Default 1 */
page: 1;
/** optional */
/** Default 'desc' */
order_by: 'desc' | 'asc';
};

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').getDeposits(param);
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').getDeposits(param).then(res => console.log(res));

// console.log(res)
[
{
/** Deposit And Withdrawal Type */
type: 'deposits',
/** Deposit Unique ID */
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
/** Crypto Currenecy Code */
currency: 'XRP';
/** Deposit TX ID */
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
/** Deposit Status */
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
/** Create Datetime */
created_at: '2019-02-28T15:17:51+09:00';
/** Done Datetime */
done_at: '2019-02-28T15:22:12+09:00';
/** Deposit Price/Count */
amount: '1.0';
/** Deposit Fee */
fee: '0.0';
/** Deposit Type */
transaction_type: 'default' | 'internal';
}
]
```
45 changes: 45 additions & 0 deletions docs/exchange-api/deposit/post-deposit-coin-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### Example
```typescript

const param = {
/** required */
/** Crypto Currency Code */
currenecy: 'XRP',
};

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').postDepositCoinAddress(param);
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').postDepositCoinAddress(param).then(res => console.log(res));

/**
* The creation of deposit addresses is asynchronous on the server.
* When requesting to issue an address, <PostDepositsCoinAddressPendingResponse> will be returned as a result, and <PostDepositsCoinAddressPendingResponse> will continue to be returned until the address issuance is completed.
*/

// console.log(res)
// Before Issued
{
/** Whether success Request */
success: true,
/** Message about the result of the request. */
message: 'XRP 입금 주소를 생성중입니다.',
}

// console.log(res)
// After Issued
{
/** Crypto Currency Code */
currency: 'XRP',
/** Deposit Address */
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
/** Secondary Deposit Address nullable Field */
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
}
```
44 changes: 44 additions & 0 deletions docs/exchange-api/deposit/post-deposit-krw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Example
```typescript

const param = {
/** required */
/** Deposit amount */
amount: 10000,
};

// ES6
import ApiUpbit from 'node-upbit-api';

const res = await new ApiUpbit('accessKey', 'secretKey').postDepositKrw(param);
console.log(res);

// ES5
var ApiUpbit = required('node-upbit-api');

new ApiUpbit('accessKey', 'secretKey').postDepositKrw(param).then(res => console.log(res));

// console.log(res)
{
/** Deposit And Withdrawal Type */
type: 'deposit',
/** Deposit Unique ID */
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
/** Currenecy Code */
currency: 'KRW';
/** Deposit TX ID */
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
/** Deposital Status */
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
/** Create Datetime */
created_at: '2019-02-28T15:17:51+09:00';
/** Done Datetime */
done_at: '2019-02-28T15:22:12+09:00';
/** Deposit Price/Count */
amount: '10000';
/** Deposit Fee */
fee: '0.0';
/** Deposit Type */
transaction_type: 'default' | 'internal';
}
```
82 changes: 82 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import {
CancelOrderRequestQuery,
CancelOrderResponse,
GetAccountsResponse,
GetDepositCoinAddreesRequstQuery,
GetDepositCoinAddressResponse,
GetDepositCoinAddressesResponse,
GetDepositRequstQuery,
GetDepositResponse,
GetDepositsRequestQuery,
GetDepositsResponse,
GetOrderRequestQuery,
GetOrderResponse,
GetOrdersChanceRequestQuery,
Expand All @@ -19,6 +26,10 @@ import {
GetWithdrawsRequestQuery,
GetWithdrawsResponse,
JwtPaylaod,
PostDepositCoinAddressResponse,
PostDepositKrwRequestBody,
PostDepositKrwResponse,
PostDepositsCoinAddressRequestBody,
PostOrdersRequestQuery,
PostOrdersResponse,
PostWithdrawsCoinRequestBody,
Expand Down Expand Up @@ -192,6 +203,77 @@ export default class ApiUpbit {
);
}

/**
* Deposits List
* `GET /v1/deposits`
* https://docs.upbit.com/reference/%EC%9E%85%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
*/
public async getDeposits(
query: GetDepositsRequestQuery,
): Promise<GetDepositsResponse> {
return this.requestApi<GetDepositsResponse>('GET', '/v1/deposits', query);
}

/**
* Deposit Detail
* `GET /v1/deposit`
* https://docs.upbit.com/reference/%EA%B0%9C%EB%B3%84-%EC%9E%85%EA%B8%88-%EC%A1%B0%ED%9A%8C
*/
public async getDeposit(
query: GetDepositRequstQuery,
): Promise<GetDepositResponse> {
return this.requestApi<GetDepositResponse>('GET', '/v1/deposit', query);
}

/**
* Request an Deposit Address
* The creation of deposit addresses is asynchronous on the server.
* When requesting to issue an address, <PostDepositsCoinAddressPendingResponse> will be returned as a result, and <PostDepositsCoinAddressPendingResponse> will continue to be returned until the address issuance is completed.
*/
public async postDepositCoinAddress(
body: PostDepositsCoinAddressRequestBody,
): Promise<PostDepositCoinAddressResponse> {
return this.requestApi<PostDepositCoinAddressResponse>(
'POST',
'/v1/deposits/generate_coin_address',
body,
);
}

/**
* Shows the List of Assets You Have.
*/
public async getDepositCoinAddresses(): Promise<GetDepositCoinAddressesResponse> {
return this.requestApi<GetDepositCoinAddressesResponse>(
'GET',
'/v1/deposits/coin_addresses',
);
}

/**
* Show The Detail of Assets You Have.
*/
public async getDepositCoinAddress(query: GetDepositCoinAddreesRequstQuery) {
return this.requestApi<GetDepositCoinAddressResponse>(
'GET',
'/v1/deposits/coin_address',
query,
);
}

/**
* Request a Deposit of KRW.
*/
public async postDepositKrw(
body: PostDepositKrwRequestBody,
): Promise<PostDepositKrwResponse> {
return this.requestApi<PostDepositKrwResponse>(
'POST',
'/v1/deposits/krw',
body,
);
}

/**
* Return Request JWT TOKEN
*/
Expand Down
Loading