okx-api 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -173
- package/lib/constants/funding.d.ts +139 -0
- package/lib/constants/funding.js +143 -0
- package/lib/constants/funding.js.map +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +18 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +18 -13
- package/lib/index.js.map +1 -1
- package/lib/rest-client.d.ts +402 -0
- package/lib/rest-client.js +741 -0
- package/lib/rest-client.js.map +1 -0
- package/lib/types/rest/index.d.ts +3 -0
- package/lib/types/rest/index.js +20 -0
- package/lib/types/rest/index.js.map +1 -0
- package/lib/types/rest/request/account.d.ts +32 -0
- package/lib/types/rest/request/account.js +3 -0
- package/lib/types/rest/request/account.js.map +1 -0
- package/lib/types/rest/request/block-trading.d.ts +60 -0
- package/lib/types/rest/request/block-trading.js +3 -0
- package/lib/types/rest/request/block-trading.js.map +1 -0
- package/lib/types/rest/request/convert.d.ts +19 -0
- package/lib/types/rest/request/convert.js +3 -0
- package/lib/types/rest/request/convert.js.map +1 -0
- package/lib/types/rest/request/funding.d.ts +21 -0
- package/lib/types/rest/request/funding.js +3 -0
- package/lib/types/rest/request/funding.js.map +1 -0
- package/lib/types/rest/request/grid-trading.d.ts +30 -0
- package/lib/types/rest/request/grid-trading.js +3 -0
- package/lib/types/rest/request/grid-trading.js.map +1 -0
- package/lib/types/rest/request/index.d.ts +8 -0
- package/lib/types/rest/request/index.js +25 -0
- package/lib/types/rest/request/index.js.map +1 -0
- package/lib/types/rest/request/shared.d.ts +7 -0
- package/lib/types/rest/request/shared.js +3 -0
- package/lib/types/rest/request/shared.js.map +1 -0
- package/lib/types/rest/request/subaccount.d.ts +12 -0
- package/lib/types/rest/request/subaccount.js +3 -0
- package/lib/types/rest/request/subaccount.js.map +1 -0
- package/lib/types/rest/request/trade.d.ts +113 -0
- package/lib/types/rest/request/trade.js +3 -0
- package/lib/types/rest/request/trade.js.map +1 -0
- package/lib/types/rest/response/index.d.ts +6 -0
- package/lib/types/rest/response/index.js +23 -0
- package/lib/types/rest/response/index.js.map +1 -0
- package/lib/types/rest/response/private-account.d.ts +213 -0
- package/lib/types/rest/response/private-account.js +3 -0
- package/lib/types/rest/response/private-account.js.map +1 -0
- package/lib/types/rest/response/private-block-trading.d.ts +89 -0
- package/lib/types/rest/response/private-block-trading.js +3 -0
- package/lib/types/rest/response/private-block-trading.js.map +1 -0
- package/lib/types/rest/response/private-funding.d.ts +68 -0
- package/lib/types/rest/response/private-funding.js +3 -0
- package/lib/types/rest/response/private-funding.js.map +1 -0
- package/lib/types/rest/response/private-subaccount.d.ts +56 -0
- package/lib/types/rest/response/private-subaccount.js +3 -0
- package/lib/types/rest/response/private-subaccount.js.map +1 -0
- package/lib/types/rest/response/private-trade.d.ts +235 -0
- package/lib/types/rest/response/private-trade.js +3 -0
- package/lib/types/rest/response/private-trade.js.map +1 -0
- package/lib/types/rest/response/public-data.d.ts +70 -0
- package/lib/types/rest/response/public-data.js +3 -0
- package/lib/types/rest/response/public-data.js.map +1 -0
- package/lib/types/rest/shared.d.ts +40 -0
- package/lib/types/rest/shared.js +3 -0
- package/lib/types/rest/shared.js.map +1 -0
- package/lib/util/BaseRestClient.d.ts +34 -0
- package/lib/util/BaseRestClient.js +204 -0
- package/lib/util/BaseRestClient.js.map +1 -0
- package/lib/util/browser-support.d.ts +1 -0
- package/lib/util/browser-support.js +24 -0
- package/lib/util/browser-support.js.map +1 -0
- package/lib/util/node-support.d.ts +1 -0
- package/lib/util/node-support.js +9 -0
- package/lib/util/node-support.js.map +1 -0
- package/lib/util/requestUtils.d.ts +17 -0
- package/lib/util/requestUtils.js +52 -0
- package/lib/util/requestUtils.js.map +1 -0
- package/lib/util/typeGuards.d.ts +2 -0
- package/lib/util/typeGuards.js +14 -0
- package/lib/util/typeGuards.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { InstrumentType, numberInString } from '../shared';
|
|
2
|
+
export interface Ticker {
|
|
3
|
+
instType: InstrumentType;
|
|
4
|
+
instId: string;
|
|
5
|
+
last: numberInString;
|
|
6
|
+
lastSz: numberInString;
|
|
7
|
+
askPx: numberInString;
|
|
8
|
+
askSz: numberInString;
|
|
9
|
+
bidPx: numberInString;
|
|
10
|
+
bidSz: numberInString;
|
|
11
|
+
open24h: numberInString;
|
|
12
|
+
high24h: numberInString;
|
|
13
|
+
low24h: numberInString;
|
|
14
|
+
volCcy24h: numberInString;
|
|
15
|
+
vol24h: numberInString;
|
|
16
|
+
sodUtc0: numberInString;
|
|
17
|
+
sodUtc8: numberInString;
|
|
18
|
+
ts: numberInString;
|
|
19
|
+
}
|
|
20
|
+
export interface IndexTicker {
|
|
21
|
+
instId: string;
|
|
22
|
+
idxPx: string;
|
|
23
|
+
high24h: string;
|
|
24
|
+
sodUtc0: string;
|
|
25
|
+
open24h: string;
|
|
26
|
+
low24h: string;
|
|
27
|
+
sodUtc8: string;
|
|
28
|
+
ts: string;
|
|
29
|
+
}
|
|
30
|
+
declare type OBPrice = string;
|
|
31
|
+
declare type OBAssetQty = string;
|
|
32
|
+
declare type OBOrderCount = string;
|
|
33
|
+
declare type OrderBookLevel = [OBPrice, OBAssetQty, '0', OBOrderCount];
|
|
34
|
+
export interface OrderBook {
|
|
35
|
+
asks: OrderBookLevel[];
|
|
36
|
+
bids: OrderBookLevel[];
|
|
37
|
+
ts: string;
|
|
38
|
+
}
|
|
39
|
+
declare type timestamp = string;
|
|
40
|
+
declare type openPrice = string;
|
|
41
|
+
declare type highPrice = string;
|
|
42
|
+
declare type lowPrice = string;
|
|
43
|
+
declare type closePrice = string;
|
|
44
|
+
declare type vol = string;
|
|
45
|
+
declare type volCcy = string;
|
|
46
|
+
export declare type Candle = [
|
|
47
|
+
timestamp,
|
|
48
|
+
openPrice,
|
|
49
|
+
highPrice,
|
|
50
|
+
lowPrice,
|
|
51
|
+
closePrice,
|
|
52
|
+
vol,
|
|
53
|
+
volCcy
|
|
54
|
+
];
|
|
55
|
+
export declare type CandleNoVolume = [
|
|
56
|
+
timestamp,
|
|
57
|
+
openPrice,
|
|
58
|
+
highPrice,
|
|
59
|
+
lowPrice,
|
|
60
|
+
closePrice
|
|
61
|
+
];
|
|
62
|
+
export interface Trade {
|
|
63
|
+
instId: string;
|
|
64
|
+
side: string;
|
|
65
|
+
sz: string;
|
|
66
|
+
px: string;
|
|
67
|
+
tradeId: string;
|
|
68
|
+
ts: string;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-data.js","sourceRoot":"","sources":["../../../../src/types/rest/response/public-data.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare type numberInString<T = string> = T;
|
|
2
|
+
export interface APIResponse<T> {
|
|
3
|
+
code: '0';
|
|
4
|
+
msg: '';
|
|
5
|
+
data: T;
|
|
6
|
+
}
|
|
7
|
+
export declare type AlgoOrderType = 'conditional' | 'oco' | 'trigger' | 'move_order_stop' | 'iceberg' | 'twap';
|
|
8
|
+
export declare type AlgoState = 'effective' | 'canceled' | 'order_failed';
|
|
9
|
+
export declare type ContractGridDirection = 'long' | 'short' | 'neutral';
|
|
10
|
+
export declare type GridAlgoSubOrderType = 'live' | 'filled';
|
|
11
|
+
export declare type InstrumentType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION';
|
|
12
|
+
export declare type MarginMode = 'cross' | 'isolated';
|
|
13
|
+
export declare type OrderSide = 'buy' | 'sell';
|
|
14
|
+
export declare type OrderType = 'market' | 'limit' | 'post_only' | 'fok' | 'ioc' | 'optimal_limit_ioc';
|
|
15
|
+
export declare type PositionSide = 'net' | 'long' | 'short';
|
|
16
|
+
export declare type PriceTriggerType = 'last' | 'index' | 'mark';
|
|
17
|
+
export interface RFQLeg {
|
|
18
|
+
instId: string;
|
|
19
|
+
sz: string;
|
|
20
|
+
side: OrderSide;
|
|
21
|
+
tgtCcy?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RFQQuoteLegExtended {
|
|
24
|
+
px: string;
|
|
25
|
+
sz: string;
|
|
26
|
+
instId: string;
|
|
27
|
+
side: string;
|
|
28
|
+
fee: string;
|
|
29
|
+
feeCcy: string;
|
|
30
|
+
tradeId: string;
|
|
31
|
+
}
|
|
32
|
+
export declare type TradeMode = 'cross' | 'isolated' | 'cash';
|
|
33
|
+
export interface TimestampObject {
|
|
34
|
+
ts: numberInString;
|
|
35
|
+
}
|
|
36
|
+
export interface Pagination {
|
|
37
|
+
after?: string;
|
|
38
|
+
before?: string;
|
|
39
|
+
limit?: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/types/rest/shared.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { RestClientOptions, OKXEnvironment } from './requestUtils';
|
|
3
|
+
export declare const MISSING_CREDENTIALS_ERROR = "Private endpoints require api and secret to be provided in the REST client constructor";
|
|
4
|
+
export interface APICredentials {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
apiSecret: string;
|
|
7
|
+
apiPass: string;
|
|
8
|
+
}
|
|
9
|
+
export default abstract class BaseRestClient {
|
|
10
|
+
private options;
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private globalRequestOptions;
|
|
13
|
+
private apiKey;
|
|
14
|
+
private apiSecret;
|
|
15
|
+
private apiPassphrase;
|
|
16
|
+
constructor(credentials: APICredentials | undefined | null, baseUrl: string, options: RestClientOptions | undefined, requestOptions: AxiosRequestConfig | undefined, environment: OKXEnvironment);
|
|
17
|
+
get(endpoint: string, params?: any): Promise<any>;
|
|
18
|
+
post(endpoint: string, params?: any): Promise<any>;
|
|
19
|
+
getPrivate(endpoint: string, params?: any): Promise<any>;
|
|
20
|
+
postPrivate(endpoint: string, params?: any): Promise<any>;
|
|
21
|
+
deletePrivate(endpoint: string, params?: any): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
|
|
24
|
+
*/
|
|
25
|
+
private _call;
|
|
26
|
+
/**
|
|
27
|
+
* Sign request
|
|
28
|
+
*/
|
|
29
|
+
private signRequest;
|
|
30
|
+
/**
|
|
31
|
+
* Generic handler to parse request exceptions
|
|
32
|
+
*/
|
|
33
|
+
private parseException;
|
|
34
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MISSING_CREDENTIALS_ERROR = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const node_support_1 = require("./node-support");
|
|
18
|
+
const requestUtils_1 = require("./requestUtils");
|
|
19
|
+
const typeGuards_1 = require("./typeGuards");
|
|
20
|
+
// axios.interceptors.request.use((request) => {
|
|
21
|
+
// console.log(new Date(), 'Starting Request', JSON.stringify(request, null, 2));
|
|
22
|
+
// return request;
|
|
23
|
+
// });
|
|
24
|
+
// axios.interceptors.response.use((response) => {
|
|
25
|
+
// // console.log(new Date(), 'Response:', JSON.stringify(response, null, 2));
|
|
26
|
+
// console.log(
|
|
27
|
+
// new Date(),
|
|
28
|
+
// 'Response:',
|
|
29
|
+
// JSON.stringify(
|
|
30
|
+
// {
|
|
31
|
+
// data: response.data,
|
|
32
|
+
// headers: response.headers,
|
|
33
|
+
// },
|
|
34
|
+
// null,
|
|
35
|
+
// 2
|
|
36
|
+
// )
|
|
37
|
+
// );
|
|
38
|
+
// return response;
|
|
39
|
+
// });
|
|
40
|
+
exports.MISSING_CREDENTIALS_ERROR = 'Private endpoints require api and secret to be provided in the REST client constructor';
|
|
41
|
+
class BaseRestClient {
|
|
42
|
+
// private environment: OKXEnvironment;
|
|
43
|
+
constructor(credentials, baseUrl, options = {}, requestOptions = {}, environment) {
|
|
44
|
+
// this.environment = environment;
|
|
45
|
+
this.options = Object.assign({
|
|
46
|
+
// if true, we'll throw errors if any params are undefined
|
|
47
|
+
strict_param_validation: false }, options);
|
|
48
|
+
this.baseUrl = baseUrl;
|
|
49
|
+
// Allow empty object
|
|
50
|
+
if (credentials &&
|
|
51
|
+
(!credentials.apiKey || !credentials.apiSecret || !credentials.apiPass)) {
|
|
52
|
+
throw new Error('API Key, Secret AND Passphrase are ALL required for private enpoints');
|
|
53
|
+
}
|
|
54
|
+
this.globalRequestOptions = Object.assign({
|
|
55
|
+
// in ms == 5 minutes by default
|
|
56
|
+
timeout: 1000 * 60 * 5, headers: {} }, requestOptions);
|
|
57
|
+
// Note: `x-simulated-trading: 1` needs to be added to the header of the Demo Trading request.
|
|
58
|
+
if (environment === 'demo') {
|
|
59
|
+
this.globalRequestOptions.headers['x-simulated-trading'] = 1;
|
|
60
|
+
}
|
|
61
|
+
this.globalRequestOptions.headers['Content-Type'] = 'application/json';
|
|
62
|
+
this.globalRequestOptions.headers['Accept'] = 'application/json';
|
|
63
|
+
this.apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
|
|
64
|
+
this.apiSecret = credentials === null || credentials === void 0 ? void 0 : credentials.apiSecret;
|
|
65
|
+
this.apiPassphrase = credentials === null || credentials === void 0 ? void 0 : credentials.apiPass;
|
|
66
|
+
}
|
|
67
|
+
// private isDemoTrading(): boolean {
|
|
68
|
+
// return this.environment === 'demo';
|
|
69
|
+
// }
|
|
70
|
+
get(endpoint, params) {
|
|
71
|
+
return this._call('GET', endpoint, params, true);
|
|
72
|
+
}
|
|
73
|
+
post(endpoint, params) {
|
|
74
|
+
return this._call('POST', endpoint, params, true);
|
|
75
|
+
}
|
|
76
|
+
getPrivate(endpoint, params) {
|
|
77
|
+
return this._call('GET', endpoint, params, false);
|
|
78
|
+
}
|
|
79
|
+
postPrivate(endpoint, params) {
|
|
80
|
+
return this._call('POST', endpoint, Array.isArray(params)
|
|
81
|
+
? params.map((p) => (Object.assign(Object.assign({}, p), { [requestUtils_1.programKey]: requestUtils_1.programId })))
|
|
82
|
+
: Object.assign(Object.assign({}, params), { [requestUtils_1.programKey]: requestUtils_1.programId }), false);
|
|
83
|
+
}
|
|
84
|
+
deletePrivate(endpoint, params) {
|
|
85
|
+
return this._call('DELETE', endpoint, params, false);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
|
|
89
|
+
*/
|
|
90
|
+
_call(method, endpoint, params, isPublicApi) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const options = Object.assign(Object.assign({}, this.globalRequestOptions), { url: [this.baseUrl, endpoint].join(endpoint.startsWith('/') ? '' : '/'), method: method, json: true });
|
|
93
|
+
// Delete any params without value
|
|
94
|
+
for (const key in params) {
|
|
95
|
+
if (typeof params[key] === 'undefined') {
|
|
96
|
+
delete params[key];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const tsISO = new Date().toISOString();
|
|
100
|
+
const signResult = yield this.signRequest(isPublicApi, tsISO, method, endpoint, params);
|
|
101
|
+
if (!isPublicApi) {
|
|
102
|
+
options.headers['OK-ACCESS-KEY'] = this.apiKey;
|
|
103
|
+
options.headers['OK-ACCESS-SIGN'] = signResult.sign;
|
|
104
|
+
options.headers['OK-ACCESS-TIMESTAMP'] = tsISO;
|
|
105
|
+
options.headers['OK-ACCESS-PASSPHRASE'] = this.apiPassphrase;
|
|
106
|
+
}
|
|
107
|
+
if (method === 'GET') {
|
|
108
|
+
options.params = signResult.requestBody;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
options.data = signResult.requestBody;
|
|
112
|
+
}
|
|
113
|
+
// console.log(new Date(), 'request: ', {
|
|
114
|
+
// url: options.url,
|
|
115
|
+
// method,
|
|
116
|
+
// params: signResult.requestBody,
|
|
117
|
+
// sign: signResult.sign,
|
|
118
|
+
// options,
|
|
119
|
+
// });
|
|
120
|
+
return (0, axios_1.default)(options)
|
|
121
|
+
.then((response) => {
|
|
122
|
+
var _a;
|
|
123
|
+
// Check this is an API response without an error code.
|
|
124
|
+
// If so, resolve the nested data property, else throw the full response body
|
|
125
|
+
if ((0, typeGuards_1.isRawAPIResponse)(response.data) &&
|
|
126
|
+
response.status == 200 &&
|
|
127
|
+
((_a = response.data) === null || _a === void 0 ? void 0 : _a.code) === '0') {
|
|
128
|
+
return response.data.data;
|
|
129
|
+
}
|
|
130
|
+
// console.log('request: ', JSON.stringify(options, null, 2));
|
|
131
|
+
// console.log(
|
|
132
|
+
// 'bad response: ',
|
|
133
|
+
// JSON.stringify(
|
|
134
|
+
// {
|
|
135
|
+
// data: response.data,
|
|
136
|
+
// headers: response.headers,
|
|
137
|
+
// },
|
|
138
|
+
// null,
|
|
139
|
+
// 2
|
|
140
|
+
// )
|
|
141
|
+
// );
|
|
142
|
+
// Also throw if API returned error code
|
|
143
|
+
// This API error thrown by the exchange will be post-processed by the exception parser
|
|
144
|
+
throw { response };
|
|
145
|
+
})
|
|
146
|
+
.catch((e) => this.parseException(e));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sign request
|
|
151
|
+
*/
|
|
152
|
+
signRequest(isPublicApi, tsISO, method, endpoint, params) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const res = {
|
|
155
|
+
requestBody: params,
|
|
156
|
+
method,
|
|
157
|
+
endpoint,
|
|
158
|
+
sign: '',
|
|
159
|
+
};
|
|
160
|
+
if (isPublicApi) {
|
|
161
|
+
return res;
|
|
162
|
+
}
|
|
163
|
+
if (!this.apiKey || !this.apiSecret || !this.apiPassphrase) {
|
|
164
|
+
throw new Error(exports.MISSING_CREDENTIALS_ERROR);
|
|
165
|
+
}
|
|
166
|
+
const serializedParams = (0, requestUtils_1.serializeParams)(params, method, this.options.strict_param_validation);
|
|
167
|
+
const message = tsISO + method + endpoint + serializedParams;
|
|
168
|
+
// console.log(new Date(), `Sign params: `, {
|
|
169
|
+
// message,
|
|
170
|
+
// secret: this.apiSecret,
|
|
171
|
+
// });
|
|
172
|
+
return Object.assign(Object.assign({}, res), { sign: (0, node_support_1.signMessage)(message, this.apiSecret) });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Generic handler to parse request exceptions
|
|
177
|
+
*/
|
|
178
|
+
parseException(e) {
|
|
179
|
+
if (this.options.parse_exceptions === false) {
|
|
180
|
+
throw e;
|
|
181
|
+
}
|
|
182
|
+
// Something happened in setting up the request that triggered an Error
|
|
183
|
+
if (!e.response) {
|
|
184
|
+
if (!e.request) {
|
|
185
|
+
throw e.message;
|
|
186
|
+
}
|
|
187
|
+
// request made but no response received
|
|
188
|
+
throw e;
|
|
189
|
+
}
|
|
190
|
+
// The request was made and the server responded with a status code
|
|
191
|
+
// that falls out of the range of 2xx
|
|
192
|
+
const response = e.response;
|
|
193
|
+
throw response.data;
|
|
194
|
+
// throw {
|
|
195
|
+
// status: response.status,
|
|
196
|
+
// statusText: response.statusText,
|
|
197
|
+
// data: response.data,
|
|
198
|
+
// headers: response.headers,
|
|
199
|
+
// requestOptions: this.options,
|
|
200
|
+
// };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.default = BaseRestClient;
|
|
204
|
+
//# sourceMappingURL=BaseRestClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseRestClient.js","sourceRoot":"","sources":["../../src/util/BaseRestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyE;AAEzE,iDAA6C;AAC7C,iDAMwB;AACxB,6CAAgD;AAEhD,gDAAgD;AAChD,mFAAmF;AACnF,oBAAoB;AACpB,MAAM;AAEN,kDAAkD;AAClD,gFAAgF;AAChF,iBAAiB;AACjB,kBAAkB;AAClB,mBAAmB;AACnB,sBAAsB;AACtB,UAAU;AACV,+BAA+B;AAC/B,qCAAqC;AACrC,WAAW;AACX,cAAc;AACd,UAAU;AACV,QAAQ;AACR,OAAO;AACP,qBAAqB;AACrB,MAAM;AAEO,QAAA,yBAAyB,GACpC,wFAAwF,CAAC;AAe3F,MAA8B,cAAc;IAQ1C,uCAAuC;IAEvC,YACE,WAA8C,EAC9C,OAAe,EACf,UAA6B,EAAE,EAC/B,iBAAqC,EAAE,EACvC,WAA2B;QAE3B,kCAAkC;QAElC,IAAI,CAAC,OAAO;YACV,0DAA0D;YAC1D,uBAAuB,EAAE,KAAK,IAC3B,OAAO,CACX,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,qBAAqB;QACrB,IACE,WAAW;YACX,CAAC,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EACvE;YACA,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;SACH;QAED,IAAI,CAAC,oBAAoB;YACvB,gCAAgC;YAChC,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,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+1 @@
|
|
|
1
|
+
export declare function signMessage(message: string, secret: string): Promise<string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.signMessage = void 0;
|
|
13
|
+
function signMessage(message, secret) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const encoder = new TextEncoder();
|
|
16
|
+
const key = yield window.crypto.subtle.importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: { name: 'SHA-256' } }, false, ['sign']);
|
|
17
|
+
const signature = yield window.crypto.subtle.sign('HMAC', key, encoder.encode(message));
|
|
18
|
+
return Array.prototype.map
|
|
19
|
+
.call(new Uint8Array(signature), (x) => ('00' + x.toString(16)).slice(-2))
|
|
20
|
+
.join('');
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.signMessage = signMessage;
|
|
24
|
+
//# sourceMappingURL=browser-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-support.js","sourceRoot":"","sources":["../../src/util/browser-support.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAc;;QAEd,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC9C,KAAK,EACL,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EACtB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAC3C,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC/C,MAAM,EACN,GAAG,EACH,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CACxB,CAAC;QAEF,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;aACvB,IAAI,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAM,EAAE,EAAE,CAC1C,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAClC;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CAAA;AAxBD,kCAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function signMessage(message: string, secret: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signMessage = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
function signMessage(message, secret) {
|
|
6
|
+
return (0, crypto_1.createHmac)('sha256', secret).update(message).digest('base64');
|
|
7
|
+
}
|
|
8
|
+
exports.signMessage = signMessage;
|
|
9
|
+
//# sourceMappingURL=node-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-support.js","sourceRoot":"","sources":["../../src/util/node-support.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,SAAgB,WAAW,CAAC,OAAe,EAAE,MAAc;IACzD,OAAO,IAAA,mBAAU,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Method } from 'axios';
|
|
2
|
+
export interface RestClientOptions {
|
|
3
|
+
strict_param_validation?: boolean;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
parse_exceptions?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function serializeParams(params: object | undefined, method: Method, strict_validation?: boolean): string;
|
|
8
|
+
export declare const programKey = "tag";
|
|
9
|
+
export declare const programId = "159881cb7207BCDE";
|
|
10
|
+
/**
|
|
11
|
+
* - live: production,
|
|
12
|
+
* - aws: aws subdomain,
|
|
13
|
+
* - demo: demo environment
|
|
14
|
+
*/
|
|
15
|
+
export declare type OKXEnvironment = 'live' | 'aws' | 'demo';
|
|
16
|
+
export declare function getRestBaseUrl(environment: OKXEnvironment, restClientOptions: RestClientOptions): string;
|
|
17
|
+
export declare function isWsPong(response: any): any;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWsPong = exports.getRestBaseUrl = exports.programId = exports.programKey = exports.serializeParams = void 0;
|
|
4
|
+
function serializeParams(params, method, strict_validation = false) {
|
|
5
|
+
if (!params) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
if (method !== 'GET') {
|
|
9
|
+
return JSON.stringify(params);
|
|
10
|
+
}
|
|
11
|
+
const queryString = Object.keys(params)
|
|
12
|
+
.map((key) => {
|
|
13
|
+
const value = params[key];
|
|
14
|
+
if (strict_validation === true && typeof value === 'undefined') {
|
|
15
|
+
throw new Error('Failed to sign API request due to undefined parameter');
|
|
16
|
+
}
|
|
17
|
+
return `${key}=${value}`;
|
|
18
|
+
})
|
|
19
|
+
.join('&');
|
|
20
|
+
// Prevent trailing `?` if no params are provided
|
|
21
|
+
return queryString ? '?' + queryString : queryString;
|
|
22
|
+
}
|
|
23
|
+
exports.serializeParams = serializeParams;
|
|
24
|
+
exports.programKey = 'tag';
|
|
25
|
+
exports.programId = '159881cb7207BCDE';
|
|
26
|
+
function getRestBaseUrl(environment, restClientOptions) {
|
|
27
|
+
if (restClientOptions.baseUrl) {
|
|
28
|
+
return restClientOptions.baseUrl;
|
|
29
|
+
}
|
|
30
|
+
switch (environment) {
|
|
31
|
+
default:
|
|
32
|
+
case 'demo':
|
|
33
|
+
case 'live': {
|
|
34
|
+
return 'https://www.okx.com';
|
|
35
|
+
}
|
|
36
|
+
case 'aws': {
|
|
37
|
+
return 'https://aws.okex.com';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.getRestBaseUrl = getRestBaseUrl;
|
|
42
|
+
function isWsPong(response) {
|
|
43
|
+
if (response.pong || response.ping) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return (response.request &&
|
|
47
|
+
response.request.op === 'ping' &&
|
|
48
|
+
response.ret_msg === 'pong' &&
|
|
49
|
+
response.success === true);
|
|
50
|
+
}
|
|
51
|
+
exports.isWsPong = isWsPong;
|
|
52
|
+
//# sourceMappingURL=requestUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestUtils.js","sourceRoot":"","sources":["../../src/util/requestUtils.ts"],"names":[],"mappings":";;;AAcA,SAAgB,eAAe,CAC7B,MAA0B,EAC1B,MAAc,EACd,iBAAiB,GAAG,KAAK;IAEzB,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC/B;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACpC,GAAG,CAAC,CA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+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRawAPIResponse = void 0;
|
|
4
|
+
function isRawAPIResponse(response) {
|
|
5
|
+
if (typeof response !== 'object' || !response) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if ('code' in response && 'msg' in response && 'data' in response) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
exports.isRawAPIResponse = isRawAPIResponse;
|
|
14
|
+
//# sourceMappingURL=typeGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../src/util/typeGuards.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAC9B,QAAiB;IAEjB,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,EAAE;QAC7C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,IAAI,MAAM,IAAI,QAAQ,EAAE;QACjE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAZD,4CAYC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okx-api",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "Node.js connector for OKX REST APIs and WebSockets, with TypeScript & integration tests.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"ws": "^7.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/jest": "^
|
|
30
|
+
"@types/jest": "^28.1.4",
|
|
31
31
|
"@types/node": "^14.14.7",
|
|
32
|
-
"eslint": "^
|
|
33
|
-
"jest": "^
|
|
34
|
-
"source-map-loader": "^
|
|
35
|
-
"ts-jest": "^
|
|
36
|
-
"ts-loader": "^
|
|
37
|
-
"typescript": "^4.
|
|
32
|
+
"eslint": "^8.19.0",
|
|
33
|
+
"jest": "^28.1.2",
|
|
34
|
+
"source-map-loader": "^4.0.0",
|
|
35
|
+
"ts-jest": "^28.0.5",
|
|
36
|
+
"ts-loader": "^9.3.1",
|
|
37
|
+
"typescript": "^4.7.4",
|
|
38
38
|
"webpack": "^5.4.0",
|
|
39
39
|
"webpack-bundle-analyzer": "^4.1.0",
|
|
40
40
|
"webpack-cli": "^4.2.0"
|