valr-typescript-client 1.0.25 → 1.0.26

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/CHECKSUMS.txt CHANGED
@@ -1,50 +1,50 @@
1
1
  # Package Checksums
2
2
 
3
- Generated on: 2026-01-25 20:24:36 UTC
4
- Git commit: 71d1f6f99b44476aed1b0c667eb073e5cd33879f
5
- Version: 1.0.25
3
+ Generated on: 2026-01-26 19:58:51 UTC
4
+ Git commit: 71b249b384233c13b2df98f3a4a9a5a9fea9cdb1
5
+ Version: 1.0.26
6
6
 
7
7
  ## Distribution Files (SHA256)
8
8
 
9
- 1ad514030f226670c9a3876382d2bf55bd17a8060af8bb8806ae053fc190fe72 dist/index.js
10
- 4d39c0f55fdce6fead26a5de898a9f8fa96a49816ba6fcc4e229c08c9552630e dist/index.d.mts
11
- 4d39c0f55fdce6fead26a5de898a9f8fa96a49816ba6fcc4e229c08c9552630e dist/index.d.ts
12
- 7aee38224d434e0960cd922e3ea005730696262bcd1ca39eddf9683644695133 dist/index.mjs
13
- a5a707a70fa00165f23c389b8b5725adc574e02838763686611b18548c340861 dist/index.mjs.map
14
- e8e86091f42adbc55f0ff1b71d2456d5e8a60ba1eff6a5fec75ff298228764aa dist/index.js.map
9
+ 1176c58feea26198e1c304a729e9b023d4ed47d0880caf58c8e703f6b4f08231 dist/index.js
10
+ 70c496fd629873c652287d77f9716e8ef66560a7aa23de37ace9550150004868 dist/index.mjs
11
+ 838ea481d946827115869257b49e6543cad802f1e0d5579c021fed8dc81009c6 dist/index.js.map
12
+ b8723c17cfd97bd1da88bad3992a3e6ee0b0af4749737cefb8bea6d261ba9c4d dist/index.d.mts
13
+ b8723c17cfd97bd1da88bad3992a3e6ee0b0af4749737cefb8bea6d261ba9c4d dist/index.d.ts
14
+ f65bf707fb52c3d08f588e3b35c488df7c97b9687cc72e97157bcc9a44611b6d dist/index.mjs.map
15
15
 
16
16
  ## Source Files (SHA256)
17
17
 
18
- 05cf6e982fcbd24cebc6c1b4c6e366095859cdf503eb70f5faf4d9bb9844631a src/client/ValrClient.ts
19
18
  0705454404aa0e0f2ce619615600d871c8052ac0afe495bb412219d9a6c032ac src/types/public.ts
20
19
  07451545d78e896ab106b594151b4b9a3ae5ca4a2328914b2040a67cec403270 src/types/margin.ts
20
+ 08d03e1aa5d5bdfa6b21fb112da24eb3e7fdfd87950a1311d1aed3c893babaa1 src/client/ValrClient.ts
21
21
  0b4530d458e0c3bbadb79566943ef466404215e545f25c4965c72d9bfeee86dc src/api/health.ts
22
+ 0da8bec4137e840f560cc7b0bd8a66f282111bea693c99a750c496f5cbd07f35 src/client/TradeWebSocket.ts
22
23
  13c4319ae883c96f779ea57f481c52f2298397e11950213f7d43a05290f42e8a src/api/trading.ts
23
24
  15ef50a824d04e4466a4e34c29b54429c4d36e64d15eed1374c7165452da3abf src/api/loans.ts
24
25
  174ffc46347008d3f473af1916e8b1b38fb9752e68a69776df831dca676a1342 src/api/public.ts
25
26
  1b2b9d2ae756384d9495e833dfa77d77f7b69da31a710dbb1bcdb7f688caace7 src/types/account.ts
26
27
  392124cca58a1532bd57472ba574bc065052c552ea8f10b7c675c942310c67e8 src/api/wallets.ts
27
28
  39fd4908c74bcca8c4e74a3a4e16de4439dfca781a7644ca9383c5f5096744cf src/types/futures.ts
29
+ 3de9435ffb394dafb92812679aaae26074cb7aaf1b62c88eb1b0b1409bf756fa src/client/ValrWebSocketClient.ts
28
30
  3e5ff90a945e12f321b0e7a5bdef82f95e0b04f6ba794eeed9d4887d80d50323 src/api/pay.ts
29
- 40f2245b2685e634bd0f531367561c1c26d174cc083c496c1f914e8c6a9f948a src/client/ValrWebSocketClient.ts
30
31
  4202fe777fda3e43ff944971783116f17031d124395e4a44cb2bf2bec5ff246c src/types/bundles.ts
