Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

okx-api

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

okx-api - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

2

lib/constants/funding.d.ts

@@ -139,2 +139,2 @@ /**

}
export declare type AssetBillType = `${ASSET_BILL_TYPE}`;
export type AssetBillType = `${ASSET_BILL_TYPE}`;

@@ -142,3 +142,3 @@ "use strict";

ASSET_BILL_TYPE["WIN_CRYPTO_WITH_SATOSHI"] = "211";
})(ASSET_BILL_TYPE = exports.ASSET_BILL_TYPE || (exports.ASSET_BILL_TYPE = {}));
})(ASSET_BILL_TYPE || (exports.ASSET_BILL_TYPE = ASSET_BILL_TYPE = {}));
//# sourceMappingURL=funding.js.map

@@ -1,2 +0,2 @@

export declare type GridAlgoOrderType = 'grid' | 'contract_grid' | 'moon_grid';
export type GridAlgoOrderType = 'grid' | 'contract_grid' | 'moon_grid';
export interface GetGridAlgoOrdersRequest {

@@ -3,0 +3,0 @@ algoOrdType: GridAlgoOrderType;

@@ -1,2 +0,2 @@

declare type AccountType = '6' | '18';
type AccountType = '6' | '18';
export interface SubAccountTransferRequest {

@@ -3,0 +3,0 @@ ccy: string;

@@ -30,6 +30,6 @@ import { InstrumentType, numberInString } from '../shared';

}
declare type OBPrice = string;
declare type OBAssetQty = string;
declare type OBOrderCount = string;
declare type OrderBookLevel = [OBPrice, OBAssetQty, '0', OBOrderCount];
type OBPrice = string;
type OBAssetQty = string;
type OBOrderCount = string;
type OrderBookLevel = [OBPrice, OBAssetQty, '0', OBOrderCount];
export interface OrderBook {

@@ -40,12 +40,12 @@ asks: OrderBookLevel[];

}
declare type timestamp = string;
declare type openPrice = string;
declare type highPrice = string;
declare type lowPrice = string;
declare type closePrice = string;
declare type vol = string;
declare type volCcy = string;
declare type volCcyQuote = string;
declare type confirm = string;
export declare type Candle = [
type timestamp = string;
type openPrice = string;
type highPrice = string;
type lowPrice = string;
type closePrice = string;
type vol = string;
type volCcy = string;
type volCcyQuote = string;
type confirm = string;
export type Candle = [
timestamp,

@@ -61,3 +61,3 @@ openPrice,

];
export declare type CandleNoVolume = [
export type CandleNoVolume = [
timestamp,

@@ -64,0 +64,0 @@ openPrice,

@@ -1,2 +0,2 @@

export declare type numberInString<T = string> = T;
export type numberInString<T = string> = T;
export interface APIResponse<T> {

@@ -7,14 +7,14 @@ code: '0';

}
export declare type AlgoOrderType = 'conditional' | 'oco' | 'trigger' | 'move_order_stop' | 'iceberg' | 'twap';
export declare type AlgoOrderState = 'live' | 'pause' | 'partially_effective' | 'effective' | 'canceled' | 'order_failed' | 'partially_failed';
export declare type AlgoPositionSide = 'long' | 'short';
export declare type ContractGridDirection = 'long' | 'short' | 'neutral';
export declare type GridAlgoSubOrderType = 'live' | 'filled';
export declare type InstrumentType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION';
export declare type MarginMode = 'cross' | 'isolated';
export declare type OrderSide = 'buy' | 'sell';
export declare type OrderType = 'market' | 'limit' | 'post_only' | 'fok' | 'ioc' | 'optimal_limit_ioc';
export declare type OrderState = 'canceled' | 'live' | 'partially_filled' | 'filled' | 'mmp_canceled';
export declare type PositionSide = 'net' | 'long' | 'short';
export declare type PriceTriggerType = 'last' | 'index' | 'mark';
export type AlgoOrderType = 'conditional' | 'oco' | 'trigger' | 'move_order_stop' | 'iceberg' | 'twap';
export type AlgoOrderState = 'live' | 'pause' | 'partially_effective' | 'effective' | 'canceled' | 'order_failed' | 'partially_failed';
export type AlgoPositionSide = 'long' | 'short';
export type ContractGridDirection = 'long' | 'short' | 'neutral';
export type GridAlgoSubOrderType = 'live' | 'filled';
export type InstrumentType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION';
export type MarginMode = 'cross' | 'isolated';
export type OrderSide = 'buy' | 'sell';
export type OrderType = 'market' | 'limit' | 'post_only' | 'fok' | 'ioc' | 'optimal_limit_ioc';
export type OrderState = 'canceled' | 'live' | 'partially_filled' | 'filled' | 'mmp_canceled';
export type PositionSide = 'net' | 'long' | 'short';
export type PriceTriggerType = 'last' | 'index' | 'mark';
export interface RFQLeg {

@@ -35,3 +35,3 @@ instId: string;

}
export declare type TradeMode = 'cross' | 'isolated' | 'cash';
export type TradeMode = 'cross' | 'isolated' | 'cash';
export interface TimestampObject {

@@ -45,2 +45,2 @@ ts: numberInString;

}
export declare type PosMode = 'long_short_mode' | 'net_mode';
export type PosMode = 'long_short_mode' | 'net_mode';

@@ -6,2 +6,2 @@ export interface APICredentials {

}
export declare type APIMarket = 'prod' | 'business' | 'businessAws' | 'aws' | 'demo' | 'businessDemo';
export type APIMarket = 'prod' | 'business' | 'businessAws' | 'aws' | 'demo' | 'businessDemo';

@@ -21,2 +21,2 @@ import { WsChannel } from './request';

}
export declare type WsResponse = WsEvent;
export type WsResponse = WsEvent;

@@ -7,14 +7,14 @@ export interface WsAuthRequestArg {

}
export declare type WsTradeOp = 'order' | 'batch-orders' | 'cancel-order' | 'batch-cancel-orders' | 'amend-order' | 'batch-amend-order';
export declare type WsRequestOp = 'login' | 'subscribe' | 'unsubscribe';
export declare type WsPrivateChannel = 'account' | 'positions' | 'balance_and_position' | 'orders' | 'orders-algo' | 'algo-advance' | 'liquidation-warning' | 'account-greeks' | 'grid-orders-spot' | 'grid-orders-contract' | 'grid-orders-moon' | 'grid-positions' | 'grid-sub-orders';
export declare type WsPublicKlineChannel = 'candle1Y' | 'candle6M' | 'candle3M' | 'candle1M' | 'candle1W' | 'candle1D' | 'candle2D' | 'candle3D' | 'candle5D' | 'candle12H' | 'candle6H' | 'candle4H' | 'candle2H' | 'candle1H' | 'candle30m' | 'candle15m' | 'candle5m' | 'candle3m' | 'candle1m' | 'candle1Yutc' | 'candle3Mutc' | 'candle1Mutc' | 'candle1Wutc' | 'candle1Dutc' | 'candle2Dutc' | 'candle3Dutc' | 'candle5Dutc' | 'candle12Hutc' | 'candle6Hutc';
export declare type WsPublicMarkPriceKlineChannel = 'mark-price-candle1Y' | 'mark-price-candle6M' | 'mark-price-candle3M' | 'mark-price-candle1M' | 'mark-price-candle1W' | 'mark-price-candle1D' | 'mark-price-candle2D' | 'mark-price-candle3D' | 'mark-price-candle5D' | 'mark-price-candle12H' | 'mark-price-candle6H' | 'mark-price-candle4H' | 'mark-price-candle2H' | 'mark-price-candle1H' | 'mark-price-candle30m' | 'mark-price-candle15m' | 'mark-price-candle5m' | 'mark-price-candle3m' | 'mark-price-candle1m' | 'mark-price-candle1Yutc' | 'mark-price-candle3Mutc' | 'mark-price-candle1Mutc' | 'mark-price-candle1Wutc' | 'mark-price-candle1Dutc' | 'mark-price-candle2Dutc' | 'mark-price-candle3Dutc' | 'mark-price-candle5Dutc' | 'mark-price-candle12Hutc' | 'mark-price-candle6Hutc';
export declare type WsPublicIndexKlineChannel = 'index-candle1Y' | 'index-candle6M' | 'index-candle3M' | 'index-candle1M' | 'index-candle1W' | 'index-candle1D' | 'index-candle2D' | 'index-candle3D' | 'index-candle5D' | 'index-candle12H' | 'index-candle6H' | 'index-candle4H index -candle2H' | 'index-candle1H' | 'index-candle30m' | 'index-candle15m' | 'index-candle5m' | 'index-candle3m' | 'index-candle1m' | 'index-candle1Yutc' | 'index-candle3Mutc' | 'index-candle1Mutc' | 'index-candle1Wutc' | 'index-candle1Dutc' | 'index-candle2Dutc' | 'index-candle3Dutc' | 'index-candle5Dutc' | 'index-candle12Hutc' | 'index-candle6Hutc';
export declare type WsPublicOrderBooksChannel = 'books' | 'books5' | 'bbo-tbt' | 'books-l2-tbt' | 'books50-l2-tpt';
export declare type WsPublicChannel = 'instruments' | 'tickers' | 'open-interest' | WsPublicKlineChannel | WsPublicMarkPriceKlineChannel | WsPublicIndexKlineChannel | 'trades' | 'estimated-price' | 'mark-price' | 'price-limit' | WsPublicOrderBooksChannel | 'opt-summary' | 'funding-rate' | 'index-tickers' | 'status' | 'liquidation-orders';
export declare type WsBusinessPrivateChannel = 'orders-algo' | 'algo-advance' | 'deposit-info' | 'withdrawal-info' | 'grid-orders-spot' | 'grid-orders-contract' | 'grid-orders-moon' | 'grid-positions' | 'grid-sub-orders' | 'algo-recurring-buy';
export declare type WsBusinessPublicChannel = WsPublicKlineChannel | WsPublicMarkPriceKlineChannel | WsPublicIndexKlineChannel;
export declare type WsBusinessChannel = WsBusinessPrivateChannel | WsBusinessPublicChannel;
export declare type WsChannel = WsPublicChannel | WsPrivateChannel | WsBusinessChannel;
export type WsTradeOp = 'order' | 'batch-orders' | 'cancel-order' | 'batch-cancel-orders' | 'amend-order' | 'batch-amend-order';
export type WsRequestOp = 'login' | 'subscribe' | 'unsubscribe';
export type WsPrivateChannel = 'account' | 'positions' | 'balance_and_position' | 'orders' | 'orders-algo' | 'algo-advance' | 'liquidation-warning' | 'account-greeks' | 'grid-orders-spot' | 'grid-orders-contract' | 'grid-orders-moon' | 'grid-positions' | 'grid-sub-orders';
export type WsPublicKlineChannel = 'candle1Y' | 'candle6M' | 'candle3M' | 'candle1M' | 'candle1W' | 'candle1D' | 'candle2D' | 'candle3D' | 'candle5D' | 'candle12H' | 'candle6H' | 'candle4H' | 'candle2H' | 'candle1H' | 'candle30m' | 'candle15m' | 'candle5m' | 'candle3m' | 'candle1m' | 'candle1Yutc' | 'candle3Mutc' | 'candle1Mutc' | 'candle1Wutc' | 'candle1Dutc' | 'candle2Dutc' | 'candle3Dutc' | 'candle5Dutc' | 'candle12Hutc' | 'candle6Hutc';
export type WsPublicMarkPriceKlineChannel = 'mark-price-candle1Y' | 'mark-price-candle6M' | 'mark-price-candle3M' | 'mark-price-candle1M' | 'mark-price-candle1W' | 'mark-price-candle1D' | 'mark-price-candle2D' | 'mark-price-candle3D' | 'mark-price-candle5D' | 'mark-price-candle12H' | 'mark-price-candle6H' | 'mark-price-candle4H' | 'mark-price-candle2H' | 'mark-price-candle1H' | 'mark-price-candle30m' | 'mark-price-candle15m' | 'mark-price-candle5m' | 'mark-price-candle3m' | 'mark-price-candle1m' | 'mark-price-candle1Yutc' | 'mark-price-candle3Mutc' | 'mark-price-candle1Mutc' | 'mark-price-candle1Wutc' | 'mark-price-candle1Dutc' | 'mark-price-candle2Dutc' | 'mark-price-candle3Dutc' | 'mark-price-candle5Dutc' | 'mark-price-candle12Hutc' | 'mark-price-candle6Hutc';
export type WsPublicIndexKlineChannel = 'index-candle1Y' | 'index-candle6M' | 'index-candle3M' | 'index-candle1M' | 'index-candle1W' | 'index-candle1D' | 'index-candle2D' | 'index-candle3D' | 'index-candle5D' | 'index-candle12H' | 'index-candle6H' | 'index-candle4H index -candle2H' | 'index-candle1H' | 'index-candle30m' | 'index-candle15m' | 'index-candle5m' | 'index-candle3m' | 'index-candle1m' | 'index-candle1Yutc' | 'index-candle3Mutc' | 'index-candle1Mutc' | 'index-candle1Wutc' | 'index-candle1Dutc' | 'index-candle2Dutc' | 'index-candle3Dutc' | 'index-candle5Dutc' | 'index-candle12Hutc' | 'index-candle6Hutc';
export type WsPublicOrderBooksChannel = 'books' | 'books5' | 'bbo-tbt' | 'books-l2-tbt' | 'books50-l2-tpt';
export type WsPublicChannel = 'instruments' | 'tickers' | 'open-interest' | WsPublicKlineChannel | WsPublicMarkPriceKlineChannel | WsPublicIndexKlineChannel | 'trades' | 'estimated-price' | 'mark-price' | 'price-limit' | WsPublicOrderBooksChannel | 'opt-summary' | 'funding-rate' | 'index-tickers' | 'status' | 'liquidation-orders';
export type WsBusinessPrivateChannel = 'orders-algo' | 'algo-advance' | 'deposit-info' | 'withdrawal-info' | 'grid-orders-spot' | 'grid-orders-contract' | 'grid-orders-moon' | 'grid-positions' | 'grid-sub-orders' | 'algo-recurring-buy';
export type WsBusinessPublicChannel = WsPublicKlineChannel | WsPublicMarkPriceKlineChannel | WsPublicIndexKlineChannel;
export type WsBusinessChannel = WsBusinessPrivateChannel | WsBusinessPublicChannel;
export type WsChannel = WsPublicChannel | WsPrivateChannel | WsBusinessChannel;
export interface WsBaseRequest {

@@ -46,3 +46,3 @@ op: WsRequestOp;

}
export declare type WsChannelArgInstType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION' | 'ANY';
export type WsChannelArgInstType = 'SPOT' | 'MARGIN' | 'SWAP' | 'FUTURES' | 'OPTION' | 'ANY';
export interface WsPrivateChannelArgWithInstFamily extends WsBaseRequestArg {

@@ -81,3 +81,3 @@ channel: 'positions' | 'orders' | 'orders-algo' | 'liquidation-warning';

}
export declare type WsPublicChannelArgInstIdOrFamily = {
export type WsPublicChannelArgInstIdOrFamily = {
channel: 'estimated-price';

@@ -101,3 +101,3 @@ instType: 'OPTION' | 'FUTURES';

}
export declare type WsChannelSubUnSubRequestArg = WsPrivateChannelArgTickers | WsPrivateChannelArgWithCcy | WsPrivateChannelArgWithInstFamily | WsPrivateChannelArgAlgo | WsPrivateChannelArgBalanceAndPosition | WsPrivateChannelArgGridOrders | WsPrivateChannelArgGridOther | WsPublicChannelArgInstType | WsPublicChannelArgInstId | WsPublicChannelArgInstIdOrFamily | WsPublicChannelArgOptionSummary | WsPublicChannelArgStatus | WsPublicChannelArgLiquidationOrders;
export type WsChannelSubUnSubRequestArg = WsPrivateChannelArgTickers | WsPrivateChannelArgWithCcy | WsPrivateChannelArgWithInstFamily | WsPrivateChannelArgAlgo | WsPrivateChannelArgBalanceAndPosition | WsPrivateChannelArgGridOrders | WsPrivateChannelArgGridOther | WsPublicChannelArgInstType | WsPublicChannelArgInstId | WsPublicChannelArgInstIdOrFamily | WsPublicChannelArgOptionSummary | WsPublicChannelArgStatus | WsPublicChannelArgLiquidationOrders;
/**

@@ -104,0 +104,0 @@ *

@@ -11,3 +11,3 @@ import { AxiosRequestConfig } from 'axios';

private apiPassphrase;
constructor(credentials: APICredentials | undefined | null, baseUrl: string, options: RestClientOptions | undefined, requestOptions: AxiosRequestConfig | undefined, market: APIMarket);
constructor(credentials: APICredentials | undefined | null, baseUrl: string, options: RestClientOptions | undefined, requestOptions: AxiosRequestConfig<any> | undefined, market: APIMarket);
get(endpoint: string, params?: any): Promise<any>;

@@ -14,0 +14,0 @@ post(endpoint: string, params?: any): Promise<any>;

@@ -55,3 +55,6 @@ "use strict";

// in ms == 5 minutes by default
timeout: 1000 * 60 * 5, headers: {} }, requestOptions);
timeout: 1000 * 60 * 5 }, requestOptions);
if (!this.globalRequestOptions.headers) {
this.globalRequestOptions.headers = {};
}
// Note: `x-simulated-trading: 1` needs to be added to the header of the Demo Trading request.

@@ -67,5 +70,2 @@ if (market === 'demo') {

}
// private isDemoTrading(): boolean {
// return this.environment === 'demo';
// }
get(endpoint, params) {

@@ -102,2 +102,5 @@ return this._call('GET', endpoint, params, true);

const signResult = yield this.signRequest(isPublicApi, tsISO, method, endpoint, params);
if (!options.headers) {
options.headers = {};
}
if (!isPublicApi) {

@@ -104,0 +107,0 @@ options.headers['OK-ACCESS-KEY'] = this.apiKey;

@@ -1,2 +0,2 @@

export declare type LogParams = null | any;
export type LogParams = null | any;
export declare const DefaultLogger: {

@@ -3,0 +3,0 @@ silly: (...params: LogParams) => void;

@@ -18,3 +18,3 @@ import { APIMarket, WebsocketClientOptions, WsChannel } from '../types';

/** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */
export declare type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP];
export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP];
export declare const PRIVATE_WS_KEYS: WsKey[];

