openfigi-sdk 1.0.3
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/LICENSE +19 -0
- package/README.md +239 -0
- package/dist/index.cjs +434 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +352 -0
- package/dist/index.d.ts +352 -0
- package/dist/index.js +405 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type IdType = 'ID_ISIN' | 'ID_BB_UNIQUE' | 'ID_SEDOL' | 'ID_COMMON' | 'ID_WERTPAPIER' | 'ID_CUSIP' | 'ID_BB' | 'ID_ITALY' | 'ID_EXCH_SYMBOL' | 'ID_FULL_EXCHANGE_SYMBOL' | 'COMPOSITE_ID_BB_GLOBAL' | 'ID_BB_GLOBAL_SHARE_CLASS_LEVEL' | 'ID_BB_GLOBAL' | 'ID_BB_SEC_NUM_DES' | 'ID_BB_SEC_NUM' | 'ID_CINS' | 'ID_BELGIUM' | 'ID_DENMARK' | 'ID_FRANCE' | 'ID_JAPAN' | 'ID_LUXEMBOURG' | 'ID_NETHERLANDS' | 'ID_POLAND' | 'ID_PORTUGAL' | 'ID_SWEDEN' | 'ID_SHORT_CODE';
|
|
4
|
+
type SecurityType = 'Common Stock' | 'Preference' | 'ADR' | 'Open-End Fund' | 'Closed-End Fund' | 'ETF' | 'ETN' | 'Unit' | 'Mutual Fund' | 'Money Market' | 'Commodity' | 'Currency' | 'Option' | 'Index';
|
|
5
|
+
type MarketSector = 'All' | 'Comdty' | 'Curncy' | 'Equity' | 'Govt' | 'Corp' | 'Index' | 'Money' | 'Mtge' | 'Muni' | 'Pref';
|
|
6
|
+
interface MappingRequest {
|
|
7
|
+
idType: IdType;
|
|
8
|
+
idValue: string;
|
|
9
|
+
exchCode?: string;
|
|
10
|
+
micCode?: string;
|
|
11
|
+
currency?: string;
|
|
12
|
+
marketSecDes?: MarketSector;
|
|
13
|
+
securityType?: SecurityType;
|
|
14
|
+
securityType2?: string;
|
|
15
|
+
includeUnlistedEquities?: boolean;
|
|
16
|
+
optionType?: 'Put' | 'Call';
|
|
17
|
+
strike?: number[];
|
|
18
|
+
contractSize?: number;
|
|
19
|
+
coupon?: number[];
|
|
20
|
+
expiration?: number[];
|
|
21
|
+
maturity?: number[];
|
|
22
|
+
stateCode?: string;
|
|
23
|
+
}
|
|
24
|
+
interface FigiResult {
|
|
25
|
+
figi: string;
|
|
26
|
+
securityType?: SecurityType;
|
|
27
|
+
marketSector?: MarketSector;
|
|
28
|
+
ticker?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
exchCode?: string;
|
|
31
|
+
shareClassFIGI?: string;
|
|
32
|
+
compositeFIGI?: string;
|
|
33
|
+
securityType2?: string;
|
|
34
|
+
securityDescription?: string;
|
|
35
|
+
metadata?: string;
|
|
36
|
+
}
|
|
37
|
+
interface MappingResponse {
|
|
38
|
+
data?: FigiResult[];
|
|
39
|
+
warning?: string;
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
interface ApiError {
|
|
43
|
+
error: string;
|
|
44
|
+
message?: string;
|
|
45
|
+
statusCode?: number;
|
|
46
|
+
}
|
|
47
|
+
interface RateLimitInfo {
|
|
48
|
+
limit: number;
|
|
49
|
+
remaining: number;
|
|
50
|
+
reset: Date;
|
|
51
|
+
}
|
|
52
|
+
interface ClientConfig {
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
retryLimit?: number;
|
|
57
|
+
retryDelay?: number;
|
|
58
|
+
userAgent?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Enable or disable debug logging
|
|
63
|
+
* @param enabled - Whether to enable debug mode
|
|
64
|
+
*/
|
|
65
|
+
declare const setDebugMode: (enabled: boolean) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Creates an OpenFIGI client with custom configuration
|
|
68
|
+
*
|
|
69
|
+
* @param config - Client configuration options
|
|
70
|
+
* @returns An OpenFIGI client instance with all available methods
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const client = createClient({
|
|
75
|
+
* apiKey: 'your-api-key',
|
|
76
|
+
* timeout: 60000
|
|
77
|
+
* })
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare const createClient: (config?: ClientConfig) => {
|
|
81
|
+
mapping: (requests: MappingRequest[]) => Promise<MappingResponse[]>;
|
|
82
|
+
mappingSingle: (request: MappingRequest) => Promise<MappingResponse>;
|
|
83
|
+
searchByISIN: (isin: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
84
|
+
searchByCUSIP: (cusip: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
85
|
+
searchBySEDOL: (sedol: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
86
|
+
searchByTicker: (ticker: string, exchCode?: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
87
|
+
searchByBloombergId: (bbgId: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
88
|
+
getRateLimitInfo: () => RateLimitInfo | undefined;
|
|
89
|
+
};
|
|
90
|
+
declare const mapping: (requests: MappingRequest[]) => Promise<MappingResponse[]>;
|
|
91
|
+
declare const mappingSingle: (request: MappingRequest) => Promise<MappingResponse>;
|
|
92
|
+
declare const searchByISIN: (isin: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
93
|
+
declare const searchByCUSIP: (cusip: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
94
|
+
declare const searchBySEDOL: (sedol: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
95
|
+
declare const searchByTicker: (ticker: string, exchCode?: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
96
|
+
declare const searchByBloombergId: (bbgId: string, options?: Partial<MappingRequest>) => Promise<MappingResponse>;
|
|
97
|
+
declare const getRateLimitInfo: () => RateLimitInfo | undefined;
|
|
98
|
+
|
|
99
|
+
declare class OpenFigiError extends Error {
|
|
100
|
+
statusCode?: number | undefined;
|
|
101
|
+
response?: unknown | undefined;
|
|
102
|
+
constructor(message: string, statusCode?: number | undefined, response?: unknown | undefined);
|
|
103
|
+
}
|
|
104
|
+
declare class RateLimitError extends OpenFigiError {
|
|
105
|
+
retryAfter?: number | undefined;
|
|
106
|
+
constructor(message: string, retryAfter?: number | undefined, statusCode?: number);
|
|
107
|
+
}
|
|
108
|
+
declare class ValidationError extends OpenFigiError {
|
|
109
|
+
errors?: unknown | undefined;
|
|
110
|
+
constructor(message: string, errors?: unknown | undefined);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Validate ISIN format (12 characters, alphanumeric)
|
|
115
|
+
*/
|
|
116
|
+
declare const isValidISIN: (isin: string) => boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Validate CUSIP format (9 characters, alphanumeric)
|
|
119
|
+
*/
|
|
120
|
+
declare const isValidCUSIP: (cusip: string) => boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Validate SEDOL format (7 characters, alphanumeric)
|
|
123
|
+
*/
|
|
124
|
+
declare const isValidSEDOL: (sedol: string) => boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Validate Bloomberg ID format (starts with BBG)
|
|
127
|
+
*/
|
|
128
|
+
declare const isValidBloombergId: (bbgId: string) => boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Split array into batches of specified size
|
|
131
|
+
* Useful for splitting large arrays for batch processing
|
|
132
|
+
*/
|
|
133
|
+
declare const batchArray: <T>(array: T[], batchSize: number) => T[][];
|
|
134
|
+
|
|
135
|
+
declare const IdTypeSchema: z.ZodEnum<{
|
|
136
|
+
ID_ISIN: "ID_ISIN";
|
|
137
|
+
ID_BB_UNIQUE: "ID_BB_UNIQUE";
|
|
138
|
+
ID_SEDOL: "ID_SEDOL";
|
|
139
|
+
ID_COMMON: "ID_COMMON";
|
|
140
|
+
ID_WERTPAPIER: "ID_WERTPAPIER";
|
|
141
|
+
ID_CUSIP: "ID_CUSIP";
|
|
142
|
+
ID_BB: "ID_BB";
|
|
143
|
+
ID_ITALY: "ID_ITALY";
|
|
144
|
+
ID_EXCH_SYMBOL: "ID_EXCH_SYMBOL";
|
|
145
|
+
ID_FULL_EXCHANGE_SYMBOL: "ID_FULL_EXCHANGE_SYMBOL";
|
|
146
|
+
COMPOSITE_ID_BB_GLOBAL: "COMPOSITE_ID_BB_GLOBAL";
|
|
147
|
+
ID_BB_GLOBAL_SHARE_CLASS_LEVEL: "ID_BB_GLOBAL_SHARE_CLASS_LEVEL";
|
|
148
|
+
ID_BB_GLOBAL: "ID_BB_GLOBAL";
|
|
149
|
+
ID_BB_SEC_NUM_DES: "ID_BB_SEC_NUM_DES";
|
|
150
|
+
ID_BB_SEC_NUM: "ID_BB_SEC_NUM";
|
|
151
|
+
ID_CINS: "ID_CINS";
|
|
152
|
+
ID_BELGIUM: "ID_BELGIUM";
|
|
153
|
+
ID_DENMARK: "ID_DENMARK";
|
|
154
|
+
ID_FRANCE: "ID_FRANCE";
|
|
155
|
+
ID_JAPAN: "ID_JAPAN";
|
|
156
|
+
ID_LUXEMBOURG: "ID_LUXEMBOURG";
|
|
157
|
+
ID_NETHERLANDS: "ID_NETHERLANDS";
|
|
158
|
+
ID_POLAND: "ID_POLAND";
|
|
159
|
+
ID_PORTUGAL: "ID_PORTUGAL";
|
|
160
|
+
ID_SWEDEN: "ID_SWEDEN";
|
|
161
|
+
ID_SHORT_CODE: "ID_SHORT_CODE";
|
|
162
|
+
}>;
|
|
163
|
+
declare const SecurityTypeSchema: z.ZodEnum<{
|
|
164
|
+
"Common Stock": "Common Stock";
|
|
165
|
+
Preference: "Preference";
|
|
166
|
+
ADR: "ADR";
|
|
167
|
+
"Open-End Fund": "Open-End Fund";
|
|
168
|
+
"Closed-End Fund": "Closed-End Fund";
|
|
169
|
+
ETF: "ETF";
|
|
170
|
+
ETN: "ETN";
|
|
171
|
+
Unit: "Unit";
|
|
172
|
+
"Mutual Fund": "Mutual Fund";
|
|
173
|
+
"Money Market": "Money Market";
|
|
174
|
+
Commodity: "Commodity";
|
|
175
|
+
Currency: "Currency";
|
|
176
|
+
Option: "Option";
|
|
177
|
+
Index: "Index";
|
|
178
|
+
}>;
|
|
179
|
+
declare const MarketSectorSchema: z.ZodEnum<{
|
|
180
|
+
Index: "Index";
|
|
181
|
+
All: "All";
|
|
182
|
+
Comdty: "Comdty";
|
|
183
|
+
Curncy: "Curncy";
|
|
184
|
+
Equity: "Equity";
|
|
185
|
+
Govt: "Govt";
|
|
186
|
+
Corp: "Corp";
|
|
187
|
+
Money: "Money";
|
|
188
|
+
Mtge: "Mtge";
|
|
189
|
+
Muni: "Muni";
|
|
190
|
+
Pref: "Pref";
|
|
191
|
+
}>;
|
|
192
|
+
declare const MappingRequestSchema: z.ZodObject<{
|
|
193
|
+
idType: z.ZodEnum<{
|
|
194
|
+
ID_ISIN: "ID_ISIN";
|
|
195
|
+
ID_BB_UNIQUE: "ID_BB_UNIQUE";
|
|
196
|
+
ID_SEDOL: "ID_SEDOL";
|
|
197
|
+
ID_COMMON: "ID_COMMON";
|
|
198
|
+
ID_WERTPAPIER: "ID_WERTPAPIER";
|
|
199
|
+
ID_CUSIP: "ID_CUSIP";
|
|
200
|
+
ID_BB: "ID_BB";
|
|
201
|
+
ID_ITALY: "ID_ITALY";
|
|
202
|
+
ID_EXCH_SYMBOL: "ID_EXCH_SYMBOL";
|
|
203
|
+
ID_FULL_EXCHANGE_SYMBOL: "ID_FULL_EXCHANGE_SYMBOL";
|
|
204
|
+
COMPOSITE_ID_BB_GLOBAL: "COMPOSITE_ID_BB_GLOBAL";
|
|
205
|
+
ID_BB_GLOBAL_SHARE_CLASS_LEVEL: "ID_BB_GLOBAL_SHARE_CLASS_LEVEL";
|
|
206
|
+
ID_BB_GLOBAL: "ID_BB_GLOBAL";
|
|
207
|
+
ID_BB_SEC_NUM_DES: "ID_BB_SEC_NUM_DES";
|
|
208
|
+
ID_BB_SEC_NUM: "ID_BB_SEC_NUM";
|
|
209
|
+
ID_CINS: "ID_CINS";
|
|
210
|
+
ID_BELGIUM: "ID_BELGIUM";
|
|
211
|
+
ID_DENMARK: "ID_DENMARK";
|
|
212
|
+
ID_FRANCE: "ID_FRANCE";
|
|
213
|
+
ID_JAPAN: "ID_JAPAN";
|
|
214
|
+
ID_LUXEMBOURG: "ID_LUXEMBOURG";
|
|
215
|
+
ID_NETHERLANDS: "ID_NETHERLANDS";
|
|
216
|
+
ID_POLAND: "ID_POLAND";
|
|
217
|
+
ID_PORTUGAL: "ID_PORTUGAL";
|
|
218
|
+
ID_SWEDEN: "ID_SWEDEN";
|
|
219
|
+
ID_SHORT_CODE: "ID_SHORT_CODE";
|
|
220
|
+
}>;
|
|
221
|
+
idValue: z.ZodString;
|
|
222
|
+
exchCode: z.ZodOptional<z.ZodString>;
|
|
223
|
+
micCode: z.ZodOptional<z.ZodString>;
|
|
224
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
225
|
+
marketSecDes: z.ZodOptional<z.ZodEnum<{
|
|
226
|
+
Index: "Index";
|
|
227
|
+
All: "All";
|
|
228
|
+
Comdty: "Comdty";
|
|
229
|
+
Curncy: "Curncy";
|
|
230
|
+
Equity: "Equity";
|
|
231
|
+
Govt: "Govt";
|
|
232
|
+
Corp: "Corp";
|
|
233
|
+
Money: "Money";
|
|
234
|
+
Mtge: "Mtge";
|
|
235
|
+
Muni: "Muni";
|
|
236
|
+
Pref: "Pref";
|
|
237
|
+
}>>;
|
|
238
|
+
securityType: z.ZodOptional<z.ZodEnum<{
|
|
239
|
+
"Common Stock": "Common Stock";
|
|
240
|
+
Preference: "Preference";
|
|
241
|
+
ADR: "ADR";
|
|
242
|
+
"Open-End Fund": "Open-End Fund";
|
|
243
|
+
"Closed-End Fund": "Closed-End Fund";
|
|
244
|
+
ETF: "ETF";
|
|
245
|
+
ETN: "ETN";
|
|
246
|
+
Unit: "Unit";
|
|
247
|
+
"Mutual Fund": "Mutual Fund";
|
|
248
|
+
"Money Market": "Money Market";
|
|
249
|
+
Commodity: "Commodity";
|
|
250
|
+
Currency: "Currency";
|
|
251
|
+
Option: "Option";
|
|
252
|
+
Index: "Index";
|
|
253
|
+
}>>;
|
|
254
|
+
securityType2: z.ZodOptional<z.ZodString>;
|
|
255
|
+
includeUnlistedEquities: z.ZodOptional<z.ZodBoolean>;
|
|
256
|
+
optionType: z.ZodOptional<z.ZodEnum<{
|
|
257
|
+
Put: "Put";
|
|
258
|
+
Call: "Call";
|
|
259
|
+
}>>;
|
|
260
|
+
strike: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
261
|
+
contractSize: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
coupon: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
263
|
+
expiration: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
264
|
+
maturity: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
265
|
+
stateCode: z.ZodOptional<z.ZodString>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
declare const FigiResultSchema: z.ZodObject<{
|
|
268
|
+
figi: z.ZodString;
|
|
269
|
+
securityType: z.ZodOptional<z.ZodEnum<{
|
|
270
|
+
"Common Stock": "Common Stock";
|
|
271
|
+
Preference: "Preference";
|
|
272
|
+
ADR: "ADR";
|
|
273
|
+
"Open-End Fund": "Open-End Fund";
|
|
274
|
+
"Closed-End Fund": "Closed-End Fund";
|
|
275
|
+
ETF: "ETF";
|
|
276
|
+
ETN: "ETN";
|
|
277
|
+
Unit: "Unit";
|
|
278
|
+
"Mutual Fund": "Mutual Fund";
|
|
279
|
+
"Money Market": "Money Market";
|
|
280
|
+
Commodity: "Commodity";
|
|
281
|
+
Currency: "Currency";
|
|
282
|
+
Option: "Option";
|
|
283
|
+
Index: "Index";
|
|
284
|
+
}>>;
|
|
285
|
+
marketSector: z.ZodOptional<z.ZodEnum<{
|
|
286
|
+
Index: "Index";
|
|
287
|
+
All: "All";
|
|
288
|
+
Comdty: "Comdty";
|
|
289
|
+
Curncy: "Curncy";
|
|
290
|
+
Equity: "Equity";
|
|
291
|
+
Govt: "Govt";
|
|
292
|
+
Corp: "Corp";
|
|
293
|
+
Money: "Money";
|
|
294
|
+
Mtge: "Mtge";
|
|
295
|
+
Muni: "Muni";
|
|
296
|
+
Pref: "Pref";
|
|
297
|
+
}>>;
|
|
298
|
+
ticker: z.ZodOptional<z.ZodString>;
|
|
299
|
+
name: z.ZodOptional<z.ZodString>;
|
|
300
|
+
exchCode: z.ZodOptional<z.ZodString>;
|
|
301
|
+
shareClassFIGI: z.ZodOptional<z.ZodString>;
|
|
302
|
+
compositeFIGI: z.ZodOptional<z.ZodString>;
|
|
303
|
+
securityType2: z.ZodOptional<z.ZodString>;
|
|
304
|
+
securityDescription: z.ZodOptional<z.ZodString>;
|
|
305
|
+
metadata: z.ZodOptional<z.ZodString>;
|
|
306
|
+
}, z.core.$strip>;
|
|
307
|
+
declare const MappingResponseSchema: z.ZodObject<{
|
|
308
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
309
|
+
figi: z.ZodString;
|
|
310
|
+
securityType: z.ZodOptional<z.ZodEnum<{
|
|
311
|
+
"Common Stock": "Common Stock";
|
|
312
|
+
Preference: "Preference";
|
|
313
|
+
ADR: "ADR";
|
|
314
|
+
"Open-End Fund": "Open-End Fund";
|
|
315
|
+
"Closed-End Fund": "Closed-End Fund";
|
|
316
|
+
ETF: "ETF";
|
|
317
|
+
ETN: "ETN";
|
|
318
|
+
Unit: "Unit";
|
|
319
|
+
"Mutual Fund": "Mutual Fund";
|
|
320
|
+
"Money Market": "Money Market";
|
|
321
|
+
Commodity: "Commodity";
|
|
322
|
+
Currency: "Currency";
|
|
323
|
+
Option: "Option";
|
|
324
|
+
Index: "Index";
|
|
325
|
+
}>>;
|
|
326
|
+
marketSector: z.ZodOptional<z.ZodEnum<{
|
|
327
|
+
Index: "Index";
|
|
328
|
+
All: "All";
|
|
329
|
+
Comdty: "Comdty";
|
|
330
|
+
Curncy: "Curncy";
|
|
331
|
+
Equity: "Equity";
|
|
332
|
+
Govt: "Govt";
|
|
333
|
+
Corp: "Corp";
|
|
334
|
+
Money: "Money";
|
|
335
|
+
Mtge: "Mtge";
|
|
336
|
+
Muni: "Muni";
|
|
337
|
+
Pref: "Pref";
|
|
338
|
+
}>>;
|
|
339
|
+
ticker: z.ZodOptional<z.ZodString>;
|
|
340
|
+
name: z.ZodOptional<z.ZodString>;
|
|
341
|
+
exchCode: z.ZodOptional<z.ZodString>;
|
|
342
|
+
shareClassFIGI: z.ZodOptional<z.ZodString>;
|
|
343
|
+
compositeFIGI: z.ZodOptional<z.ZodString>;
|
|
344
|
+
securityType2: z.ZodOptional<z.ZodString>;
|
|
345
|
+
securityDescription: z.ZodOptional<z.ZodString>;
|
|
346
|
+
metadata: z.ZodOptional<z.ZodString>;
|
|
347
|
+
}, z.core.$strip>>>;
|
|
348
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
349
|
+
error: z.ZodOptional<z.ZodString>;
|
|
350
|
+
}, z.core.$strip>;
|
|
351
|
+
|
|
352
|
+
export { type ApiError, type ClientConfig, type FigiResult, FigiResultSchema, type IdType, IdTypeSchema, type MappingRequest, MappingRequestSchema, type MappingResponse, MappingResponseSchema, type MarketSector, MarketSectorSchema, OpenFigiError, RateLimitError, type RateLimitInfo, type SecurityType, SecurityTypeSchema, ValidationError, batchArray, createClient, getRateLimitInfo, isValidBloombergId, isValidCUSIP, isValidISIN, isValidSEDOL, mapping, mappingSingle, searchByBloombergId, searchByCUSIP, searchByISIN, searchBySEDOL, searchByTicker, setDebugMode };
|