oilpriceapi 0.8.2 → 0.9.1

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.
Files changed (53) hide show
  1. package/README.md +201 -19
  2. package/dist/cjs/client.js +139 -19
  3. package/dist/cjs/index.js +17 -3
  4. package/dist/cjs/resources/analytics.js +99 -137
  5. package/dist/cjs/resources/bunker-fuels.js +37 -23
  6. package/dist/cjs/resources/data-sources.js +13 -12
  7. package/dist/cjs/resources/ei/frac-focus.js +16 -6
  8. package/dist/cjs/resources/ei/well-permits.js +18 -6
  9. package/dist/cjs/resources/forecasts.js +11 -5
  10. package/dist/cjs/resources/futures.js +244 -16
  11. package/dist/cjs/resources/indicators.js +79 -0
  12. package/dist/cjs/resources/raw.js +128 -0
  13. package/dist/cjs/resources/rig-counts.js +5 -2
  14. package/dist/cjs/resources/spreads.js +105 -0
  15. package/dist/cjs/resources/storage.js +5 -5
  16. package/dist/cjs/resources/streaming.js +350 -0
  17. package/dist/cjs/resources/webhooks.js +3 -14
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/client.d.ts +97 -1
  20. package/dist/client.js +139 -19
  21. package/dist/index.d.ts +12 -3
  22. package/dist/index.js +5 -0
  23. package/dist/resources/analytics.d.ts +147 -214
  24. package/dist/resources/analytics.js +99 -137
  25. package/dist/resources/bunker-fuels.d.ts +35 -12
  26. package/dist/resources/bunker-fuels.js +37 -23
  27. package/dist/resources/data-sources.d.ts +31 -31
  28. package/dist/resources/data-sources.js +13 -12
  29. package/dist/resources/ei/frac-focus.d.ts +23 -9
  30. package/dist/resources/ei/frac-focus.js +16 -6
  31. package/dist/resources/ei/well-permits.d.ts +25 -9
  32. package/dist/resources/ei/well-permits.js +18 -6
  33. package/dist/resources/forecasts.d.ts +4 -1
  34. package/dist/resources/forecasts.js +11 -5
  35. package/dist/resources/futures.d.ts +287 -33
  36. package/dist/resources/futures.js +241 -15
  37. package/dist/resources/indicators.d.ts +170 -0
  38. package/dist/resources/indicators.js +75 -0
  39. package/dist/resources/raw.d.ts +94 -0
  40. package/dist/resources/raw.js +124 -0
  41. package/dist/resources/rig-counts.js +5 -2
  42. package/dist/resources/spreads.d.ts +121 -0
  43. package/dist/resources/spreads.js +101 -0
  44. package/dist/resources/storage.d.ts +5 -4
  45. package/dist/resources/storage.js +5 -5
  46. package/dist/resources/streaming.d.ts +272 -0
  47. package/dist/resources/streaming.js +342 -0
  48. package/dist/resources/webhooks.d.ts +37 -23
  49. package/dist/resources/webhooks.js +3 -14
  50. package/dist/types.d.ts +41 -0
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +7 -1
@@ -5,6 +5,163 @@
5
5
  * OHLC, intraday, spreads, curves, and continuous contracts.
6
6
  */
7
7
  import { ValidationError } from "../errors.js";
