oilpriceapi 0.7.0 → 0.9.0
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/README.md +244 -30
- package/dist/cjs/client.js +610 -0
- package/dist/cjs/errors.js +80 -0
- package/dist/cjs/index.js +96 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/alerts.js +387 -0
- package/dist/cjs/resources/analytics.js +188 -0
- package/dist/cjs/resources/bunker-fuels.js +210 -0
- package/dist/cjs/resources/commodities.js +115 -0
- package/dist/cjs/resources/data-quality.js +144 -0
- package/dist/cjs/resources/data-sources.js +298 -0
- package/dist/cjs/resources/diesel.js +119 -0
- package/dist/cjs/resources/drilling.js +269 -0
- package/dist/cjs/resources/ei/drilling-productivity.js +108 -0
- package/dist/cjs/resources/ei/forecasts.js +106 -0
- package/dist/cjs/resources/ei/frac-focus.js +165 -0
- package/dist/cjs/resources/ei/index.js +98 -0
- package/dist/cjs/resources/ei/oil-inventories.js +97 -0
- package/dist/cjs/resources/ei/opec-production.js +97 -0
- package/dist/cjs/resources/ei/rig-counts.js +93 -0
- package/dist/cjs/resources/ei/well-permits.js +136 -0
- package/dist/cjs/resources/forecasts.js +168 -0
- package/dist/cjs/resources/futures.js +424 -0
- package/dist/cjs/resources/indicators.js +79 -0
- package/dist/cjs/resources/raw.js +128 -0
- package/dist/cjs/resources/rig-counts.js +164 -0
- package/dist/cjs/resources/spreads.js +105 -0
- package/dist/cjs/resources/storage.js +166 -0
- package/dist/cjs/resources/streaming.js +350 -0
- package/dist/cjs/resources/webhooks.js +283 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/version.js +24 -0
- package/dist/client.d.ts +130 -3
- package/dist/client.js +206 -30
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +25 -16
- package/dist/index.d.ts +28 -5
- package/dist/index.js +29 -1
- package/dist/resources/alerts.js +31 -77
- package/dist/resources/analytics.d.ts +147 -214
- package/dist/resources/analytics.js +104 -141
- package/dist/resources/bunker-fuels.d.ts +35 -12
- package/dist/resources/bunker-fuels.js +41 -26
- package/dist/resources/commodities.js +2 -1
- package/dist/resources/data-quality.js +2 -1
- package/dist/resources/data-sources.d.ts +31 -31
- package/dist/resources/data-sources.js +30 -85
- package/dist/resources/diesel.d.ts +1 -1
- package/dist/resources/diesel.js +9 -38
- package/dist/resources/drilling.js +2 -1
- package/dist/resources/ei/drilling-productivity.js +2 -1
- package/dist/resources/ei/forecasts.js +2 -1
- package/dist/resources/ei/frac-focus.d.ts +23 -9
- package/dist/resources/ei/frac-focus.js +20 -9
- package/dist/resources/ei/index.js +2 -1
- package/dist/resources/ei/oil-inventories.js +2 -1
- package/dist/resources/ei/opec-production.js +2 -1
- package/dist/resources/ei/rig-counts.js +2 -1
- package/dist/resources/ei/well-permits.d.ts +25 -9
- package/dist/resources/ei/well-permits.js +20 -7
- package/dist/resources/forecasts.d.ts +4 -1
- package/dist/resources/forecasts.js +13 -6
- package/dist/resources/futures.d.ts +178 -1
- package/dist/resources/futures.js +199 -8
- package/dist/resources/indicators.d.ts +170 -0
- package/dist/resources/indicators.js +75 -0
- package/dist/resources/raw.d.ts +94 -0
- package/dist/resources/raw.js +124 -0
- package/dist/resources/rig-counts.js +5 -2
- package/dist/resources/spreads.d.ts +121 -0
- package/dist/resources/spreads.js +101 -0
- package/dist/resources/storage.d.ts +5 -4
- package/dist/resources/storage.js +7 -6
- package/dist/resources/streaming.d.ts +272 -0
- package/dist/resources/streaming.js +342 -0
- package/dist/resources/webhooks.d.ts +73 -23
- package/dist/resources/webhooks.js +59 -77
- package/dist/types.d.ts +43 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/package.json +21 -6
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rig Counts Resource
|
|
4
|
+
*
|
|
5
|
+
* Access Baker Hughes rig count data including current counts, historical trends,
|
|
6
|
+
* and breakdowns by basin, state, and rig type.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RigCountsResource = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Rig Counts Resource
|
|
12
|
+
*
|
|
13
|
+
* Access Baker Hughes rig count data including current counts, historical data,
|
|
14
|
+
* trends, and summaries.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
19
|
+
*
|
|
20
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
21
|
+
*
|
|
22
|
+
* // Get latest rig count
|
|
23
|
+
* const latest = await client.rigCounts.latest();
|
|
24
|
+
* console.log(`Total rigs: ${latest.total}`);
|
|
25
|
+
* console.log(`Oil: ${latest.oil}, Gas: ${latest.gas}`);
|
|
26
|
+
*
|
|
27
|
+
* // Get summary with changes
|
|
28
|
+
* const summary = await client.rigCounts.summary();
|
|
29
|
+
* console.log(`Week-over-week: ${summary.week_change}`);
|
|
30
|
+
* console.log(`Year-over-year: ${summary.year_change}`);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
class RigCountsResource {
|
|
34
|
+
constructor(client) {
|
|
35
|
+
this.client = client;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get latest rig count data
|
|
39
|
+
*
|
|
40
|
+
* Returns the most recent Baker Hughes rig count.
|
|
41
|
+
*
|
|
42
|
+
* @returns Latest rig count data
|
|
43
|
+
*
|
|
44
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
45
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const latest = await client.rigCounts.latest();
|
|
50
|
+
* console.log(`Total rigs: ${latest.total}`);
|
|
51
|
+
* console.log(`Oil rigs: ${latest.oil}`);
|
|
52
|
+
* console.log(`Gas rigs: ${latest.gas}`);
|
|
53
|
+
* console.log(`Change: ${latest.change}`);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
async latest() {
|
|
57
|
+
return this.client["request"]("/v1/rig-counts/latest", {});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get current rig count data
|
|
61
|
+
*
|
|
62
|
+
* Alias for latest(). Returns the most recent Baker Hughes rig count.
|
|
63
|
+
*
|
|
64
|
+
* @returns Current rig count data
|
|
65
|
+
*
|
|
66
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
67
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const current = await client.rigCounts.current();
|
|
72
|
+
* console.log(`Total rigs: ${current.total}`);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
async current() {
|
|
76
|
+
return this.client["request"]("/v1/rig-counts/current", {});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get historical rig count data
|
|
80
|
+
*
|
|
81
|
+
* Returns time series of rig counts.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Date range filters
|
|
84
|
+
* @returns Array of historical rig count data
|
|
85
|
+
*
|
|
86
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
87
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const history = await client.rigCounts.historical({
|
|
92
|
+
* startDate: '2024-01-01',
|
|
93
|
+
* endDate: '2024-12-31'
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* history.forEach(point => {
|
|
97
|
+
* console.log(`${point.date}: ${point.total} rigs (${point.oil} oil, ${point.gas} gas)`);
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
async historical(options) {
|
|
102
|
+
// The controller filters via `has_scope :by_period, using: %i[from to], type: :hash`,
|
|
103
|
+
// i.e. it reads nested `by_period[from]` / `by_period[to]` query params — NOT
|
|
104
|
+
// flat `start_date` / `end_date` (which were silently ignored by earlier SDKs).
|
|
105
|
+
const params = {};
|
|
106
|
+
if (options?.startDate)
|
|
107
|
+
params["by_period[from]"] = options.startDate;
|
|
108
|
+
if (options?.endDate)
|
|
109
|
+
params["by_period[to]"] = options.endDate;
|
|
110
|
+
const response = await this.client["request"]("/v1/rig-counts/historical", params);
|
|
111
|
+
return Array.isArray(response) ? response : response.data;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get rig count trend analysis
|
|
115
|
+
*
|
|
116
|
+
* Returns trend analysis for a specified time period.
|
|
117
|
+
*
|
|
118
|
+
* @param period - Time period (e.g., "week", "month", "quarter", "year")
|
|
119
|
+
* @returns Trend analysis data
|
|
120
|
+
*
|
|
121
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
122
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const monthlyTrend = await client.rigCounts.trends('month');
|
|
127
|
+
* console.log(`Monthly average: ${monthlyTrend.average}`);
|
|
128
|
+
* console.log(`Trend: ${monthlyTrend.trend}`);
|
|
129
|
+
* console.log(`Change: ${monthlyTrend.change_percent}%`);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
async trends(period) {
|
|
133
|
+
const params = {};
|
|
134
|
+
if (period)
|
|
135
|
+
params.period = period;
|
|
136
|
+
return this.client["request"]("/v1/rig-counts/trends", params);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get rig count summary
|
|
140
|
+
*
|
|
141
|
+
* Returns comprehensive summary including current count and changes
|
|
142
|
+
* across multiple time periods.
|
|
143
|
+
*
|
|
144
|
+
* @returns Rig count summary
|
|
145
|
+
*
|
|
146
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
147
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const summary = await client.rigCounts.summary();
|
|
152
|
+
* console.log(`Current: ${summary.current}`);
|
|
153
|
+
* console.log(`Week-over-week: ${summary.week_change}`);
|
|
154
|
+
* console.log(`Month-over-month: ${summary.month_change}`);
|
|
155
|
+
* console.log(`Year-over-year: ${summary.year_change}`);
|
|
156
|
+
* console.log(`Oil rigs: ${summary.breakdown.oil}`);
|
|
157
|
+
* console.log(`Gas rigs: ${summary.breakdown.gas}`);
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
async summary() {
|
|
161
|
+
return this.client["request"]("/v1/rig-counts/summary", {});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.RigCountsResource = RigCountsResource;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Spreads Resource
|
|
4
|
+
*
|
|
5
|
+
* Access oil & product spread analytics: crack spreads, basis spreads,
|
|
6
|
+
* curve-structure (contango/backwardation), refining margins, and physical
|
|
7
|
+
* premiums. Each spread type supports the latest value, full history, and an
|
|
8
|
+
* `all` listing.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SpreadsResource = void 0;
|
|
12
|
+
const errors_js_1 = require("../errors.js");
|
|
13
|
+
/**
|
|
14
|
+
* Spreads Resource
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
19
|
+
*
|
|
20
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
21
|
+
*
|
|
22
|
+
* // Latest crack spread
|
|
23
|
+
* const crack = await client.spreads.crack();
|
|
24
|
+
* console.log(`Crack spread: ${crack.value} ${crack.unit}`);
|
|
25
|
+
*
|
|
26
|
+
* // Historical basis spreads
|
|
27
|
+
* const history = await client.spreads.historical('basis', {
|
|
28
|
+
* startDate: '2024-01-01',
|
|
29
|
+
* endDate: '2024-12-31',
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // All margin spreads
|
|
33
|
+
* const all = await client.spreads.all('margin');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
class SpreadsResource {
|
|
37
|
+
constructor(client) {
|
|
38
|
+
this.client = client;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the latest value for a spread type.
|
|
42
|
+
*
|
|
43
|
+
* @param type - Spread type slug.
|
|
44
|
+
* @returns Latest spread value.
|
|
45
|
+
* @throws {ValidationError} If the type is invalid.
|
|
46
|
+
*/
|
|
47
|
+
async get(type) {
|
|
48
|
+
this.validateType(type);
|
|
49
|
+
return this.client["request"](`/v1/spreads/${type}`, {});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get historical data for a spread type.
|
|
53
|
+
*
|
|
54
|
+
* @param type - Spread type slug.
|
|
55
|
+
* @param options - Optional date range filters.
|
|
56
|
+
* @returns Array of historical spread values.
|
|
57
|
+
*/
|
|
58
|
+
async historical(type, options) {
|
|
59
|
+
this.validateType(type);
|
|
60
|
+
const params = {};
|
|
61
|
+
if (options?.startDate)
|
|
62
|
+
params.start_date = options.startDate;
|
|
63
|
+
if (options?.endDate)
|
|
64
|
+
params.end_date = options.endDate;
|
|
65
|
+
const response = await this.client["request"](`/v1/spreads/${type}/historical`, params);
|
|
66
|
+
return Array.isArray(response) ? response : response.data;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get all spread values for a spread type.
|
|
70
|
+
*
|
|
71
|
+
* @param type - Spread type slug.
|
|
72
|
+
* @returns Array of spread values.
|
|
73
|
+
*/
|
|
74
|
+
async all(type) {
|
|
75
|
+
this.validateType(type);
|
|
76
|
+
const response = await this.client["request"](`/v1/spreads/${type}/all`, {});
|
|
77
|
+
return Array.isArray(response) ? response : response.data;
|
|
78
|
+
}
|
|
79
|
+
/** Latest crack spread. */
|
|
80
|
+
async crack() {
|
|
81
|
+
return this.get("crack");
|
|
82
|
+
}
|
|
83
|
+
/** Latest basis spread. */
|
|
84
|
+
async basis() {
|
|
85
|
+
return this.get("basis");
|
|
86
|
+
}
|
|
87
|
+
/** Latest curve-structure (contango / backwardation). */
|
|
88
|
+
async curveStructure() {
|
|
89
|
+
return this.get("curve-structure");
|
|
90
|
+
}
|
|
91
|
+
/** Latest refining margin. */
|
|
92
|
+
async margin() {
|
|
93
|
+
return this.get("margin");
|
|
94
|
+
}
|
|
95
|
+
/** Latest physical premium. */
|
|
96
|
+
async physicalPremium() {
|
|
97
|
+
return this.get("physical-premium");
|
|
98
|
+
}
|
|
99
|
+
validateType(type) {
|
|
100
|
+
if (!type || typeof type !== "string") {
|
|
101
|
+
throw new errors_js_1.ValidationError("Spread type must be a non-empty string");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.SpreadsResource = SpreadsResource;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Storage Resource
|
|
4
|
+
*
|
|
5
|
+
* Access crude oil storage data including total US inventory, Cushing hub levels,
|
|
6
|
+
* Strategic Petroleum Reserve (SPR), and regional breakdowns.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.StorageResource = void 0;
|
|
10
|
+
const errors_js_1 = require("../errors.js");
|
|
11
|
+
/**
|
|
12
|
+
* Storage Resource
|
|
13
|
+
*
|
|
14
|
+
* Access crude oil storage data for US inventory levels, Cushing hub,
|
|
15
|
+
* Strategic Petroleum Reserve, and regional breakdowns.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
20
|
+
*
|
|
21
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
22
|
+
*
|
|
23
|
+
* // Get all storage data
|
|
24
|
+
* const storage = await client.storage.all();
|
|
25
|
+
* console.log(`Total US inventory: ${storage.level} ${storage.unit}`);
|
|
26
|
+
*
|
|
27
|
+
* // Get Cushing levels
|
|
28
|
+
* const cushing = await client.storage.cushing();
|
|
29
|
+
* console.log(`Cushing: ${cushing.level} ${cushing.unit}`);
|
|
30
|
+
*
|
|
31
|
+
* // Get SPR levels
|
|
32
|
+
* const spr = await client.storage.spr();
|
|
33
|
+
* console.log(`SPR: ${spr.level} ${spr.unit}`);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
class StorageResource {
|
|
37
|
+
constructor(client) {
|
|
38
|
+
this.client = client;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get all current storage levels
|
|
42
|
+
*
|
|
43
|
+
* Returns total US commercial crude oil inventory.
|
|
44
|
+
*
|
|
45
|
+
* @returns Current storage data
|
|
46
|
+
*
|
|
47
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
48
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const storage = await client.storage.all();
|
|
53
|
+
* console.log(`Total inventory: ${storage.level} ${storage.unit}`);
|
|
54
|
+
* if (storage.change) {
|
|
55
|
+
* console.log(`Change: ${storage.change > 0 ? '+' : ''}${storage.change}`);
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
async all() {
|
|
60
|
+
return this.client["request"]("/v1/storage", {});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get Cushing, OK storage levels
|
|
64
|
+
*
|
|
65
|
+
* Returns current inventory at Cushing, Oklahoma - the key delivery point
|
|
66
|
+
* for WTI crude oil futures.
|
|
67
|
+
*
|
|
68
|
+
* @returns Cushing storage data
|
|
69
|
+
*
|
|
70
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
71
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const cushing = await client.storage.cushing();
|
|
76
|
+
* console.log(`Cushing inventory: ${cushing.level} ${cushing.unit}`);
|
|
77
|
+
* console.log(`Week-over-week change: ${cushing.change_percent}%`);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
async cushing() {
|
|
81
|
+
return this.client["request"]("/v1/storage/cushing", {});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get Strategic Petroleum Reserve (SPR) levels
|
|
85
|
+
*
|
|
86
|
+
* Returns current US Strategic Petroleum Reserve inventory.
|
|
87
|
+
*
|
|
88
|
+
* @returns SPR storage data
|
|
89
|
+
*
|
|
90
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
91
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const spr = await client.storage.spr();
|
|
96
|
+
* console.log(`SPR inventory: ${spr.level} ${spr.unit}`);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
async spr() {
|
|
100
|
+
return this.client["request"]("/v1/storage/spr", {});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get regional storage breakdown
|
|
104
|
+
*
|
|
105
|
+
* Returns storage levels by region (PADD districts) or a specific region.
|
|
106
|
+
*
|
|
107
|
+
* @param region - Optional region code (e.g., "PADD1", "PADD2", "PADD3")
|
|
108
|
+
* @returns Regional storage data
|
|
109
|
+
*
|
|
110
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
111
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* // Get all regions
|
|
116
|
+
* const regions = await client.storage.regional();
|
|
117
|
+
*
|
|
118
|
+
* // Get specific region (Gulf Coast)
|
|
119
|
+
* const gulfCoast = await client.storage.regional('PADD3');
|
|
120
|
+
* console.log(`PADD 3 (Gulf Coast): ${gulfCoast.level} ${gulfCoast.unit}`);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
async regional(region) {
|
|
124
|
+
const params = {};
|
|
125
|
+
if (region)
|
|
126
|
+
params.region = region;
|
|
127
|
+
return this.client["request"]("/v1/storage/regional", params);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get historical storage data
|
|
131
|
+
*
|
|
132
|
+
* Returns time series of storage levels for a specific location.
|
|
133
|
+
*
|
|
134
|
+
* @param code - Storage location code (e.g., "US", "CUSHING", "SPR")
|
|
135
|
+
* @param options - Date range filters
|
|
136
|
+
* @returns Array of historical storage data
|
|
137
|
+
*
|
|
138
|
+
* @throws {NotFoundError} If location code not found
|
|
139
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const history = await client.storage.history('CUSHING', {
|
|
144
|
+
* startDate: '2024-01-01',
|
|
145
|
+
* endDate: '2024-12-31'
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* history.forEach(point => {
|
|
149
|
+
* console.log(`${point.date}: ${point.level} ${point.unit}`);
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async history(code, options) {
|
|
154
|
+
if (!code || typeof code !== "string") {
|
|
155
|
+
throw new errors_js_1.ValidationError("Storage location code must be a non-empty string");
|
|
156
|
+
}
|
|
157
|
+
const params = {};
|
|
158
|
+
if (options?.period)
|
|
159
|
+
params.period = options.period;
|
|
160
|
+
// Route is GET /v1/storage/history/:code (the :code segment comes AFTER
|
|
161
|
+
// `history`), and the controller reads a `period` token.
|
|
162
|
+
const response = await this.client["request"](`/v1/storage/history/${code}`, params);
|
|
163
|
+
return Array.isArray(response) ? response : response.data;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.StorageResource = StorageResource;
|