@@ -21,0 +21,0 @@ export declare const PUBLIC_WS_KEYS: WsKey[];

@@ -12,3 +12,3 @@ import WebSocket from 'isomorphic-ws';

/** A "topic" is always a string */
declare type WsTopic = string;
type WsTopic = string;
/**

@@ -39,3 +39,3 @@ * A "Set" is used to ensure we only subscribe to a topic once (tracking a list of unique topics we're expected to be connected to)

export declare function isDeepObjectMatch(object1: any, object2: any): boolean;
declare type WSSimpleTopic = string;
type WSSimpleTopic = string;
export declare class WsStore<WSComplexTopic> {

@@ -42,0 +42,0 @@ private wsState;

@@ -13,3 +13,3 @@ "use strict";

// ERROR = 5,
})(WsConnectionStateEnum = exports.WsConnectionStateEnum || (exports.WsConnectionStateEnum = {}));
})(WsConnectionStateEnum || (exports.WsConnectionStateEnum = WsConnectionStateEnum = {}));
function isDeepObjectMatch(object1, object2) {

@@ -16,0 +16,0 @@ if (typeof object2 !== typeof object1) {

@@ -7,4 +7,4 @@ /// <reference types="node" />

import { WsKey } from './util/websocket-util';
export declare type WsClientEvent = 'open' | 'update' | 'close' | 'error' | 'reconnect' | 'reconnected' | 'response';
declare type WsKeyObject = {
export type WsClientEvent = 'open' | 'update' | 'close' | 'error' | 'reconnect' | 'reconnected' | 'response';
type WsKeyObject = {
wsKey: WsKey;

@@ -11,0 +11,0 @@ };

{
"name": "okx-api",
"version": "1.2.1",
"version": "1.3.0",
"description": "Complete & robust Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests",

@@ -25,3 +25,3 @@ "main": "lib/index.js",

"dependencies": {
"axios": "^0.21.0",
"axios": "^1.6.7",
"isomorphic-ws": "^4.0.1",

@@ -31,10 +31,12 @@ "ws": "^7.4.0"

"devDependencies": {
"@types/jest": "^28.1.4",
"@types/node": "^14.14.7",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.6",
"eslint": "^8.19.0",
"jest": "^28.1.2",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"typescript": "^5.3.3"
},
"optionalDependencies": {
"source-map-loader": "^4.0.0",
"ts-jest": "^28.0.5",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"webpack": "^5.4.0",

@@ -41,0 +43,0 @@ "webpack-bundle-analyzer": "^4.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc