Skip to content

Commit 29d3274

Browse files
committed
feat(candlestick api): add public api
1 parent ca9e212 commit 29d3274

6 files changed

Lines changed: 59 additions & 1 deletion

src/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import {
3030
IPostWithDrawalKrw,
3131
IBalanceResponse,
3232
IBithumbErrorResponse,
33+
Time,
34+
IGetCandlestick,
35+
IGetCandlestickData,
3336
} from './types';
3437

3538
export default class ApiBithumb {
@@ -96,6 +99,31 @@ export default class ApiBithumb {
9699
return res;
97100
}
98101

102+
/**
103+
* provides a Candlestick data.
104+
* https://apidocs.bithumb.com/docs/candlestick
105+
*/
106+
public async GetCandlestick(
107+
orderCurrency: string,
108+
paymentCurrency: string,
109+
chartIntervals: Time,
110+
): Promise<IGetCandlestickData[]> {
111+
const endpoint = `/candlestick/${orderCurrency}_${paymentCurrency}`;
112+
const res = <IGetCandlestick> await this.requestPublic(endpoint, chartIntervals);
113+
114+
const candleData: IGetCandlestickData[] = res.data.map((candle) => ({
115+
timestamp: candle[0],
116+
opening_price: candle[1],
117+
closing_price: candle[2],
118+
max_price: candle[3],
119+
min_price: candle[4],
120+
volume: candle[5],
121+
}));
122+
123+
return candleData;
124+
}
125+
126+
99127
/**
100128
* Provide information on membership and coin transaction fees.
101129
* https://apidocs.bithumb.com/docs/account
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface IGetCandlestickData {
2+
timestamp: number;
3+
opening_price: string;
4+
closing_price: string;
5+
max_price: string;
6+
min_price: string;
7+
volume: string;
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type Time =
2+
| '1m'
3+
| '3m'
4+
| '5m'
5+
| '10m'
6+
| '30m'
7+
| '1h'
8+
| '6h'
9+
| '12h'
10+
| '24h';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { IBithumbResponse } from './bithumb-response.interface';
2+
3+
export interface IGetCandlestick extends IBithumbResponse {
4+
5+
/** [timestamp, opening amount, closing amount, max price, min price, volume] */
6+
data: [number, string, string, string, string, string][];
7+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export type getEndpointType = 'ticker' | 'orderbook' | 'transaction_history' | 'assetsstatus' | 'btci';
1+
type Candlestick = string;
2+
3+
export type getEndpointType = 'ticker' | 'orderbook' | 'transaction_history' | 'assetsstatus' | 'btci' | Candlestick;

src/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export * from './market-sell.interface';
2121
export * from './withdrawal-coin.interface';
2222
export * from './withdrawal-krw.interface';
2323
export * from './bithumb-error-response.interface';
24+
export * from './get-candlestick.interface';
25+
export * from './get-candlestick-data.interface';
2426

2527
// type
2628
export * from './currency-i18n.interface';
2729
export * from './get-endpoint.interface';
2830
export * from './post-endpoint.interface';
2931
export * from './trade-type.interface';
32+
export * from './get-candlestick-time.interface';

0 commit comments

Comments
 (0)