8
+ /**
9
+ * Ergonomic contract codes for the most-requested futures families (issue #1).
10
+ *
11
+ * Use with the generic {@link FuturesResource} methods, or use the typed
12
+ * {@link FuturesResource.family} helper for direct access to a family's
13
+ * endpoints.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { FUTURES_CONTRACTS } from 'oilpriceapi';
18
+ *
19
+ * const brent = await client.futures.latest(FUTURES_CONTRACTS.BRENT); // "BZ"
20
+ * const gasoil = await client.futures.family('ice-gasoil').latest();
21
+ * ```
22
+ */
23
+ export const FUTURES_CONTRACTS = {
24
+ /** ICE Brent crude */
25
+ BRENT: "BZ",
26
+ /** NYMEX WTI crude */
27
+ WTI: "CL",
28
+ /** ICE Gasoil */
29
+ GASOIL: "G",
30
+ /** Henry Hub natural gas */
31
+ NATURAL_GAS: "NG",
32
+ /** TTF natural gas (Europe) */
33
+ TTF_GAS: "TTF",
34
+ /** LNG JKM (Asia) */
35
+ LNG_JKM: "JKM",
36
+ /** EU carbon allowance */
37
+ EUA_CARBON: "EUA",
38
+ /** UK carbon allowance */
39
+ UK_CARBON: "UKA",
40
+ };
41
+ /**
42
+ * Mapping of ergonomic contract codes to their API contract-family slugs.
43
+ *
44
+ * Lets you resolve a contract code (e.g., `"BZ"`) to the `/v1/futures/{slug}`
45
+ * path segment used by the typed family helpers.
46
+ */
47
+ export const FUTURES_FAMILY_SLUGS = {
48
+ [FUTURES_CONTRACTS.BRENT]: "ice-brent", // BZ
49
+ [FUTURES_CONTRACTS.WTI]: "ice-wti", // CL
50
+ [FUTURES_CONTRACTS.GASOIL]: "ice-gasoil", // G
51
+ QS: "ice-gasoil", // ICE Gasoil also trades under the QS ticker prefix
52
+ [FUTURES_CONTRACTS.NATURAL_GAS]: "natural-gas", // NG
53
+ [FUTURES_CONTRACTS.TTF_GAS]: "ttf-gas", // TTF
54
+ [FUTURES_CONTRACTS.LNG_JKM]: "lng-jkm", // JKM
55
+ [FUTURES_CONTRACTS.EUA_CARBON]: "eua-carbon", // EUA
56
+ [FUTURES_CONTRACTS.UK_CARBON]: "uk-carbon", // UKA
57
+ };
58
+ /**
59
+ * Resolve a futures contract code (e.g. `"BZ"`, `"QS"`) or an already-valid
60
+ * family slug (e.g. `"ice-brent"`) to its `/v1/futures/{slug}` path segment.
61
+ *
62
+ * Matching is case-insensitive for codes. Returns `null` if the input maps to
63
+ * neither a known code nor a known family slug.
64
+ */
65
+ export function resolveFuturesFamilySlug(codeOrSlug) {
66
+ const trimmed = codeOrSlug.trim();
67
+ // Direct code match (case-insensitive — codes are upper-case).
68
+ const byCode = FUTURES_FAMILY_SLUGS[trimmed.toUpperCase()];
69
+ if (byCode)
70
+ return byCode;
71
+ // Already a valid family slug?
72
+ const lower = trimmed.toLowerCase();
73
+ const isSlug = Object.values(FUTURES_FAMILY_SLUGS).includes(lower);
74
+ return isSlug ? lower : null;
75
+ }
76
+ /**
77
+ * Typed helper for a single futures contract family (e.g., ICE Brent, Gasoil).
78
+ *
79
+ * Provides ergonomic access to the family's endpoints without having to
80
+ * remember the URL slug. Obtain an instance via {@link FuturesResource.family},
81
+ * {@link FuturesResource.brent}, {@link FuturesResource.gasoil}, etc.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const gasoil = client.futures.gasoil();
86
+ * const latest = await gasoil.latest();
87
+ * const curve = await gasoil.curve();
88
+ * ```
89
+ */
90
+ export class FuturesContractFamily {
91
+ constructor(client,
92
+ /** The contract-family slug used in the API path. */
93
+ slug) {
94
+ this.client = client;
95
+ this.slug = slug;
96
+ }
97
+ /**
98
+ * Get the latest price for this contract family.
99
+ *
100
+ * Latest is served from the bare slug path `GET /v1/futures/{slug}` —
101
+ * there is NO `/latest` suffix (that path 404s).
102
+ */
103
+ async latest() {
104
+ return this.client["request"](`/v1/futures/${this.slug}`, {});
105
+ }
106
+ /**
107
+ * Get historical prices for this contract family.
108
+ *
109
+ * @param options - Optional date range filters.
110
+ */
111
+ async historical(options) {
112
+ const params = {};
113
+ if (options?.startDate)
114
+ params.from = options.startDate;
115
+ if (options?.endDate)
116
+ params.to = options.endDate;
117
+ if (options?.interval)
118
+ params.interval = options.interval;
119
+ if (options?.contracts)
120
+ params.contracts = options.contracts;
121
+ const response = await this.client["request"](`/v1/futures/${this.slug}/historical`, params);
122
+ return Array.isArray(response) ? response : response.prices;
123
+ }
124
+ /**
125
+ * Get OHLC data for this contract family.
126
+ *
127
+ * @param options - `{ days, contract, interval }` (the API has no `date` param here).
128
+ */
129
+ async ohlc(options) {
130
+ const params = {};
131
+ if (options?.days !== undefined)
132
+ params.days = options.days.toString();
133
+ if (options?.contract)
134
+ params.contract = options.contract;
135
+ if (options?.interval)
136
+ params.interval = options.interval;
137
+ return this.client["request"](`/v1/futures/${this.slug}/ohlc`, params);
138
+ }
139
+ /**
140
+ * Get intraday price data for this contract family.
141
+ */
142
+ async intraday() {
143
+ return this.client["request"](`/v1/futures/${this.slug}/intraday`, {});
144
+ }
145
+ /**
146
+ * Get the spreads for this contract family.
147
+ */
148
+ async spreads() {
149
+ const response = await this.client["request"](`/v1/futures/${this.slug}/spreads`, {});
150
+ return Array.isArray(response) ? response : response.data;
151
+ }
152
+ /**
153
+ * Get the forward curve for this contract family.
154
+ */
155
+ async curve() {
156
+ return this.client["request"](`/v1/futures/${this.slug}/curve`, {});
157
+ }
158
+ /**
159
+ * Get historical spread data for this contract family.
160
+ */
161
+ async spreadHistory() {
162
+ return this.client["request"](`/v1/futures/${this.slug}/spread-history`, {});
163
+ }
164
+ }
8
165
  /**
9
166
  * Futures Resource
10
167
  *
@@ -17,16 +174,13 @@ import { ValidationError } from "../errors.js";
17
174
  *
18
175
  * const client = new OilPriceAPI({ apiKey: 'your_key' });
19
176
  *
20
- * // Get latest price
21
- * const latest = await client.futures.latest('CL.1');
177
+ * // Get the latest curve by contract code (resolves to GET /v1/futures/ice-wti)
178
+ * const latest = await client.futures.latest('CL');
22
179
  * console.log(`${latest.contract}: $${latest.price}`);
23
180
  *
24
- * // Get OHLC data
25
- * const ohlc = await client.futures.ohlc('CL.1', '2024-01-15');
26
- * console.log(`High: $${ohlc.high}, Low: $${ohlc.low}`);
27
- *
28
- * // Get futures curve
29
- * const curve = await client.futures.curve('CL');
181
+ * // Typed family helpers are the most ergonomic option:
182
+ * const brent = await client.futures.brent().latest();
183
+ * const curve = await client.futures.brent().curve();
30
184
  * curve.curve.forEach(point => {
31
185
  * console.log(`${point.months_out}mo: $${point.price}`);
32
186
  * });
@@ -37,25 +191,42 @@ export class FuturesResource {
37
191
  this.client = client;
38
192
  }
39
193
  /**
40
- * Get latest price for a futures contract
194
+ * Get the latest curve/quote for a futures contract family.
41
195
  *
42
- * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
43
- * @returns Latest futures price data
196
+ * Accepts an ergonomic contract code (e.g. `"BZ"`, `"CL"`, `"QS"`) or a
197
+ * family slug (e.g. `"ice-brent"`). The code is resolved to its family slug
198
+ * and the request is sent to `GET /v1/futures/{slug}` — the bare slug path,
199
+ * with NO `/latest` suffix (the suffixed path 404s).
44
200
  *
45
- * @throws {NotFoundError} If contract not found
201
+ * Supported codes: BZ (Brent), CL (WTI), G/QS (Gasoil), NG (Natural Gas),
202
+ * TTF, JKM, EUA, UKA. Slugs: ice-brent, ice-wti, ice-gasoil, natural-gas,
203
+ * ttf-gas, lng-jkm, eua-carbon, uk-carbon.
204
+ *
205
+ * @param contract - Contract code (e.g. "BZ") or family slug (e.g. "ice-brent").
206
+ * @returns Latest futures price/curve data
207
+ *
208
+ * @throws {ValidationError} If the code/slug is empty or unrecognized.
46
209
  * @throws {OilPriceAPIError} If API request fails
47
210
  *
48
211
  * @example
49
212
  * ```typescript
50
- * const price = await client.futures.latest('CL.1');
51
- * console.log(`WTI Front Month: $${price.price}`);
213
+ * import { FUTURES_CONTRACTS } from 'oilpriceapi';
214
+ * const price = await client.futures.latest(FUTURES_CONTRACTS.BRENT); // "BZ"
215
+ * const wti = await client.futures.latest('ice-wti');
52
216
  * ```
53
217
  */