31
32
  43ce3b42153a2e1a2d290ea893507c820e4461eb2162b1ccfa0d832118468618 src/api/margin.ts
32
33
  4e77e25219e1d4c7552ffc6b561493e33fb179c31fc9eaf456a304e7d7055552 src/api/account.ts
33
34
  551aa287e635dad4d0209502a0410f09c169715a5bac95366a875038c3e50504 src/api/futures.ts
34
35
  5572db3151cd4db275a7ac6e8a8859e3c9048e0bd873a113f445139c0db2017c src/api/bundles.ts
36
+ 56848fb83b06ee2264c2a5197dc641d5b28513aee2c097cdcbf8ed1db3cdf271 src/client/AccountWebSocket.ts
35
37
  593e9b1515cb7e1316feae0cf24a9300b879284677c5e790e650502b32c70706 src/types/websocket.ts
38
+ 5a6cc3f289263a8d68c4dbe1d23be4c686676a81975b8eb3d49c4445903929e8 src/utils/http.ts
36
39
  5f68ae1d81c72d13f5c4c2b16d6c45e89500b069b84f3cf788f97b313790e8cf src/types/index.ts
37
40
  612b1e543d1bbd97b75e814fa7d9b4ff4b1786f6b3671a03019917049e38a96e src/types/stake.ts
38
41
  6ec43e250aca38bc6a9dc4f16e5fe7e6ca25bd831270c5d02c1bc82d79f5731d src/types/loans.ts
39
42
  70636220daed500243e5cd40d25748efcd401a9ff50f4237fa200bce1fe3be38 src/errors/ValrError.ts
40
43
  a1227a733cc2ab864023614a826d8c174464d6dd5390eb8820ed616c596be0d1 src/types/trading.ts
41
44
  a52c483def6de035f7fcf690b6102129ea22cb817bed5a106d3617c8edc7d849 src/api/stake.ts
42
- c235e305ae167ebe7b97944fb50df66df428cf7b4776aacab57f6c4d6083cf40 src/utils/http.ts
43
45
  dc9ef99ff3979f5dd0f0fc7231f9a6b9418dd13e0e8961511af1c9d54200576e src/types/pay.ts
44
46
  e4cd666eff2f4223850198ca26912d310298291cfe0606a773350df3b3f58c59 src/types/common.ts
45
47
  ec209b0ff8de8e662c2ea701feccee22b53e6ed684affb3eacd39e68c3aa725a src/index.ts
46
48
  f67a6c69ed003a1606221e792de802592aedb7164cafb7d7d2eab4fac105807a src/utils/constants.ts
47
- f819d431730bb51a23d2cad32cc6eee83dc9d917e5cb9efd3201ffeb64d76ec5 src/client/AccountWebSocket.ts
48
49
  fadae797586481848494b79e9924ecc1e6fabc19a154d822579ffa2065d395fd src/auth/RequestSigner.ts
49
- fe3ced400781e287f691c1262b48ea5005d21b45f69172a8a03b470e14c63a6e src/client/TradeWebSocket.ts
50
50
  fe8bec28add01e200bd95ad326a0511334671b3a82a3990d2ee521adca7a7a8e src/types/wallets.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
2
1
  import WebSocket from 'ws';
3
- import EventEmitter from 'eventemitter3';
2
+ import { EventEmitter } from 'node:events';
4
3
 
5
4
  /**
6
5
  * HTTP client configuration
@@ -11,31 +10,85 @@ interface HttpClientConfig {
11
10
  headers?: Record<string, string>;
12
11
  }
13
12
  /**
14
- * HTTP client wrapper for VALR API
13
+ * Request configuration (similar to AxiosRequestConfig for compatibility)
14
+ */
15
+ interface RequestConfig {
16
+ headers?: Record<string, string>;
17
+ params?: Record<string, any>;
18
+ signal?: AbortSignal;
19
+ /** Request body data (for DELETE with body) */
20
+ data?: any;
21
+ }
22
+ /**
23
+ * Internal request configuration used by interceptors
24
+ */
25
+ interface InternalRequestConfig {
26
+ method: string;
27
+ url: string;
28
+ headers: Record<string, string>;
29
+ params?: Record<string, any>;
30
+ data?: any;
31
+ }
32
+ /**
33
+ * Request interceptor function type
34
+ */
35
+ type RequestInterceptor = (config: InternalRequestConfig) => InternalRequestConfig;
36
+ /**
37
+ * Response wrapper (similar to AxiosResponse for compatibility)
38
+ */
39
+ interface HttpResponse<T = any> {
40
+ data: T;
41
+ status: number;
42
+ statusText: string;
43
+ headers: Headers;
44
+ }
45
+ /**
46
+ * HTTP client wrapper for VALR API using native fetch
47
+ * Zero dependencies - uses Node.js built-in fetch (Node 18+)
15
48
  */
