oilpriceapi 0.6.0 → 0.8.2

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 (80) hide show
  1. package/README.md +418 -123
  2. package/dist/cjs/client.js +490 -0
  3. package/dist/cjs/errors.js +80 -0
  4. package/dist/cjs/index.js +82 -0
  5. package/dist/cjs/package.json +1 -0
  6. package/dist/cjs/resources/alerts.js +387 -0
  7. package/dist/cjs/resources/analytics.js +226 -0
  8. package/dist/cjs/resources/bunker-fuels.js +196 -0
  9. package/dist/cjs/resources/commodities.js +115 -0
  10. package/dist/cjs/resources/data-quality.js +144 -0
  11. package/dist/cjs/resources/data-sources.js +297 -0
  12. package/dist/cjs/resources/diesel.js +119 -0
  13. package/dist/cjs/resources/drilling.js +269 -0
  14. package/dist/cjs/resources/ei/drilling-productivity.js +108 -0
  15. package/dist/cjs/resources/ei/forecasts.js +106 -0
  16. package/dist/cjs/resources/ei/frac-focus.js +155 -0
  17. package/dist/cjs/resources/ei/index.js +98 -0
  18. package/dist/cjs/resources/ei/oil-inventories.js +97 -0
  19. package/dist/cjs/resources/ei/opec-production.js +97 -0
  20. package/dist/cjs/resources/ei/rig-counts.js +93 -0
  21. package/dist/cjs/resources/ei/well-permits.js +124 -0
  22. package/dist/cjs/resources/forecasts.js +162 -0
  23. package/dist/cjs/resources/futures.js +233 -0
  24. package/dist/cjs/resources/rig-counts.js +161 -0
  25. package/dist/cjs/resources/storage.js +166 -0
  26. package/dist/cjs/resources/webhooks.js +294 -0
  27. package/dist/cjs/types.js +2 -0
  28. package/dist/cjs/version.js +24 -0
  29. package/dist/client.d.ts +116 -5
  30. package/dist/client.js +169 -47
  31. package/dist/errors.d.ts +6 -0
  32. package/dist/errors.js +25 -16
  33. package/dist/index.d.ts +45 -6
  34. package/dist/index.js +40 -3
  35. package/dist/resources/alerts.d.ts +52 -15
  36. package/dist/resources/alerts.js +121 -109
  37. package/dist/resources/analytics.d.ts +325 -0
  38. package/dist/resources/analytics.js +222 -0
  39. package/dist/resources/bunker-fuels.d.ts +270 -0
  40. package/dist/resources/bunker-fuels.js +192 -0
  41. package/dist/resources/commodities.d.ts +148 -0
  42. package/dist/resources/commodities.js +111 -0
  43. package/dist/resources/data-quality.d.ts +229 -0
  44. package/dist/resources/data-quality.js +140 -0
  45. package/dist/resources/data-sources.d.ts +365 -0
  46. package/dist/resources/data-sources.js +293 -0
  47. package/dist/resources/diesel.d.ts +1 -1
  48. package/dist/resources/diesel.js +9 -38
  49. package/dist/resources/drilling.d.ts +403 -0
  50. package/dist/resources/drilling.js +265 -0
  51. package/dist/resources/ei/drilling-productivity.d.ts +173 -0
  52. package/dist/resources/ei/drilling-productivity.js +104 -0
  53. package/dist/resources/ei/forecasts.d.ts +177 -0
  54. package/dist/resources/ei/forecasts.js +102 -0
  55. package/dist/resources/ei/frac-focus.d.ts +212 -0
  56. package/dist/resources/ei/frac-focus.js +151 -0
  57. package/dist/resources/ei/index.d.ts +140 -0
  58. package/dist/resources/ei/index.js +88 -0
  59. package/dist/resources/ei/oil-inventories.d.ts +155 -0
  60. package/dist/resources/ei/oil-inventories.js +93 -0
  61. package/dist/resources/ei/opec-production.d.ts +146 -0
  62. package/dist/resources/ei/opec-production.js +93 -0
  63. package/dist/resources/ei/rig-counts.d.ts +131 -0
  64. package/dist/resources/ei/rig-counts.js +89 -0
  65. package/dist/resources/ei/well-permits.d.ts +178 -0
  66. package/dist/resources/ei/well-permits.js +120 -0
  67. package/dist/resources/forecasts.d.ts +200 -0
  68. package/dist/resources/forecasts.js +158 -0
  69. package/dist/resources/futures.d.ts +322 -0
  70. package/dist/resources/futures.js +229 -0
  71. package/dist/resources/rig-counts.d.ts +221 -0
  72. package/dist/resources/rig-counts.js +157 -0
  73. package/dist/resources/storage.d.ts +182 -0
  74. package/dist/resources/storage.js +162 -0
  75. package/dist/resources/webhooks.d.ts +326 -0
  76. package/dist/resources/webhooks.js +290 -0
  77. package/dist/types.d.ts +79 -8
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +2 -2
  80. package/package.json +17 -8
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Energy Intelligence - Rig Counts Resource
4
+ *
5
+ * Access Baker Hughes rig count data with basin, state, and historical breakdowns.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.EIRigCountsResource = void 0;
9
+ const errors_js_1 = require("../../errors.js");
10
+ /**
11
+ * EI Rig Counts Resource
12
+ *
13
+ * Access Baker Hughes rig count data with comprehensive breakdowns.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
18
+ *
19
+ * // Get latest rig count
20
+ * const latest = await client.ei.rigCounts.latest();
21
+ * console.log(`Total rigs: ${latest.total_rigs}`);
22
+ *
23
+ * // Get by basin
24
+ * const basins = await client.ei.rigCounts.byBasin();
25
+ * basins.forEach(b => console.log(`${b.basin}: ${b.rig_count} rigs`));
26
+ * ```
27
+ */
28
+ class EIRigCountsResource {
29
+ constructor(client) {
30
+ this.client = client;
31
+ }
32
+ /**
33
+ * List all rig count records
34
+ *
35
+ * @returns Array of rig count records
36
+ *
37
+ * @throws {OilPriceAPIError} If API request fails
38
+ */
39
+ async list() {
40
+ const response = await this.client["request"]("/v1/ei/rig_counts", {});
41
+ return Array.isArray(response) ? response : response.data;
42
+ }
43
+ /**
44
+ * Get a specific rig count record
45
+ *
46
+ * @param id - Record ID
47
+ * @returns Rig count record
48
+ *
49
+ * @throws {NotFoundError} If record not found
50
+ */
51
+ async get(id) {
52
+ if (!id || typeof id !== "string") {
53
+ throw new errors_js_1.ValidationError("Record ID must be a non-empty string");
54
+ }
55
+ return this.client["request"](`/v1/ei/rig_counts/${id}`, {});
56
+ }
57
+ /**
58
+ * Get latest rig count
59
+ *
60
+ * @returns Latest rig count data
61
+ */
62
+ async latest() {
63
+ return this.client["request"]("/v1/ei/rig_counts/latest", {});
64
+ }
65
+ /**
66
+ * Get rig counts by basin
67
+ *
68
+ * @returns Array of rig counts by basin
69
+ */
70
+ async byBasin() {
71
+ const response = await this.client["request"]("/v1/ei/rig_counts/by_basin", {});
72
+ return Array.isArray(response) ? response : response.data;
73
+ }
74
+ /**
75
+ * Get rig counts by state
76
+ *
77
+ * @returns Array of rig counts by state
78
+ */
79
+ async byState() {
80
+ const response = await this.client["request"]("/v1/ei/rig_counts/by_state", {});
81
+ return Array.isArray(response) ? response : response.data;
82
+ }
83
+ /**
84
+ * Get historical rig count data
85
+ *
86
+ * @returns Array of historical rig counts
87
+ */
88
+ async historical() {
89
+ const response = await this.client["request"]("/v1/ei/rig_counts/historical", {});
90
+ return Array.isArray(response) ? response : response.data;
91
+ }
92
+ }
93
+ exports.EIRigCountsResource = EIRigCountsResource;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * Energy Intelligence - Well Permits Resource
4
+ *
5
+ * Access oil and gas well permit data by state, operator, and formation.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.EIWellPermitsResource = void 0;
9
+ const errors_js_1 = require("../../errors.js");
10
+ /**
11
+ * EI Well Permits Resource
12
+ *
13
+ * Access oil and gas well permit data with detailed breakdowns.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
18
+ *
19
+ * // Get latest permits
20
+ * const latest = await client.ei.wellPermits.latest();
21
+ * console.log(`Permit: ${latest.permit_number} - ${latest.operator}`);
22
+ *
23
+ * // Get permits by state
24
+ * const states = await client.ei.wellPermits.byState();
25
+ * states.forEach(s => console.log(`${s.state}: ${s.permit_count} permits`));
26
+ *
27
+ * // Search permits
28
+ * const results = await client.ei.wellPermits.search({
29
+ * state: 'Texas',
30
+ * operator: 'ConocoPhillips'
31
+ * });
32
+ * ```
33
+ */
34
+ class EIWellPermitsResource {
35
+ constructor(client) {
36
+ this.client = client;
37
+ }
38
+ /**
39
+ * List all well permit records
40
+ *
41
+ * @returns Array of well permit records
42
+ */
43
+ async list() {
44
+ const response = await this.client["request"]("/v1/ei/well-permits", {});
45
+ return Array.isArray(response) ? response : response.data;
46
+ }
47
+ /**
48
+ * Get a specific well permit record
49
+ *
50
+ * @param id - Record ID
51
+ * @returns Well permit record
52
+ */
53
+ async get(id) {
54
+ if (!id || typeof id !== "string") {
55
+ throw new errors_js_1.ValidationError("Record ID must be a non-empty string");
56
+ }
57
+ return this.client["request"](`/v1/ei/well-permits/${id}`, {});
58
+ }
59
+ /**
60
+ * Get latest well permit
61
+ *
62
+ * @returns Latest well permit record
63
+ */
64
+ async latest() {
65
+ return this.client["request"]("/v1/ei/well-permits/latest", {});
66
+ }
67
+ /**
68
+ * Get well permit summary
69
+ *
70
+ * @returns Well permit summary statistics
71
+ */
72
+ async summary() {
73
+ return this.client["request"]("/v1/ei/well-permits/summary", {});
74
+ }
75
+ /**
76
+ * Get permits by state
77
+ *
78
+ * @returns Array of permits grouped by state
79
+ */
80
+ async byState() {
81
+ const response = await this.client["request"]("/v1/ei/well-permits/by-state", {});
82
+ return Array.isArray(response) ? response : response.data;
83
+ }
84
+ /**
85
+ * Get permits by operator
86
+ *
87
+ * @returns Array of permits grouped by operator
88
+ */
89
+ async byOperator() {
90
+ const response = await this.client["request"]("/v1/ei/well-permits/by-operator", {});
91
+ return Array.isArray(response) ? response : response.data;
92
+ }
93
+ /**
94
+ * Get permits by formation
95
+ *
96
+ * @returns Array of permits grouped by formation
97
+ */
98
+ async byFormation() {
99
+ const response = await this.client["request"]("/v1/ei/well-permits/by-formation", {});
100
+ return Array.isArray(response) ? response : response.data;
101
+ }
102
+ /**
103
+ * Search well permits
104
+ *
105
+ * @param query - Search query parameters
106
+ * @returns Array of matching well permit records
107
+ */
108
+ async search(query) {
109
+ const params = {};
110
+ if (query.state)
111
+ params.state = query.state;
112
+ if (query.operator)
113
+ params.operator = query.operator;
114
+ if (query.formation)
115
+ params.formation = query.formation;
116
+ if (query.start_date)
117
+ params.start_date = query.start_date;
118
+ if (query.end_date)
119
+ params.end_date = query.end_date;
120
+ const response = await this.client["request"]("/v1/ei/well-permits/search", params);
121
+ return Array.isArray(response) ? response : response.data;
122
+ }
123
+ }
124
+ exports.EIWellPermitsResource = EIWellPermitsResource;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ /**
3
+ * Forecasts Resource
4
+ *
5
+ * Access official price forecasts from EIA, IEA, and other agencies including
6
+ * monthly outlooks, accuracy metrics, and historical archives.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ForecastsResource = void 0;
10
+ const errors_js_1 = require("../errors.js");
11
+ /**
12
+ * Forecasts Resource
13
+ *
14
+ * Access official price forecasts from government agencies and research
15
+ * organizations including EIA, IEA, and others.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { OilPriceAPI } from 'oilpriceapi';
20
+ *
21
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
22
+ *
23
+ * // Get monthly forecasts
24
+ * const forecasts = await client.forecasts.monthly();
25
+ * forecasts.forEach(f => {
26
+ * console.log(`${f.period}: $${f.forecast_price} (${f.source})`);
27
+ * });
28
+ *
29
+ * // Check forecast accuracy
30
+ * const accuracy = await client.forecasts.accuracy();
31
+ * console.log(`EIA MAPE: ${accuracy.mape}%`);
32
+ * ```
33
+ */
34
+ class ForecastsResource {
35
+ constructor(client) {
36
+ this.client = client;
37
+ }
38
+ /**
39
+ * Get monthly price forecasts
40
+ *
41
+ * Returns official monthly forecasts from EIA, IEA, and other agencies.
42
+ *
43
+ * @param commodity - Optional commodity code filter
44
+ * @returns Array of monthly forecasts
45
+ *
46
+ * @throws {OilPriceAPIError} If API request fails
47
+ * @throws {AuthenticationError} If API key is invalid
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // Get all forecasts
52
+ * const allForecasts = await client.forecasts.monthly();
53
+ *
54
+ * // Get WTI forecasts only
55
+ * const wtiForecasts = await client.forecasts.monthly('WTI_USD');
56
+ *
57
+ * wtiForecasts.forEach(forecast => {
58
+ * console.log(`${forecast.period}: $${forecast.forecast_price}`);
59
+ * console.log(` Range: $${forecast.lower_bound} - $${forecast.upper_bound}`);
60
+ * console.log(` Source: ${forecast.source}`);
61
+ * });
62
+ * ```
63
+ */
64
+ async monthly(commodity) {
65
+ const params = {};
66
+ if (commodity)
67
+ params.commodity = commodity;
68
+ const response = await this.client["request"]("/v1/forecasts/monthly", params);
69
+ return Array.isArray(response) ? response : response.forecasts;
70
+ }
71
+ /**
72
+ * Get forecast accuracy metrics
73
+ *
74
+ * Returns historical accuracy measurements for forecast sources.
75
+ *
76
+ * @returns Forecast accuracy data
77
+ *
78
+ * @throws {OilPriceAPIError} If API request fails
79
+ * @throws {AuthenticationError} If API key is invalid
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const accuracy = await client.forecasts.accuracy();
84
+ * console.log(`Source: ${accuracy.source}`);
85
+ * console.log(`MAPE: ${accuracy.mape}%`);
86
+ * console.log(`RMSE: ${accuracy.rmse}`);
87
+ * console.log(`Sample size: ${accuracy.sample_size} forecasts`);
88
+ * ```
89
+ */
90
+ async accuracy() {
91
+ return this.client["request"]("/v1/forecasts/accuracy", {});
92
+ }
93
+ /**
94
+ * Get archived forecasts
95
+ *
96
+ * Returns historical forecasts with actual outcomes for accuracy analysis.
97
+ *
98
+ * @param year - Optional year filter
99
+ * @returns Array of archived forecasts
100
+ *
101
+ * @throws {OilPriceAPIError} If API request fails
102
+ * @throws {AuthenticationError} If API key is invalid
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * // Get all archived forecasts
107
+ * const archive = await client.forecasts.archive();
108
+ *
109
+ * // Get forecasts from specific year
110
+ * const archive2024 = await client.forecasts.archive(2024);
111
+ *
112
+ * archive2024.forEach(forecast => {
113
+ * if (forecast.actual_price) {
114
+ * console.log(`${forecast.year}-${forecast.month}:`);
115
+ * console.log(` Forecast: $${forecast.forecast_price}`);
116
+ * console.log(` Actual: $${forecast.actual_price}`);
117
+ * console.log(` Error: ${forecast.error}%`);
118
+ * }
119
+ * });
120
+ * ```
121
+ */
122
+ async archive(year) {
123
+ const params = {};
124
+ if (year)
125
+ params.year = year.toString();
126
+ const response = await this.client["request"]("/v1/forecasts/archive", params);
127
+ return Array.isArray(response) ? response : response.forecasts;
128
+ }
129
+ /**
130
+ * Get forecast for a specific period
131
+ *
132
+ * @param period - Period identifier (e.g., "2024-03", "2024-Q2")
133
+ * @param commodity - Optional commodity code filter
134
+ * @returns Monthly forecast data
135
+ *
136
+ * @throws {NotFoundError} If period not found
137
+ * @throws {OilPriceAPIError} If API request fails
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * // Get March 2024 forecast
142
+ * const march2024 = await client.forecasts.get('2024-03');
143
+ *
144
+ * // Get Q2 2024 WTI forecast
145
+ * const q2Wti = await client.forecasts.get('2024-Q2', 'WTI_USD');
146
+ *
147
+ * console.log(`Period: ${march2024.period}`);
148
+ * console.log(`Forecast: $${march2024.forecast_price}`);
149
+ * console.log(`Published: ${march2024.published_at}`);
150
+ * ```
151
+ */
152
+ async get(period, commodity) {
153
+ if (!period || typeof period !== "string") {
154
+ throw new errors_js_1.ValidationError("Period must be a non-empty string");
155
+ }
156
+ const params = {};
157
+ if (commodity)
158
+ params.commodity = commodity;
159
+ return this.client["request"](`/v1/forecasts/monthly/${period}`, params);
160
+ }
161
+ }
162
+ exports.ForecastsResource = ForecastsResource;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ /**
3
+ * Futures Resource
4
+ *
5
+ * Access futures contract data including latest prices, historical data,
6
+ * OHLC, intraday, spreads, curves, and continuous contracts.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FuturesResource = void 0;
10
+ const errors_js_1 = require("../errors.js");
11
+ /**
12
+ * Futures Resource
13
+ *
14
+ * Access futures contract data including latest, historical, OHLC, intraday,
15
+ * spreads, curves, and continuous contracts.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { OilPriceAPI } from 'oilpriceapi';
20
+ *
21
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
22
+ *
23
+ * // Get latest price
24
+ * const latest = await client.futures.latest('CL.1');
25
+ * console.log(`${latest.contract}: $${latest.price}`);
26
+ *
27
+ * // Get OHLC data
28
+ * const ohlc = await client.futures.ohlc('CL.1', '2024-01-15');
29
+ * console.log(`High: $${ohlc.high}, Low: $${ohlc.low}`);
30
+ *
31
+ * // Get futures curve
32
+ * const curve = await client.futures.curve('CL');
33
+ * curve.curve.forEach(point => {
34
+ * console.log(`${point.months_out}mo: $${point.price}`);
35
+ * });
36
+ * ```
37
+ */
38
+ class FuturesResource {
39
+ constructor(client) {
40
+ this.client = client;
41
+ }
42
+ /**
43
+ * Get latest price for a futures contract
44
+ *
45
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
46
+ * @returns Latest futures price data
47
+ *
48
+ * @throws {NotFoundError} If contract not found
49
+ * @throws {OilPriceAPIError} If API request fails
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const price = await client.futures.latest('CL.1');
54
+ * console.log(`WTI Front Month: $${price.price}`);
55
+ * ```
56
+ */
57
+ async latest(contract) {
58
+ if (!contract || typeof contract !== "string") {
59
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
60
+ }
61
+ return this.client["request"](`/v1/futures/${contract}`, {});
62
+ }
63
+ /**
64
+ * Get historical prices for a futures contract
65
+ *
66
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
67
+ * @param options - Date range filters
68
+ * @returns Array of historical prices
69
+ *
70
+ * @throws {NotFoundError} If contract not found
71
+ * @throws {OilPriceAPIError} If API request fails
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const history = await client.futures.historical('CL.1', {
76
+ * startDate: '2024-01-01',
77
+ * endDate: '2024-01-31'
78
+ * });
79
+ * console.log(`${history.length} historical prices`);
80
+ * ```
81
+ */
82
+ async historical(contract, options) {
83
+ if (!contract || typeof contract !== "string") {
84
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
85
+ }
86
+ const params = {};
87
+ if (options?.startDate)
88
+ params.start_date = options.startDate;
89
+ if (options?.endDate)
90
+ params.end_date = options.endDate;
91
+ const response = await this.client["request"](`/v1/futures/${contract}/historical`, params);
92
+ return Array.isArray(response) ? response : response.prices;
93
+ }
94
+ /**
95
+ * Get OHLC (Open, High, Low, Close) data for a futures contract
96
+ *
97
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
98
+ * @param date - Optional date in YYYY-MM-DD format (defaults to latest)
99
+ * @returns OHLC data
100
+ *
101
+ * @throws {NotFoundError} If contract not found
102
+ * @throws {OilPriceAPIError} If API request fails
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const ohlc = await client.futures.ohlc('CL.1', '2024-01-15');
107
+ * console.log(`Open: $${ohlc.open}`);
108
+ * console.log(`High: $${ohlc.high}`);
109
+ * console.log(`Low: $${ohlc.low}`);
110
+ * console.log(`Close: $${ohlc.close}`);
111
+ * ```
112
+ */
113
+ async ohlc(contract, date) {
114
+ if (!contract || typeof contract !== "string") {
115
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
116
+ }
117
+ const params = {};
118
+ if (date)
119
+ params.date = date;
120
+ return this.client["request"](`/v1/futures/${contract}/ohlc`, params);
121
+ }
122
+ /**
123
+ * Get intraday price data for a futures contract
124
+ *
125
+ * Returns price points throughout the trading day.
126
+ *
127
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
128
+ * @returns Intraday price data
129
+ *
130
+ * @throws {NotFoundError} If contract not found
131
+ * @throws {OilPriceAPIError} If API request fails
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const intraday = await client.futures.intraday('CL.1');
136
+ * intraday.prices.forEach(point => {
137
+ * console.log(`${point.time}: $${point.price}`);
138
+ * });
139
+ * ```
140
+ */
141
+ async intraday(contract) {
142
+ if (!contract || typeof contract !== "string") {
143
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
144
+ }
145
+ return this.client["request"](`/v1/futures/${contract}/intraday`, {});
146
+ }
147
+ /**
148
+ * Get spread between two futures contracts
149
+ *
150
+ * Calculates the price difference between two contracts (contract1 - contract2).
151
+ *
152
+ * @param contract1 - First contract symbol
153
+ * @param contract2 - Second contract symbol
154
+ * @returns Spread data
155
+ *
156
+ * @throws {NotFoundError} If either contract not found
157
+ * @throws {OilPriceAPIError} If API request fails
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * // Calculate spread between front month and second month
162
+ * const spread = await client.futures.spreads('CL.1', 'CL.2');
163
+ * console.log(`CL.1 - CL.2 spread: $${spread.spread}`);
164
+ * ```
165
+ */
166
+ async spreads(contract1, contract2) {
167
+ if (!contract1 || typeof contract1 !== "string") {
168
+ throw new errors_js_1.ValidationError("First contract symbol must be a non-empty string");
169
+ }
170
+ if (!contract2 || typeof contract2 !== "string") {
171
+ throw new errors_js_1.ValidationError("Second contract symbol must be a non-empty string");
172
+ }
173
+ return this.client["request"]("/v1/futures/spreads", {
174
+ contract1,
175
+ contract2,
176
+ });
177
+ }
178
+ /**
179
+ * Get futures curve for a contract
180
+ *
181
+ * Returns the forward curve showing prices across different expiration dates.
182
+ *
183
+ * @param contract - Base contract symbol (e.g., "CL", "BZ")
184
+ * @returns Futures curve data
185
+ *
186
+ * @throws {NotFoundError} If contract not found
187
+ * @throws {OilPriceAPIError} If API request fails
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const curve = await client.futures.curve('CL');
192
+ * console.log('WTI Futures Curve:');
193
+ * curve.curve.forEach(point => {
194
+ * console.log(`${point.months_out} months: $${point.price}`);
195
+ * });
196
+ * ```
197
+ */
198
+ async curve(contract) {
199
+ if (!contract || typeof contract !== "string") {
200
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
201
+ }
202
+ return this.client["request"](`/v1/futures/${contract}/curve`, {});
203
+ }
204
+ /**
205
+ * Get continuous futures contract data
206
+ *
207
+ * Returns a continuous time series by rolling contracts before expiration.
208
+ *
209
+ * @param contract - Base contract symbol (e.g., "CL", "BZ")
210
+ * @param months - Number of months for continuous contract (default: 1 for front month)
211
+ * @returns Continuous contract data
212
+ *
213
+ * @throws {NotFoundError} If contract not found
214
+ * @throws {OilPriceAPIError} If API request fails
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * // Get continuous front month contract
219
+ * const continuous = await client.futures.continuous('CL', 1);
220
+ * console.log(`${continuous.prices.length} data points`);
221
+ * ```
222
+ */
223
+ async continuous(contract, months) {
224
+ if (!contract || typeof contract !== "string") {
225
+ throw new errors_js_1.ValidationError("Contract symbol must be a non-empty string");
226
+ }
227
+ const params = {};
228
+ if (months !== undefined)
229
+ params.months = months.toString();
230
+ return this.client["request"](`/v1/futures/${contract}/continuous`, params);
231
+ }
232
+ }
233
+ exports.FuturesResource = FuturesResource;