54
218
  async latest(contract) {
55
219
  if (!contract || typeof contract !== "string") {
56
220
  throw new ValidationError("Contract symbol must be a non-empty string");
57
221
  }
58
- return this.client["request"](`/v1/futures/${contract}`, {});
222
+ const slug = resolveFuturesFamilySlug(contract);
223
+ if (!slug) {
224
+ throw new ValidationError(`Unknown futures contract "${contract}". Use a contract code ` +
225
+ `(BZ, CL, G, QS, NG, TTF, JKM, EUA, UKA) or a family slug ` +
226
+ `(ice-brent, ice-wti, ice-gasoil, natural-gas, ttf-gas, lng-jkm, ` +
227
+ `eua-carbon, uk-carbon).`);
228
+ }
229
+ return this.client["request"](`/v1/futures/${slug}`, {});
59
230
  }
60
231
  /**
61
232
  * Get historical prices for a futures contract
@@ -226,4 +397,59 @@ export class FuturesResource {
226
397
  params.months = months.toString();
227
398
  return this.client["request"](`/v1/futures/${contract}/continuous`, params);
228
399
  }
400
+ /**
401
+ * Get a typed helper for a specific contract family (issue #1).
402
+ *
403
+ * Provides ergonomic access to the ICE Brent / WTI / Gasoil and gas/carbon
404
+ * family endpoints (`/latest`, `/historical`, `/ohlc`, `/intraday`,
405
+ * `/spreads`, `/curve`, `/spread-history`) without remembering the URL slug.
406
+ *
407
+ * @param slug - Contract family slug (e.g., `"ice-brent"`, `"ice-gasoil"`).
408
+ * @returns A {@link FuturesContractFamily} bound to the slug.
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * const brent = client.futures.family('ice-brent');
413
+ * const latest = await brent.latest();
414
+ * const curve = await brent.curve();
415
+ * ```
416
+ */
417
+ family(slug) {
418
+ if (!slug || typeof slug !== "string") {
419
+ throw new ValidationError("Contract family slug must be a non-empty string");
420
+ }
421
+ return new FuturesContractFamily(this.client, slug);
422
+ }
423
+ /** ICE Brent crude futures family helper (issue #1). */
424
+ brent() {
425
+ return this.family("ice-brent");
426
+ }
427
+ /** ICE WTI crude futures family helper. */
428
+ wti() {
429
+ return this.family("ice-wti");
430
+ }
431
+ /** ICE Gasoil futures family helper (issue #1). */
432
+ gasoil() {
433
+ return this.family("ice-gasoil");
434
+ }
435
+ /** Henry Hub natural gas futures family helper. */
436
+ naturalGas() {
437
+ return this.family("natural-gas");
438
+ }
439
+ /** TTF natural gas (Europe) futures family helper. */
440
+ ttfGas() {
441
+ return this.family("ttf-gas");
442
+ }
443
+ /** LNG JKM (Asia) futures family helper. */
444
+ lngJkm() {
445
+ return this.family("lng-jkm");
446
+ }
447
+ /** EU carbon allowance (EUA) futures family helper. */
448
+ euaCarbon() {
449
+ return this.family("eua-carbon");
450
+ }
451
+ /** UK carbon allowance (UKA) futures family helper. */
452
+ ukCarbon() {
453
+ return this.family("uk-carbon");
454
+ }
229
455
  }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Indicators Resource