16
49
  declare class HttpClient {
17
- private axiosInstance;
50
+ private baseURL;
51
+ private timeout;
52
+ private defaultHeaders;
53
+ private requestInterceptors;
18
54
  constructor(config?: HttpClientConfig);
55
+ /**
56
+ * Add a request interceptor
57
+ * Interceptors are called in order before each request
58
+ */
59
+ addRequestInterceptor(interceptor: RequestInterceptor): void;
60
+ /**
61
+ * Build full URL with query parameters
62
+ */
63
+ private buildUrl;
64
+ /**
65
+ * Execute HTTP request with error handling
66
+ */
67
+ private request;
68
+ /**
69
+ * Handle error responses and throw appropriate VALR errors
70
+ */
71
+ private handleErrorResponse;
19
72
  /**
20
73
  * Perform GET request
21
74
  */
22
- get<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
75
+ get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
23
76
  /**
24
77
  * Perform POST request
25
78
  */
26
- post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
79
+ post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
27
80
  /**
28
81
  * Perform PUT request
29
82
  */
30
- put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
83
+ put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
31
84
  /**
32
85
  * Perform PATCH request
33
86
  */
34
- patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
87
+ patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
35
88
  /**
36
89
  * Perform DELETE request
37
90
  */
38
- delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
91
+ delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
39
92
  /**
40
93
  * Set default header
41
94
  */
@@ -44,10 +97,6 @@ declare class HttpClient {
44
97
  * Remove default header
45
98
  */
46
99
  removeHeader(key: string): void;
47
- /**
48
- * Get the underlying Axios instance
49
- */
50
- getInstance(): AxiosInstance;
51
100
  }
52
101
 
53
102
  /**
@@ -3746,22 +3795,11 @@ interface WebSocketClientConfig {
3746
3795
  /** Base URL for WS (defaults to wss://api.valr.com) */
3747
3796
  baseURL?: string;
3748
3797
  }
3749
- /**
3750
- * WebSocket event types
3751
- */
3752
- interface WebSocketEvents {
3753
- connected: () => void;
3754
- authenticated: () => void;
3755
- message: (message: WebSocketMessage) => void;
3756
- error: (error: Error) => void;
3757
- close: (code: number, reason: string) => void;
3758
- disconnected: () => void;
3759
- reconnecting: (attempt: number) => void;
3760
- }
3761
3798
  /**
3762
3799
  * Base WebSocket client for VALR API
3800
+ * Uses Node.js native EventEmitter (zero dependencies)
3763
3801
  */
