Skip to content

Commit dd82baf

Browse files
authored
feat(deposit-api): add deposit api (#11)
* feat(deposit-api): add get deposits api * feat(deposit-api): add get deposit api * feat(deposit-api): add post deposit coin address api * feat(deposit-api): get deposit coin addresses api * feat(deposit-api): get deposit coin address api * feat(deposit-api): post deposit krw api * docs(readme): modify typo
1 parent c45540f commit dd82baf

23 files changed

+425
-7
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,24 @@ wrapper for upbit API
7575
- [postWithdrawsKrw](/docs/exchange-api/withdraw/post-withdraws-krw.md)
7676
- Request an Withdraw Krw
7777
- Deposit
78-
- [ ] `GET /v1/deposits`
79-
- [ ] `GET /v1/deposit`
80-
- [ ] `POST /v1/deposit/generate_coin_address`
81-
- [ ] `GET /v1/deposits/coin_addresses`
82-
- [ ] `GET /v1/deposits/coin_address`
83-
- [ ] `GET /v1/deposits/krw`
78+
- [x] `GET /v1/deposits`
79+
- [getDeposits](/docs/exchange-api/deposit/get-deposits.md)
80+
- Deposits List
81+
- [x] `GET /v1/deposit`
82+
- [getDeposit](/docs/exchange-api/deposit/get-deposit.md)
83+
- Deposit Detail
84+
- [x] `POST /v1/deposit/generate_coin_address`
85+
- [postDepositCoinAddress](/docs/exchange-api/deposit/post-deposit-coin-address.md)
86+
- Request an Deposit Address
87+
- [x] `GET /v1/deposits/coin_addresses`
88+
- [getDepositCoinAddresses](/docs/exchange-api/deposit/get-deposit-coin-addresses.md)
89+
- Show The List of Assets You Have.
90+
- [x] `GET /v1/deposits/coin_address`
91+
- [getDepositCoinAddress](/docs/exchange-api/deposit/get-deposit-coin-address.md)
92+
- Show The Detail of Assets You Have.
93+
- [x] `POST /v1/deposits/krw`
94+
- [postDepositKrw](/docs/exchange-api/deposit/post-deposit-krw.md)
95+
- Request a Deposit of KRW.
8496
- Quotation API
8597
- Coin List
8698
- [ ] `GET /v1/market/all`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
### Example
2+
```typescript
3+
4+
const param = {
5+
/** required */
6+
/** Crypto Currency Code */
7+
currenecy: 'XRP',
8+
};
9+
10+
// ES6
11+
import ApiUpbit from 'node-upbit-api';
12+
13+
const res = await new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddress(param);
14+
console.log(res);
15+
16+
// ES5
17+
var ApiUpbit = required('node-upbit-api');
18+
19+
new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddress(param).then(res => console.log(res));
20+
21+
// console.log(res)
22+
{
23+
/** Crypto Currency Code */
24+
currency: 'XRP',
25+
/** Deposit Address */
26+
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
27+
/** Secondary Deposit Address nullable Field */
28+
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
29+
}
30+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### Example
2+
```typescript
3+
4+
// ES6
5+
import ApiUpbit from 'node-upbit-api';
6+
7+
const res = await new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddresses();
8+
console.log(res);
9+
10+
// ES5
11+
var ApiUpbit = required('node-upbit-api');
12+
13+
new ApiUpbit('accessKey', 'secretKey').getDepositCoinAddresses().then(res => console.log(res));
14+
15+
// console.log(res)
16+
[
17+
{
18+
/** Crypto Currency Code */
19+
currency: 'XRP',
20+
/** Deposit Address */
21+
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
22+
/** Secondary Deposit Address nullable Field */
23+
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
24+
}
25+
]
26+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
### Example
2+
```typescript
3+
4+
/** Either (uuid, txid) value must be included. */
5+
const param = {
6+
/** required */
7+
/** Crypto Currency Code */
8+
currenecy: 'XRP',
9+
/** optional */
10+
/** Deposit Unique ID */
11+
uuids: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
12+
/** optional */
13+
/** Deposit TX ID */
14+
txids: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc',
15+
};
16+
17+
// ES6
18+
import ApiUpbit from 'node-upbit-api';
19+
20+
const res = await new ApiUpbit('accessKey', 'secretKey').getDepoit(param);
21+
console.log(res);
22+
23+
// ES5
24+
var ApiUpbit = required('node-upbit-api');
25+
26+
new ApiUpbit('accessKey', 'secretKey').getDepoit(param).then(res => console.log(res));
27+
28+
// console.log(res)
29+
{
30+
/** Deposit And Withdrawal Type */
31+
type: 'deposit',
32+
/** Deposit Unique ID */
33+
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
34+
/** Crypto Currenecy Code */
35+
currency: 'XRP';
36+
/** Deposit TX ID */
37+
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
38+
/** Deposital Status */
39+
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
40+
/** Create Datetime */
41+
created_at: '2019-02-28T15:17:51+09:00';
42+
/** Done Datetime */
43+
done_at: '2019-02-28T15:22:12+09:00';
44+
/** Deposit Price/Count */
45+
amount: '1.0';
46+
/** Deposit Fee */
47+
fee: '0.0';
48+
/** Deposit Type */
49+
transaction_type: 'default' | 'internal';
50+
}
51+
```
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
### Example
2+
```typescript
3+
4+
const param = {
5+
/** required */
6+
/** Crypto Currency Code */
7+
currenecy: 'XRP';
8+
/** required */
9+
/** Deposit Status */
10+
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
11+
/** required */
12+
/** Deposit Unique ID */
13+
uuids: [];
14+
/** required */
15+
/** Deposit TX ID */
16+
txids: [];
17+
/** optional */
18+
/** Default 100, Max 100 */
19+
limit: 100;
20+
/** optional */
21+
/** Default 1 */
22+
page: 1;
23+
/** optional */
24+
/** Default 'desc' */
25+
order_by: 'desc' | 'asc';
26+
};
27+
28+
// ES6
29+
import ApiUpbit from 'node-upbit-api';
30+
31+
const res = await new ApiUpbit('accessKey', 'secretKey').getDeposits(param);
32+
console.log(res);
33+
34+
// ES5
35+
var ApiUpbit = required('node-upbit-api');
36+
37+
new ApiUpbit('accessKey', 'secretKey').getDeposits(param).then(res => console.log(res));
38+
39+
// console.log(res)
40+
[
41+
{
42+
/** Deposit And Withdrawal Type */
43+
type: 'deposits',
44+
/** Deposit Unique ID */
45+
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
46+
/** Crypto Currenecy Code */
47+
currency: 'XRP';
48+
/** Deposit TX ID */
49+
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
50+
/** Deposit Status */
51+
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
52+
/** Create Datetime */
53+
created_at: '2019-02-28T15:17:51+09:00';
54+
/** Done Datetime */
55+
done_at: '2019-02-28T15:22:12+09:00';
56+
/** Deposit Price/Count */
57+
amount: '1.0';
58+
/** Deposit Fee */
59+
fee: '0.0';
60+
/** Deposit Type */
61+
transaction_type: 'default' | 'internal';
62+
}
63+
]
64+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### Example
2+
```typescript
3+
4+
const param = {
5+
/** required */
6+
/** Crypto Currency Code */
7+
currenecy: 'XRP',
8+
};
9+
10+
// ES6
11+
import ApiUpbit from 'node-upbit-api';
12+
13+
const res = await new ApiUpbit('accessKey', 'secretKey').postDepositCoinAddress(param);
14+
console.log(res);
15+
16+
// ES5
17+
var ApiUpbit = required('node-upbit-api');
18+
19+
new ApiUpbit('accessKey', 'secretKey').postDepositCoinAddress(param).then(res => console.log(res));
20+
21+
/**
22+
* The creation of deposit addresses is asynchronous on the server.
23+
* 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.
24+
*/
25+
26+
// console.log(res)
27+
// Before Issued
28+
{
29+
/** Whether success Request */
30+
success: true,
31+
/** Message about the result of the request. */
32+
message: 'XRP 입금 주소를 생성중입니다.',
33+
}
34+
35+
// console.log(res)
36+
// After Issued
37+
{
38+
/** Crypto Currency Code */
39+
currency: 'XRP',
40+
/** Deposit Address */
41+
deposit_address: '152rff1-d2v14v2rcxd-cd21vqdc1-2dsab',
42+
/** Secondary Deposit Address nullable Field */
43+
secondary_addres: '2rcf1dv2-vd2c2d1dvf-2rcf21wdx-vdw1cdxw',
44+
}
45+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
### Example
2+
```typescript
3+
4+
const param = {
5+
/** required */
6+
/** Deposit amount */
7+
amount: 10000,
8+
};
9+
10+
// ES6
11+
import ApiUpbit from 'node-upbit-api';
12+
13+
const res = await new ApiUpbit('accessKey', 'secretKey').postDepositKrw(param);
14+
console.log(res);
15+
16+
// ES5
17+
var ApiUpbit = required('node-upbit-api');
18+
19+
new ApiUpbit('accessKey', 'secretKey').postDepositKrw(param).then(res => console.log(res));
20+
21+
// console.log(res)
22+
{
23+
/** Deposit And Withdrawal Type */
24+
type: 'deposit',
25+
/** Deposit Unique ID */
26+
uuid: '35a4f1dc-1db5-4d6b-89b5-7ec137875956',
27+
/** Currenecy Code */
28+
currency: 'KRW';
29+
/** Deposit TX ID */
30+
txid: '98c15999f0bdc4ae0e8a-ed35868bb0c204fe6ec29e4058a3451e-88636d1040f4baddf943274ce37cf9cc';
31+
/** Deposital Status */
32+
state: 'submitting' | 'submitted' | 'almost_accepted' | 'rejected' | 'accepted' | 'processing' | 'done' | 'canceled',
33+
/** Create Datetime */
34+
created_at: '2019-02-28T15:17:51+09:00';
35+
/** Done Datetime */
36+
done_at: '2019-02-28T15:22:12+09:00';
37+
/** Deposit Price/Count */
38+
amount: '10000';
39+
/** Deposit Fee */
40+
fee: '0.0';
41+
/** Deposit Type */
42+
transaction_type: 'default' | 'internal';
43+
}
44+
```

src/index.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import {
66
CancelOrderRequestQuery,
77
CancelOrderResponse,
88
GetAccountsResponse,
9+
GetDepositCoinAddreesRequstQuery,
10+
GetDepositCoinAddressResponse,
11+
GetDepositCoinAddressesResponse,
12+
GetDepositRequstQuery,
13+
GetDepositResponse,
14+
GetDepositsRequestQuery,
15+
GetDepositsResponse,
916
GetOrderRequestQuery,
1017
GetOrderResponse,
1118
GetOrdersChanceRequestQuery,
@@ -19,6 +26,10 @@ import {
1926
GetWithdrawsRequestQuery,
2027
GetWithdrawsResponse,
2128
JwtPaylaod,
29+
PostDepositCoinAddressResponse,
30+
PostDepositKrwRequestBody,
31+
PostDepositKrwResponse,
32+
PostDepositsCoinAddressRequestBody,
2233
PostOrdersRequestQuery,
2334
PostOrdersResponse,
2435
PostWithdrawsCoinRequestBody,
@@ -192,6 +203,77 @@ export default class ApiUpbit {
192203
);
193204
}
194205

206+
/**
207+
* Deposits List
208+
* `GET /v1/deposits`
209+
* 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
210+
*/
211+
public async getDeposits(
212+
query: GetDepositsRequestQuery,
213+
): Promise<GetDepositsResponse> {
214+
return this.requestApi<GetDepositsResponse>('GET', '/v1/deposits', query);
215+
}
216+
217+
/**
218+
* Deposit Detail
219+
* `GET /v1/deposit`
220+
* https://docs.upbit.com/reference/%EA%B0%9C%EB%B3%84-%EC%9E%85%EA%B8%88-%EC%A1%B0%ED%9A%8C
221+
*/
222+
public async getDeposit(
223+
query: GetDepositRequstQuery,
224+
): Promise<GetDepositResponse> {
225+
return this.requestApi<GetDepositResponse>('GET', '/v1/deposit', query);
226+
}
227+
228+
/**
229+
* Request an Deposit Address
230+
* The creation of deposit addresses is asynchronous on the server.
231+
* 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.
232+
*/
233+
public async postDepositCoinAddress(
234+
body: PostDepositsCoinAddressRequestBody,
235+
): Promise<PostDepositCoinAddressResponse> {
236+
return this.requestApi<PostDepositCoinAddressResponse>(
237+
'POST',
238+
'/v1/deposits/generate_coin_address',
239+
body,
240+
);
241+
}
242+
243+
/**
244+
* Shows the List of Assets You Have.
245+
*/
246+
public async getDepositCoinAddresses(): Promise<GetDepositCoinAddressesResponse> {
247+
return this.requestApi<GetDepositCoinAddressesResponse>(
248+
'GET',
249+
'/v1/deposits/coin_addresses',
250+
);
251+
}
252+
253+
/**
254+
* Show The Detail of Assets You Have.
255+
*/
256+
public async getDepositCoinAddress(query: GetDepositCoinAddreesRequstQuery) {
257+
return this.requestApi<GetDepositCoinAddressResponse>(
258+
'GET',
259+
'/v1/deposits/coin_address',
260+
query,
261+
);
262+
}
263+
264+
/**
265+
* Request a Deposit of KRW.
266+
*/
267+
public async postDepositKrw(
268+
body: PostDepositKrwRequestBody,
269+
): Promise<PostDepositKrwResponse> {
270+
return this.requestApi<PostDepositKrwResponse>(
271+
'POST',
272+
'/v1/deposits/krw',
273+
body,
274+
);
275+
}
276+
195277
/**
196278
* Return Request JWT TOKEN
197279
*/

0 commit comments

Comments
 (0)