3
+ *
4
+ * Access derived market indicators and signals: fuel-switching economics,
5
+ * price context, storage analytics, market annotations, CFTC positioning, and
6
+ * congressional energy-sector trades.
7
+ */
8
+ import type { OilPriceAPI } from "../client.js";
9
+ /**
10
+ * Supported indicator types.
11
+ */
12
+ export type IndicatorType = "fuel-switching" | "price-context" | "storage-analytics" | "annotations" | "cftc-positioning" | "congressional-trades";
13
+ /**
14
+ * Fuel-switching economics indicator.
15
+ */
16
+ export interface FuelSwitchingIndicator {
17
+ /** Switching ratio or breakeven value */
18
+ value: number;
19
+ /** Whether switching is economical */
20
+ economical?: boolean;
21
+ /** From fuel (e.g., "gas") */
22
+ from_fuel?: string;
23
+ /** To fuel (e.g., "oil") */
24
+ to_fuel?: string;
25
+ /** Unit */
26
+ unit?: string;
27
+ /** ISO timestamp */
28
+ timestamp: string;
29
+ /** Additional metadata */
30
+ metadata?: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * Price-context indicator (where the current price sits historically).
34
+ */
35
+ export interface PriceContextIndicator {
36
+ /** Commodity code */
37
+ commodity?: string;
38
+ /** Current price */
39
+ price: number;
40
+ /** Percentile vs trailing window */
41
+ percentile?: number;
42
+ /** 52-week high */
43
+ high_52w?: number;
44
+ /** 52-week low */
45
+ low_52w?: number;
46
+ /** ISO timestamp */
47
+ timestamp: string;
48
+ /** Additional metadata */
49
+ metadata?: Record<string, unknown>;
50
+ }
51
+ /**
52
+ * Storage-analytics indicator.
53
+ */
54
+ export interface StorageAnalyticsIndicator {
55
+ /** Storage level */
56
+ level: number;
57
+ /** Capacity utilization percentage */
58
+ capacity_percent?: number;
59
+ /** Days of cover */
60
+ days_of_cover?: number;
61
+ /** Z-score vs 5-year average */
62
+ zscore?: number;
63
+ /** Unit */
64
+ unit?: string;
65
+ /** ISO timestamp */
66
+ timestamp: string;
67
+ /** Additional metadata */
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Market annotation (notable event marker).
72
+ */
73
+ export interface AnnotationIndicator {
74
+ /** Annotation ID */
75
+ id?: string;
76
+ /** Title */
77
+ title: string;
78
+ /** Description */
79
+ description?: string;
80
+ /** Category (e.g., "geopolitical", "supply", "demand") */
81
+ category?: string;
82
+ /** Event date */
83
+ date: string;
84
+ /** Related commodity */
85
+ commodity?: string;
86
+ /** Additional metadata */
87
+ metadata?: Record<string, unknown>;
88
+ }
89
+ /**
90
+ * CFTC positioning indicator (Commitment of Traders).
91
+ */
92
+ export interface CFTCPositioningIndicator {
93
+ /** Market / commodity */
94
+ market?: string;
95
+ /** Managed-money long contracts */
96
+ managed_money_long?: number;
97
+ /** Managed-money short contracts */
98
+ managed_money_short?: number;
99
+ /** Net positioning */
100
+ net_position?: number;
101
+ /** Report date */
102
+ report_date: string;
103
+ /** Additional metadata */
104
+ metadata?: Record<string, unknown>;
105
+ }
106
+ /**
107
+ * Congressional trade indicator (energy-sector disclosures).
108
+ */
109
+ export interface CongressionalTradeIndicator {
110
+ /** Representative or senator name */
111
+ member?: string;
112
+ /** Ticker traded */
113
+ ticker?: string;
114
+ /** Transaction type ("buy" / "sell") */
115
+ transaction_type?: string;
116
+ /** Amount range */
117
+ amount_range?: string;
118
+ /** Transaction date */
119
+ transaction_date: string;
120
+ /** Disclosure date */
121
+ disclosure_date?: string;
122
+ /** Additional metadata */
123
+ metadata?: Record<string, unknown>;
124
+ }
125
+ /**
126
+ * Indicators Resource
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * import { OilPriceAPI } from 'oilpriceapi';
131
+ *
132
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
133
+ *
134
+ * // Fuel-switching economics
135
+ * const fs = await client.indicators.fuelSwitching();
136
+ * console.log(`Switching economical: ${fs.economical}`);
137
+ *
138
+ * // CFTC positioning
139
+ * const cftc = await client.indicators.cftcPositioning();
140
+ * cftc.forEach(p => console.log(`${p.market}: net ${p.net_position}`));
141
+ *
142
+ * // Congressional trades
143
+ * const trades = await client.indicators.congressionalTrades();
144
+ * ```
145
+ */
146
+ export declare class IndicatorsResource {
147
+ private client;
148
+ constructor(client: OilPriceAPI);
149
+ /**
150
+ * Get an arbitrary indicator by type.
151
+ *
152
+ * @typeParam T - Expected response type.
153
+ * @param type - Indicator type slug.
154
+ * @returns The indicator data.
155
+ * @throws {ValidationError} If the type is invalid.
156
+ */
157
+ get<T = unknown>(type: IndicatorType): Promise<T>;
158
+ /** Fuel-switching economics indicator. */
159
+ fuelSwitching(): Promise<FuelSwitchingIndicator>;
160
+ /** Price-context indicator. */
161
+ priceContext(): Promise<PriceContextIndicator>;
162
+ /** Storage-analytics indicator. */
163
+ storageAnalytics(): Promise<StorageAnalyticsIndicator>;
164
+ /** Market annotations. */
165
+ annotations(): Promise<AnnotationIndicator[]>;
166
+ /** CFTC positioning (Commitment of Traders) indicators. */
167
+ cftcPositioning(): Promise<CFTCPositioningIndicator[]>;
168
+ /** Congressional energy-sector trade indicators. */
169
+ congressionalTrades(): Promise<CongressionalTradeIndicator[]>;
170
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Indicators Resource
3
+ *
4
+ * Access derived market indicators and signals: fuel-switching economics,
5
+ * price context, storage analytics, market annotations, CFTC positioning, and
6
+ * congressional energy-sector trades.
7
+ */
8
+ import { ValidationError } from "../errors.js";
9
+ /**
10
+ * Indicators Resource
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { OilPriceAPI } from 'oilpriceapi';
15
+ *
16
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
17
+ *
18
+ * // Fuel-switching economics
19
+ * const fs = await client.indicators.fuelSwitching();
20
+ * console.log(`Switching economical: ${fs.economical}`);
21
+ *
22
+ * // CFTC positioning
23
+ * const cftc = await client.indicators.cftcPositioning();
24
+ * cftc.forEach(p => console.log(`${p.market}: net ${p.net_position}`));
25
+ *
26
+ * // Congressional trades
27
+ * const trades = await client.indicators.congressionalTrades();
28
+ * ```
29
+ */
30
+ export class IndicatorsResource {
31
+ constructor(client) {
32
+ this.client = client;
33
+ }
34
+ /**
35
+ * Get an arbitrary indicator by type.
36
+ *
37
+ * @typeParam T - Expected response type.
38
+ * @param type - Indicator type slug.
39
+ * @returns The indicator data.
40
+ * @throws {ValidationError} If the type is invalid.
41
+ */
42
+ async get(type) {
43
+ if (!type || typeof type !== "string") {
44
+ throw new ValidationError("Indicator type must be a non-empty string");
45
+ }
46
+ return this.client["request"](`/v1/indicators/${type}`, {});
47
+ }
48
+ /** Fuel-switching economics indicator. */
49
+ async fuelSwitching() {
50
+ return this.get("fuel-switching");
51
+ }
52
+ /** Price-context indicator. */
53
+ async priceContext() {
54
+ return this.get("price-context");
55
+ }
56
+ /** Storage-analytics indicator. */
57
+ async storageAnalytics() {
58
+ return this.get("storage-analytics");
59
+ }
60
+ /** Market annotations. */
61
+ async annotations() {
62
+ const response = await this.client["request"]("/v1/indicators/annotations", {});
63
+ return Array.isArray(response) ? response : response.data;
64
+ }
65
+ /** CFTC positioning (Commitment of Traders) indicators. */
66
+ async cftcPositioning() {
67
+ const response = await this.client["request"]("/v1/indicators/cftc-positioning", {});
68
+ return Array.isArray(response) ? response : response.data;
69
+ }
70
+ /** Congressional energy-sector trade indicators. */
71
+ async congressionalTrades() {
72
+ const response = await this.client["request"]("/v1/indicators/congressional-trades", {});
73
+ return Array.isArray(response) ? response : response.data;
74
+ }
75
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Raw Response Resource
3
+ *
4
+ * Provides opt-in access to the underlying HTTP status code and response
5
+ * headers alongside the parsed data. Mirrors the most commonly used top-level
6
+ * client methods. This is the #1 requested enhancement (issue #7).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { OilPriceAPI } from 'oilpriceapi';
11
+ *
12
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
13
+ *
14
+ * const { data, status, headers } = await client.raw.getLatestPrices();
15
+ * console.log(`HTTP ${status}`);
16
+ * console.log(`Rate limit remaining: ${headers.get('x-ratelimit-remaining')}`);
17
+ * console.log(data[0].price);
18
+ * ```
19
+ */
20
+ import type { OilPriceAPI, APIResponse } from "../client.js";
21
+ import type { Price, LatestPricesOptions, HistoricalPricesOptions, Commodity, CommoditiesResponse, CategoriesResponse } from "../types.js";
22
+ /**
23
+ * Raw Response Resource
24
+ *
25
+ * Each method returns an {@link APIResponse} with `{ data, status, headers }`
26
+ * instead of just the parsed data, so callers can inspect HTTP metadata such
27
+ * as rate-limit headers, caching headers, and the exact status code.
28
+ */
29
+ export declare class RawResource {
30
+ private client;
31
+ constructor(client: OilPriceAPI);
32
+ /**
33
+ * Make an arbitrary GET request and return data plus HTTP status and headers.
34
+ *
35
+ * Use this for endpoints without a dedicated raw helper.
36
+ *
37
+ * @typeParam T - Expected parsed response type.
38
+ * @param endpoint - API path beginning with `/` (e.g. `/v1/prices/latest`).
39
+ * @param params - Optional query parameters.
40
+ * @returns The parsed data along with the HTTP status code and headers.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const { data, status, headers } = await client.raw.get('/v1/futures/CL.1');
45
+ * ```
46
+ */
47
+ get<T = unknown>(endpoint: string, params?: Record<string, string>): Promise<APIResponse<T>>;
48
+ /**
49
+ * Latest prices with raw HTTP status and headers.
50
+ *
51
+ * @param options - Optional commodity filter.
52
+ * @returns Prices array with HTTP status and headers.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const { data, status, headers } = await client.raw.getLatestPrices({ commodity: 'WTI_USD' });
57
+ * ```
58
+ */
59
+ getLatestPrices(options?: LatestPricesOptions): Promise<APIResponse<Price[]>>;
60
+ /**
61
+ * Historical prices with raw HTTP status and headers.
62
+ *
63
+ * @param options - Time period and filter options.
64
+ * @returns Prices array with HTTP status and headers.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const { data, status, headers } = await client.raw.getHistoricalPrices({
69
+ * period: 'past_week',
70
+ * commodity: 'BRENT_CRUDE_USD',
71
+ * });
72
+ * ```
73
+ */
74
+ getHistoricalPrices(options?: HistoricalPricesOptions): Promise<APIResponse<Price[]>>;
75
+ /**
76
+ * Commodities metadata with raw HTTP status and headers.
77
+ *
78
+ * @returns Commodities response with HTTP status and headers.
79
+ */
80
+ getCommodities(): Promise<APIResponse<CommoditiesResponse>>;
81
+ /**
82
+ * Commodity categories with raw HTTP status and headers.
83
+ *
84
+ * @returns Categories response with HTTP status and headers.
85
+ */
86
+ getCommodityCategories(): Promise<APIResponse<CategoriesResponse>>;
87
+ /**
88
+ * A single commodity's metadata with raw HTTP status and headers.
89
+ *
90
+ * @param code - Commodity code (e.g., "WTI_USD").
91
+ * @returns Commodity with HTTP status and headers.
92
+ */
93
+ getCommodity(code: string): Promise<APIResponse<Commodity>>;
94
+ }