3764
- declare abstract class ValrWebSocketClient<TEvents extends WebSocketEvents = WebSocketEvents> extends EventEmitter<TEvents> {
3802
+ declare abstract class ValrWebSocketClient extends EventEmitter {
3765
3803
  protected ws?: WebSocket;
3766
3804
  protected url: string;
3767
3805
  protected path: string;
@@ -3819,19 +3857,6 @@ declare abstract class ValrWebSocketClient<TEvents extends WebSocketEvents = Web
3819
3857
  protected abstract onMessage(message: WebSocketMessage): void;
3820
3858
  }
3821
3859
 
3822
- /**
3823
- * Account WebSocket events (in addition to base events)
3824
- */
3825
- interface AccountWebSocketEvents {
3826
- 'order:processed': (data: OrderProcessed) => void;
3827
- 'order:statusUpdate': (data: OrderStatusUpdate) => void;
3828
- 'balance:update': (data: BalanceUpdate) => void;
3829
- 'trade:new': (data: AccountTrade) => void;
3830
- }
3831
- /**
3832
- * Combined event types for AccountWebSocket
3833
- */
3834
- type AccountWebSocketEventMap = WebSocketEvents & AccountWebSocketEvents;
3835
3860
  /**
3836
3861
  * Account WebSocket client for real-time account updates
3837
3862
  *
@@ -3867,7 +3892,7 @@ type AccountWebSocketEventMap = WebSocketEvents & AccountWebSocketEvents;
3867
3892
  * wsClient.connect();
3868
3893
  * ```
3869
3894
  */
3870
- declare class AccountWebSocket extends ValrWebSocketClient<AccountWebSocketEventMap> {
3895
+ declare class AccountWebSocket extends ValrWebSocketClient {
3871
3896
  constructor(config: WebSocketClientConfig);
3872
3897
  /**
3873
3898
  * Subscribe to specific events
@@ -3891,18 +3916,6 @@ declare class AccountWebSocket extends ValrWebSocketClient<AccountWebSocketEvent
3891
3916
  protected onMessage(message: WebSocketMessage): void;
3892
3917
  }
3893
3918
 
3894
- /**
3895
- * Trade WebSocket events (in addition to base events)
3896
- */
3897
- interface TradeWebSocketEvents {
3898
- 'orderbook:update': (data: OrderBookUpdate) => void;
3899
- 'market:summary': (data: MarketSummaryUpdate) => void;
3900
- 'trade:new': (data: NewTrade) => void;
3901
- }
3902
- /**
3903
- * Combined event types for TradeWebSocket
3904
- */
3905
- type TradeWebSocketEventMap = WebSocketEvents & TradeWebSocketEvents;
3906
3919
  /**
3907
3920
  * Trade WebSocket client for real-time market data
3908
3921
  *
@@ -3934,7 +3947,7 @@ type TradeWebSocketEventMap = WebSocketEvents & TradeWebSocketEvents;
3934
3947
  * wsClient.connect();
3935
3948
  * ```
3936
3949
  */
3937
- declare class TradeWebSocket extends ValrWebSocketClient<TradeWebSocketEventMap> {
3950
+ declare class TradeWebSocket extends ValrWebSocketClient {
3938
3951
  constructor(config?: WebSocketClientConfig);
3939
3952
  /**
3940
3953
  * Subscribe to aggregated order book updates for currency pairs
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
2
1
  import WebSocket from 'ws';
3
- import EventEmitter from 'eventemitter3';
2
+ import { EventEmitter } from 'node:events';
4
3
 
5
4
  /**
6
5
  * HTTP client configuration
@@ -11,31 +10,85 @@ interface HttpClientConfig {
11
10
  headers?: Record<string, string>;
12
11
  }
13
12
  /**
14
- * HTTP client wrapper for VALR API
13
+ * Request configuration (similar to AxiosRequestConfig for compatibility)
14
+ */
15
+ interface RequestConfig {
16
+ headers?: Record<string, string>;
17
+ params?: Record<string, any>;
18
+ signal?: AbortSignal;
19
+ /** Request body data (for DELETE with body) */
20
+ data?: any;
21
+ }
22
+ /**
23
+ * Internal request configuration used by interceptors
24
+ */
25
+ interface InternalRequestConfig {
26
+ method: string;
27
+ url: string;
28
+ headers: Record<string, string>;
29
+ params?: Record<string, any>;
30
+ data?: any;
31
+ }
32
+ /**
33
+ * Request interceptor function type
34
+ */
35
+ type RequestInterceptor = (config: InternalRequestConfig) => InternalRequestConfig;
36
+ /**
37
+ * Response wrapper (similar to AxiosResponse for compatibility)
38
+ */
39
+ interface HttpResponse<T = any> {
40
+ data: T;
41
+ status: number;
42
+ statusText: string;
43
+ headers: Headers;
44
+ }
45
+ /**
46
+ * HTTP client wrapper for VALR API using native fetch
47
+ * Zero dependencies - uses Node.js built-in fetch (Node 18+)
15
48
  */
16
49
  declare class HttpClient {
17
- private axiosInstance;
50
+ private baseURL;
51
+ private timeout;
52
+ private defaultHeaders;
53
+ private requestInterceptors;
18
54
  constructor(config?: HttpClientConfig);
55
+ /**
56
+ * Add a request interceptor
57
+ * Interceptors are called in order before each request
58
+ */
59
+ addRequestInterceptor(interceptor: RequestInterceptor): void;
60
+ /**
61
+ * Build full URL with query parameters
62
+ */
63
+ private buildUrl;
64
+ /**
65
+ * Execute HTTP request with error handling
66
+ */
67
+ private request;
68
+ /**
69
+ * Handle error responses and throw appropriate VALR errors
70
+ */
71
+ private handleErrorResponse;
19
72
  /**
20
73
  * Perform GET request
21
74
  */
22
- get<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
75
+ get<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
23
76
  /**
24
77
  * Perform POST request
25
78
  */
26
- post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
79
+ post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
27
80
  /**
28
81
  * Perform PUT request
29
82
  */
30
- put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
83
+ put<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
31
84
  /**
32
85
  * Perform PATCH request
33
86
  */
34
- patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
87
+ patch<T = any>(url: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
35
88
  /**
36
89
  * Perform DELETE request
37
90
  */
38
- delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
91
+ delete<T = any>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
39
92
  /**
40
93
  * Set default header
41
94
  */
@@ -44,10 +97,6 @@ declare class HttpClient {
44
97
  * Remove default header
45
98
  */
46
99
  removeHeader(key: string): void;
47
- /**
48
- * Get the underlying Axios instance
49
- */
50
- getInstance(): AxiosInstance;
51
100
  }
52
101
 
53
102
  /**
@@ -3746,22 +3795,11 @@ interface WebSocketClientConfig {
3746
3795
  /** Base URL for WS (defaults to wss://api.valr.com) */
3747
3796
  baseURL?: string;
3748
3797
  }
3749
- /**
3750
- * WebSocket event types
3751
- */
3752
- interface WebSocketEvents {
3753
- connected: () => void;
3754
- authenticated: () => void;
3755
- message: (message: WebSocketMessage) => void;
3756
- error: (error: Error) => void;
3757
- close: (code: number, reason: string) => void;
3758
- disconnected: () => void;
3759
- reconnecting: (attempt: number) => void;
3760
- }
3761
3798
  /**
3762
3799
  * Base WebSocket client for VALR API
3800
+ * Uses Node.js native EventEmitter (zero dependencies)
3763
3801
  */
3764
- declare abstract class ValrWebSocketClient<TEvents extends WebSocketEvents = WebSocketEvents> extends EventEmitter<TEvents> {
3802
+ declare abstract class ValrWebSocketClient extends EventEmitter {
3765
3803
  protected ws?: WebSocket;
3766
3804
  protected url: string;
3767
3805
  protected path: string;
@@ -3819,19 +3857,6 @@ declare abstract class ValrWebSocketClient<TEvents extends WebSocketEvents = Web
3819
3857
  protected abstract onMessage(message: WebSocketMessage): void;
3820
3858
  }
3821
3859
 
3822
- /**
3823
- * Account WebSocket events (in addition to base events)
3824
- */
3825
- interface AccountWebSocketEvents {
3826
- 'order:processed': (data: OrderProcessed) => void;
3827
- 'order:statusUpdate': (data: OrderStatusUpdate) => void;
3828
- 'balance:update': (data: BalanceUpdate) => void;
3829
- 'trade:new': (data: AccountTrade) => void;
3830
- }
3831
- /**
3832
- * Combined event types for AccountWebSocket
3833
- */
3834
- type AccountWebSocketEventMap = WebSocketEvents & AccountWebSocketEvents;
3835
3860
  /**
3836
3861
  * Account WebSocket client for real-time account updates
3837
3862
  *
@@ -3867,7 +3892,7 @@ type AccountWebSocketEventMap = WebSocketEvents & AccountWebSocketEvents;
3867
3892
  * wsClient.connect();
3868
3893
  * ```
3869
3894
  */
3870
- declare class AccountWebSocket extends ValrWebSocketClient<AccountWebSocketEventMap> {
3895
+ declare class AccountWebSocket extends ValrWebSocketClient {
3871
3896
  constructor(config: WebSocketClientConfig);
3872
3897
  /**
3873
3898
  * Subscribe to specific events
@@ -3891,18 +3916,6 @@ declare class AccountWebSocket extends ValrWebSocketClient<AccountWebSocketEvent
3891
3916
  protected onMessage(message: WebSocketMessage): void;
3892
3917
  }
3893
3918
 
3894
- /**
3895
- * Trade WebSocket events (in addition to base events)
3896
- */
3897
- interface TradeWebSocketEvents {
3898
- 'orderbook:update': (data: OrderBookUpdate) => void;
3899
- 'market:summary': (data: MarketSummaryUpdate) => void;
3900
- 'trade:new': (data: NewTrade) => void;
3901
- }
3902
- /**
3903
- * Combined event types for TradeWebSocket
3904
- */
3905
- type TradeWebSocketEventMap = WebSocketEvents & TradeWebSocketEvents;
3906
3919
  /**
3907
3920
  * Trade WebSocket client for real-time market data
3908
3921
  *
@@ -3934,7 +3947,7 @@ type TradeWebSocketEventMap = WebSocketEvents & TradeWebSocketEvents;
3934
3947
  * wsClient.connect();
3935
3948
  * ```
3936
3949
  */
3937
- declare class TradeWebSocket extends ValrWebSocketClient<TradeWebSocketEventMap> {
3950
+ declare class TradeWebSocket extends ValrWebSocketClient {
3938
3951
  constructor(config?: WebSocketClientConfig);
3939
3952
  /**
3940
3953
  * Subscribe to aggregated order book updates for currency pairs