oilpriceapi 0.5.3 → 0.7.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 +395 -110
- package/dist/client.d.ts +83 -3
- package/dist/client.js +118 -38
- package/dist/index.d.ts +31 -6
- package/dist/index.js +17 -3
- package/dist/resources/alerts.d.ts +52 -15
- package/dist/resources/alerts.js +143 -85
- package/dist/resources/analytics.d.ts +325 -0
- package/dist/resources/analytics.js +221 -0
- package/dist/resources/bunker-fuels.d.ts +270 -0
- package/dist/resources/bunker-fuels.js +191 -0
- package/dist/resources/commodities.d.ts +148 -0
- package/dist/resources/commodities.js +110 -0
- package/dist/resources/data-quality.d.ts +229 -0
- package/dist/resources/data-quality.js +139 -0
- package/dist/resources/data-sources.d.ts +365 -0
- package/dist/resources/data-sources.js +349 -0
- package/dist/resources/drilling.d.ts +403 -0
- package/dist/resources/drilling.js +264 -0
- package/dist/resources/ei/drilling-productivity.d.ts +173 -0
- package/dist/resources/ei/drilling-productivity.js +103 -0
- package/dist/resources/ei/forecasts.d.ts +177 -0
- package/dist/resources/ei/forecasts.js +101 -0
- package/dist/resources/ei/frac-focus.d.ts +212 -0
- package/dist/resources/ei/frac-focus.js +150 -0
- package/dist/resources/ei/index.d.ts +140 -0
- package/dist/resources/ei/index.js +87 -0
- package/dist/resources/ei/oil-inventories.d.ts +155 -0
- package/dist/resources/ei/oil-inventories.js +92 -0
- package/dist/resources/ei/opec-production.d.ts +146 -0
- package/dist/resources/ei/opec-production.js +92 -0
- package/dist/resources/ei/rig-counts.d.ts +131 -0
- package/dist/resources/ei/rig-counts.js +88 -0
- package/dist/resources/ei/well-permits.d.ts +178 -0
- package/dist/resources/ei/well-permits.js +119 -0
- package/dist/resources/forecasts.d.ts +200 -0
- package/dist/resources/forecasts.js +157 -0
- package/dist/resources/futures.d.ts +322 -0
- package/dist/resources/futures.js +228 -0
- package/dist/resources/rig-counts.d.ts +221 -0
- package/dist/resources/rig-counts.js +157 -0
- package/dist/resources/storage.d.ts +182 -0
- package/dist/resources/storage.js +161 -0
- package/dist/resources/webhooks.d.ts +290 -0
- package/dist/resources/webhooks.js +297 -0
- package/dist/types.d.ts +106 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import type { OilPriceAPIConfig, Price, LatestPricesOptions, HistoricalPricesOptions, Commodity, CommoditiesResponse, CategoriesResponse } from
|
|
2
|
-
import { DieselResource } from
|
|
3
|
-
import { AlertsResource } from
|
|
1
|
+
import type { OilPriceAPIConfig, Price, LatestPricesOptions, HistoricalPricesOptions, Commodity, CommoditiesResponse, CategoriesResponse, DataConnectorPrice, DataConnectorOptions } from "./types.js";
|
|
2
|
+
import { DieselResource } from "./resources/diesel.js";
|
|
3
|
+
import { AlertsResource } from "./resources/alerts.js";
|
|
4
|
+
import { CommoditiesResource } from "./resources/commodities.js";
|
|
5
|
+
import { FuturesResource } from "./resources/futures.js";
|
|
6
|
+
import { StorageResource } from "./resources/storage.js";
|
|
7
|
+
import { RigCountsResource } from "./resources/rig-counts.js";
|
|
8
|
+
import { BunkerFuelsResource } from "./resources/bunker-fuels.js";
|
|
9
|
+
import { AnalyticsResource } from "./resources/analytics.js";
|
|
10
|
+
import { ForecastsResource } from "./resources/forecasts.js";
|
|
11
|
+
import { DataQualityResource } from "./resources/data-quality.js";
|
|
12
|
+
import { DrillingIntelligenceResource } from "./resources/drilling.js";
|
|
13
|
+
import { EnergyIntelligenceResource } from "./resources/ei/index.js";
|
|
14
|
+
import { WebhooksResource } from "./resources/webhooks.js";
|
|
15
|
+
import { DataSourcesResource } from "./resources/data-sources.js";
|
|
4
16
|
/**
|
|
5
17
|
* Official Node.js client for Oil Price API
|
|
6
18
|
*
|
|
@@ -35,6 +47,8 @@ export declare class OilPriceAPI {
|
|
|
35
47
|
private retryStrategy;
|
|
36
48
|
private timeout;
|
|
37
49
|
private debug;
|
|
50
|
+
private appUrl?;
|
|
51
|
+
private appName?;
|
|
38
52
|
/**
|
|
39
53
|
* Diesel prices resource (state averages + station-level pricing)
|
|
40
54
|
*/
|
|
@@ -43,6 +57,54 @@ export declare class OilPriceAPI {
|
|
|
43
57
|
* Price alerts resource (create, manage, and monitor alerts)
|
|
44
58
|
*/
|
|
45
59
|
readonly alerts: AlertsResource;
|
|
60
|
+
/**
|
|
61
|
+
* Commodities resource (metadata and categories)
|
|
62
|
+
*/
|
|
63
|
+
readonly commodities: CommoditiesResource;
|
|
64
|
+
/**
|
|
65
|
+
* Futures resource (contracts, OHLC, curves, spreads)
|
|
66
|
+
*/
|
|
67
|
+
readonly futures: FuturesResource;
|
|
68
|
+
/**
|
|
69
|
+
* Storage resource (inventory levels, Cushing, SPR)
|
|
70
|
+
*/
|
|
71
|
+
readonly storage: StorageResource;
|
|
72
|
+
/**
|
|
73
|
+
* Rig counts resource (Baker Hughes rig count data)
|
|
74
|
+
*/
|
|
75
|
+
readonly rigCounts: RigCountsResource;
|
|
76
|
+
/**
|
|
77
|
+
* Bunker fuels resource (marine fuel prices at ports)
|
|
78
|
+
*/
|
|
79
|
+
readonly bunkerFuels: BunkerFuelsResource;
|
|
80
|
+
/**
|
|
81
|
+
* Analytics resource (performance, statistics, correlations)
|
|
82
|
+
*/
|
|
83
|
+
readonly analytics: AnalyticsResource;
|
|
84
|
+
/**
|
|
85
|
+
* Forecasts resource (EIA/IEA forecasts and accuracy)
|
|
86
|
+
*/
|
|
87
|
+
readonly forecasts: ForecastsResource;
|
|
88
|
+
/**
|
|
89
|
+
* Data quality resource (quality metrics and reports)
|
|
90
|
+
*/
|
|
91
|
+
readonly dataQuality: DataQualityResource;
|
|
92
|
+
/**
|
|
93
|
+
* Drilling intelligence resource (US onshore drilling activity)
|
|
94
|
+
*/
|
|
95
|
+
readonly drilling: DrillingIntelligenceResource;
|
|
96
|
+
/**
|
|
97
|
+
* Energy intelligence resource (comprehensive market intelligence)
|
|
98
|
+
*/
|
|
99
|
+
readonly ei: EnergyIntelligenceResource;
|
|
100
|
+
/**
|
|
101
|
+
* Webhooks resource (webhook endpoint management)
|
|
102
|
+
*/
|
|
103
|
+
readonly webhooks: WebhooksResource;
|
|
104
|
+
/**
|
|
105
|
+
* Data sources resource (BYOS - Bring Your Own Source)
|
|
106
|
+
*/
|
|
107
|
+
readonly dataSources: DataSourcesResource;
|
|
46
108
|
constructor(config: OilPriceAPIConfig);
|
|
47
109
|
/**
|
|
48
110
|
* Log debug messages if debug mode is enabled
|
|
@@ -103,6 +165,24 @@ export declare class OilPriceAPI {
|
|
|
103
165
|
* ```
|
|
104
166
|
*/
|
|
105
167
|
getHistoricalPrices(options?: HistoricalPricesOptions): Promise<Price[]>;
|
|
168
|
+
/**
|
|
169
|
+
* Get prices from your connected data sources (BYOS)
|
|
170
|
+
*
|
|
171
|
+
* Requires Data Connector feature enabled on your organization.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Get all connected prices
|
|
176
|
+
* const prices = await client.getDataConnectorPrices();
|
|
177
|
+
*
|
|
178
|
+
* // Filter by fuel type
|
|
179
|
+
* const vlsfo = await client.getDataConnectorPrices({ fuelType: 'VLSFO' });
|
|
180
|
+
*
|
|
181
|
+
* // Filter by port
|
|
182
|
+
* const singapore = await client.getDataConnectorPrices({ port: 'SINGAPORE' });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
getDataConnectorPrices(options?: DataConnectorOptions): Promise<DataConnectorPrice[]>;
|
|
106
186
|
/**
|
|
107
187
|
* Get metadata for all supported commodities
|
|
108
188
|
*
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from
|
|
2
|
-
import { DieselResource } from
|
|
3
|
-
import { AlertsResource } from
|
|
4
|
-
import {
|
|
1
|
+
import { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from "./errors.js";
|
|
2
|
+
import { DieselResource } from "./resources/diesel.js";
|
|
3
|
+
import { AlertsResource } from "./resources/alerts.js";
|
|
4
|
+
import { CommoditiesResource } from "./resources/commodities.js";
|
|
5
|
+
import { FuturesResource } from "./resources/futures.js";
|
|
6
|
+
import { StorageResource } from "./resources/storage.js";
|
|
7
|
+
import { RigCountsResource } from "./resources/rig-counts.js";
|
|
8
|
+
import { BunkerFuelsResource } from "./resources/bunker-fuels.js";
|
|
9
|
+
import { AnalyticsResource } from "./resources/analytics.js";
|
|
10
|
+
import { ForecastsResource } from "./resources/forecasts.js";
|
|
11
|
+
import { DataQualityResource } from "./resources/data-quality.js";
|
|
12
|
+
import { DrillingIntelligenceResource } from "./resources/drilling.js";
|
|
13
|
+
import { EnergyIntelligenceResource } from "./resources/ei/index.js";
|
|
14
|
+
import { WebhooksResource } from "./resources/webhooks.js";
|
|
15
|
+
import { DataSourcesResource } from "./resources/data-sources.js";
|
|
16
|
+
import { SDK_VERSION, SDK_NAME, buildUserAgent } from "./version.js";
|
|
5
17
|
/**
|
|
6
18
|
* Official Node.js client for Oil Price API
|
|
7
19
|
*
|
|
@@ -31,18 +43,32 @@ import { SDK_VERSION, SDK_NAME, buildUserAgent } from './version.js';
|
|
|
31
43
|
export class OilPriceAPI {
|
|
32
44
|
constructor(config) {
|
|
33
45
|
if (!config.apiKey) {
|
|
34
|
-
throw new OilPriceAPIError(
|
|
46
|
+
throw new OilPriceAPIError("API key is required");
|
|
35
47
|
}
|
|
36
48
|
this.apiKey = config.apiKey;
|
|
37
|
-
this.baseUrl = config.baseUrl ||
|
|
49
|
+
this.baseUrl = config.baseUrl || "https://api.oilpriceapi.com";
|
|
38
50
|
this.retries = config.retries !== undefined ? config.retries : 3;
|
|
39
51
|
this.retryDelay = config.retryDelay || 1000;
|
|
40
|
-
this.retryStrategy = config.retryStrategy ||
|
|
52
|
+
this.retryStrategy = config.retryStrategy || "exponential";
|
|
41
53
|
this.timeout = config.timeout || 90000; // 90 seconds for slow historical queries
|
|
42
54
|
this.debug = config.debug || false;
|
|
55
|
+
this.appUrl = config.appUrl;
|
|
56
|
+
this.appName = config.appName;
|
|
43
57
|
// Initialize resources
|
|
44
58
|
this.diesel = new DieselResource(this);
|
|
45
59
|
this.alerts = new AlertsResource(this);
|
|
60
|
+
this.commodities = new CommoditiesResource(this);
|
|
61
|
+
this.futures = new FuturesResource(this);
|
|
62
|
+
this.storage = new StorageResource(this);
|
|
63
|
+
this.rigCounts = new RigCountsResource(this);
|
|
64
|
+
this.bunkerFuels = new BunkerFuelsResource(this);
|
|
65
|
+
this.analytics = new AnalyticsResource(this);
|
|
66
|
+
this.forecasts = new ForecastsResource(this);
|
|
67
|
+
this.dataQuality = new DataQualityResource(this);
|
|
68
|
+
this.drilling = new DrillingIntelligenceResource(this);
|
|
69
|
+
this.ei = new EnergyIntelligenceResource(this);
|
|
70
|
+
this.webhooks = new WebhooksResource(this);
|
|
71
|
+
this.dataSources = new DataSourcesResource(this);
|
|
46
72
|
}
|
|
47
73
|
/**
|
|
48
74
|
* Log debug messages if debug mode is enabled
|
|
@@ -50,7 +76,7 @@ export class OilPriceAPI {
|
|
|
50
76
|
log(message, data) {
|
|
51
77
|
if (this.debug) {
|
|
52
78
|
const timestamp = new Date().toISOString();
|
|
53
|
-
console.log(`[OilPriceAPI ${timestamp}] ${message}`, data ||
|
|
79
|
+
console.log(`[OilPriceAPI ${timestamp}] ${message}`, data || "");
|
|
54
80
|
}
|
|
55
81
|
}
|
|
56
82
|
/**
|
|
@@ -58,11 +84,11 @@ export class OilPriceAPI {
|
|
|
58
84
|
*/
|
|
59
85
|
calculateRetryDelay(attempt) {
|
|
60
86
|
switch (this.retryStrategy) {
|
|
61
|
-
case
|
|
87
|
+
case "exponential":
|
|
62
88
|
return this.retryDelay * Math.pow(2, attempt);
|
|
63
|
-
case
|
|
89
|
+
case "linear":
|
|
64
90
|
return this.retryDelay * (attempt + 1);
|
|
65
|
-
case
|
|
91
|
+
case "fixed":
|
|
66
92
|
default:
|
|
67
93
|
return this.retryDelay;
|
|
68
94
|
}
|
|
@@ -71,14 +97,14 @@ export class OilPriceAPI {
|
|
|
71
97
|
* Sleep for specified milliseconds
|
|
72
98
|
*/
|
|
73
99
|
sleep(ms) {
|
|
74
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
100
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
75
101
|
}
|
|
76
102
|
/**
|
|
77
103
|
* Determine if error is retryable
|
|
78
104
|
*/
|
|
79
105
|
isRetryable(error) {
|
|
80
106
|
// Retry on network errors
|
|
81
|
-
if (error instanceof TypeError && error.message.includes(
|
|
107
|
+
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
82
108
|
return true;
|
|
83
109
|
}
|
|
84
110
|
// Retry on timeout errors
|
|
@@ -122,15 +148,24 @@ export class OilPriceAPI {
|
|
|
122
148
|
const controller = new AbortController();
|
|
123
149
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
124
150
|
try {
|
|
151
|
+
// Build headers with optional telemetry
|
|
152
|
+
const headers = {
|
|
153
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
154
|
+
"Content-Type": "application/json",
|
|
155
|
+
"User-Agent": buildUserAgent(),
|
|
156
|
+
"X-SDK-Name": SDK_NAME,
|
|
157
|
+
"X-SDK-Version": SDK_VERSION,
|
|
158
|
+
};
|
|
159
|
+
// Add optional telemetry headers (10% bonus for appUrl!)
|
|
160
|
+
if (this.appUrl) {
|
|
161
|
+
headers["X-App-URL"] = this.appUrl;
|
|
162
|
+
}
|
|
163
|
+
if (this.appName) {
|
|
164
|
+
headers["X-App-Name"] = this.appName;
|
|
165
|
+
}
|
|
125
166
|
const response = await fetch(url.toString(), {
|
|
126
|
-
method:
|
|
127
|
-
headers
|
|
128
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
129
|
-
'Content-Type': 'application/json',
|
|
130
|
-
'User-Agent': buildUserAgent(),
|
|
131
|
-
'X-Api-Client': SDK_NAME,
|
|
132
|
-
'X-Client-Version': SDK_VERSION,
|
|
133
|
-
},
|
|
167
|
+
method: "GET",
|
|
168
|
+
headers,
|
|
134
169
|
signal: controller.signal,
|
|
135
170
|
});
|
|
136
171
|
clearTimeout(timeoutId);
|
|
@@ -142,7 +177,8 @@ export class OilPriceAPI {
|
|
|
142
177
|
// Try to parse JSON error response
|
|
143
178
|
try {
|
|
144
179
|
const errorJson = JSON.parse(errorBody);
|
|
145
|
-
errorMessage =
|
|
180
|
+
errorMessage =
|
|
181
|
+
errorJson.message || errorJson.error || errorMessage;
|
|
146
182
|
}
|
|
147
183
|
catch {
|
|
148
184
|
// Use default error message if response isn't JSON
|
|
@@ -155,7 +191,7 @@ export class OilPriceAPI {
|
|
|
155
191
|
case 404:
|
|
156
192
|
throw new NotFoundError(errorMessage);
|
|
157
193
|
case 429:
|
|
158
|
-
const retryAfter = response.headers.get(
|
|
194
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
159
195
|
const rateLimitError = new RateLimitError(errorMessage, retryAfter ? parseInt(retryAfter, 10) : undefined);
|
|
160
196
|
// If rate limited and we have retries left, wait and retry
|
|
161
197
|
if (attempt < this.retries && rateLimitError.retryAfter) {
|
|
@@ -170,19 +206,19 @@ export class OilPriceAPI {
|
|
|
170
206
|
case 504:
|
|
171
207
|
throw new ServerError(errorMessage, response.status);
|
|
172
208
|
default:
|
|
173
|
-
throw new OilPriceAPIError(errorMessage, response.status,
|
|
209
|
+
throw new OilPriceAPIError(errorMessage, response.status, "HTTP_ERROR");
|
|
174
210
|
}
|
|
175
211
|
}
|
|
176
212
|
// Parse successful response
|
|
177
213
|
const responseData = await response.json();
|
|
178
|
-
this.log(
|
|
214
|
+
this.log("Response data received", {
|
|
179
215
|
status: responseData.status,
|
|
180
|
-
hasData: !!responseData.data
|
|
216
|
+
hasData: !!responseData.data,
|
|
181
217
|
});
|
|
182
218
|
// Handle different response structures
|
|
183
219
|
// Latest endpoint: { status, data: { price, ... } }
|
|
184
220
|
// Historical endpoint: { status, data: { prices: [...] } }
|
|
185
|
-
if (responseData.status ===
|
|
221
|
+
if (responseData.status === "success" && responseData.data) {
|
|
186
222
|
if (responseData.data.prices) {
|
|
187
223
|
// Historical endpoint - return prices array
|
|
188
224
|
this.log(`Returning ${responseData.data.prices.length} prices`);
|
|
@@ -190,18 +226,18 @@ export class OilPriceAPI {
|
|
|
190
226
|
}
|
|
191
227
|
else if (responseData.data.price !== undefined) {
|
|
192
228
|
// Latest endpoint - wrap single price in array
|
|
193
|
-
this.log(
|
|
229
|
+
this.log("Returning single price (wrapped in array)");
|
|
194
230
|
return [responseData.data];
|
|
195
231
|
}
|
|
196
232
|
}
|
|
197
233
|
// Fallback - return data as-is
|
|
198
|
-
this.log(
|
|
234
|
+
this.log("Returning data as-is");
|
|
199
235
|
return responseData.data;
|
|
200
236
|
}
|
|
201
237
|
catch (error) {
|
|
202
238
|
// Handle abort (timeout)
|
|
203
|
-
if (error instanceof Error && error.name ===
|
|
204
|
-
throw new TimeoutError(
|
|
239
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
240
|
+
throw new TimeoutError("Request timeout", this.timeout);
|
|
205
241
|
}
|
|
206
242
|
throw error;
|
|
207
243
|
}
|
|
@@ -210,7 +246,7 @@ export class OilPriceAPI {
|
|
|
210
246
|
lastError = error;
|
|
211
247
|
this.log(`Request failed: ${lastError.message}`, {
|
|
212
248
|
attempt,
|
|
213
|
-
retryable: this.isRetryable(lastError)
|
|
249
|
+
retryable: this.isRetryable(lastError),
|
|
214
250
|
});
|
|
215
251
|
// Re-throw our custom errors if not retryable
|
|
216
252
|
if (error instanceof OilPriceAPIError && !this.isRetryable(error)) {
|
|
@@ -223,7 +259,7 @@ export class OilPriceAPI {
|
|
|
223
259
|
}
|
|
224
260
|
// Wrap fetch errors (network issues, etc.)
|
|
225
261
|
if (error instanceof Error) {
|
|
226
|
-
throw new OilPriceAPIError(`Request failed after ${this.retries + 1} attempts: ${error.message}`, undefined,
|
|
262
|
+
throw new OilPriceAPIError(`Request failed after ${this.retries + 1} attempts: ${error.message}`, undefined, "NETWORK_ERROR");
|
|
227
263
|
}
|
|
228
264
|
throw error;
|
|
229
265
|
}
|
|
@@ -234,7 +270,7 @@ export class OilPriceAPI {
|
|
|
234
270
|
}
|
|
235
271
|
}
|
|
236
272
|
// This should never be reached, but TypeScript wants it
|
|
237
|
-
throw lastError || new OilPriceAPIError(
|
|
273
|
+
throw lastError || new OilPriceAPIError("Unknown error occurred");
|
|
238
274
|
}
|
|
239
275
|
/**
|
|
240
276
|
* Get the latest prices for all commodities or a specific commodity
|
|
@@ -256,7 +292,7 @@ export class OilPriceAPI {
|
|
|
256
292
|
if (options?.commodity) {
|
|
257
293
|
params.by_code = options.commodity;
|
|
258
294
|
}
|
|
259
|
-
return this.request(
|
|
295
|
+
return this.request("/v1/prices/latest", params);
|
|
260
296
|
}
|
|
261
297
|
/**
|
|
262
298
|
* Get historical prices for a time period
|
|
@@ -294,6 +330,20 @@ export class OilPriceAPI {
|
|
|
294
330
|
if (options?.endDate) {
|
|
295
331
|
params.end_date = options.endDate;
|
|
296
332
|
}
|
|
333
|
+
// PERFORMANCE FIX (December 24, 2025):
|
|
334
|
+
// Pass interval parameter to enable aggregated queries
|
|
335
|
+
// This reduces response times from 74s to <1s for year-long queries
|
|
336
|
+
// by returning 365 daily points instead of 600k+ raw points
|
|
337
|
+
if (options?.interval) {
|
|
338
|
+
params.interval = options.interval;
|
|
339
|
+
}
|
|
340
|
+
// Pagination parameters
|
|
341
|
+
if (options?.perPage !== undefined) {
|
|
342
|
+
params.per_page = options.perPage.toString();
|
|
343
|
+
}
|
|
344
|
+
if (options?.page !== undefined) {
|
|
345
|
+
params.page = options.page.toString();
|
|
346
|
+
}
|
|
297
347
|
// CRITICAL FIX (December 17, 2025):
|
|
298
348
|
// Use /v1/prices/past_year endpoint instead of /v1/prices
|
|
299
349
|
// The /v1/prices endpoint does NOT correctly handle start_date/end_date parameters
|
|
@@ -301,7 +351,37 @@ export class OilPriceAPI {
|
|
|
301
351
|
// Issue: SDK was returning wrong dates for historical queries
|
|
302
352
|
// Root Cause: Backend has_scope :by_period not working on /v1/prices
|
|
303
353
|
// Solution: Use /v1/prices/past_year which uses direct WHERE clauses
|
|
304
|
-
return this.request(
|
|
354
|
+
return this.request("/v1/prices/past_year", params);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Get prices from your connected data sources (BYOS)
|
|
358
|
+
*
|
|
359
|
+
* Requires Data Connector feature enabled on your organization.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* // Get all connected prices
|
|
364
|
+
* const prices = await client.getDataConnectorPrices();
|
|
365
|
+
*
|
|
366
|
+
* // Filter by fuel type
|
|
367
|
+
* const vlsfo = await client.getDataConnectorPrices({ fuelType: 'VLSFO' });
|
|
368
|
+
*
|
|
369
|
+
* // Filter by port
|
|
370
|
+
* const singapore = await client.getDataConnectorPrices({ port: 'SINGAPORE' });
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
async getDataConnectorPrices(options = {}) {
|
|
374
|
+
const params = {};
|
|
375
|
+
if (options.fuelType)
|
|
376
|
+
params.fuel_type = options.fuelType;
|
|
377
|
+
if (options.port)
|
|
378
|
+
params.port = options.port;
|
|
379
|
+
if (options.region)
|
|
380
|
+
params.region = options.region;
|
|
381
|
+
if (options.since)
|
|
382
|
+
params.since = options.since;
|
|
383
|
+
const response = await this.request("/v1/prices/data-connector", params);
|
|
384
|
+
return response.prices;
|
|
305
385
|
}
|
|
306
386
|
/**
|
|
307
387
|
* Get metadata for all supported commodities
|
|
@@ -315,7 +395,7 @@ export class OilPriceAPI {
|
|
|
315
395
|
* ```
|
|
316
396
|
*/
|
|
317
397
|
async getCommodities() {
|
|
318
|
-
return this.request(
|
|
398
|
+
return this.request("/v1/commodities", {});
|
|
319
399
|
}
|
|
320
400
|
/**
|
|
321
401
|
* Get all commodity categories with their commodities
|
|
@@ -330,7 +410,7 @@ export class OilPriceAPI {
|
|
|
330
410
|
* ```
|
|
331
411
|
*/
|
|
332
412
|
async getCommodityCategories() {
|
|
333
|
-
return this.request(
|
|
413
|
+
return this.request("/v1/commodities/categories", {});
|
|
334
414
|
}
|
|
335
415
|
/**
|
|
336
416
|
* Get metadata for a specific commodity by code
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,34 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
export { OilPriceAPI } from
|
|
9
|
-
export { SDK_VERSION, SDK_NAME } from
|
|
10
|
-
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, Commodity, CommoditiesResponse, CommodityCategory, CategoriesResponse, } from
|
|
11
|
-
export type { DieselPrice, DieselStation, DieselStationsResponse, GetDieselStationsOptions, } from
|
|
12
|
-
export type { PriceAlert, CreateAlertParams, UpdateAlertParams, AlertOperator,
|
|
13
|
-
export {
|
|
8
|
+
export { OilPriceAPI } from "./client.js";
|
|
9
|
+
export { SDK_VERSION, SDK_NAME } from "./version.js";
|
|
10
|
+
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, AggregationInterval, Commodity, CommoditiesResponse, CommodityCategory, CategoriesResponse, DataConnectorPrice, DataConnectorOptions, } from "./types.js";
|
|
11
|
+
export type { DieselPrice, DieselStation, DieselStationsResponse, GetDieselStationsOptions, } from "./resources/diesel.js";
|
|
12
|
+
export type { PriceAlert, CreateAlertParams, UpdateAlertParams, AlertOperator, } from "./resources/alerts.js";
|
|
13
|
+
export type { FuturesPrice, HistoricalFuturesPrice, HistoricalFuturesOptions, FuturesOHLC, IntradayPrice, IntradayFuturesData, FuturesSpread, FuturesCurvePoint, FuturesCurveData, ContinuousContractPrice, ContinuousFuturesData, } from "./resources/futures.js";
|
|
14
|
+
export type { StorageData, HistoricalStorageData, HistoricalStorageOptions, } from "./resources/storage.js";
|
|
15
|
+
export type { RigCountData, HistoricalRigCountData, HistoricalRigCountOptions, RigCountTrend, RigCountSummary, } from "./resources/rig-counts.js";
|
|
16
|
+
export type { BunkerFuelPrice, PortBunkerPrices, PortPriceComparison, BunkerFuelSpreads, HistoricalBunkerPrice, HistoricalBunkerOptions, } from "./resources/bunker-fuels.js";
|
|
17
|
+
export type { PerformanceMetrics, PerformanceOptions, StatisticalAnalysis, CorrelationAnalysis, TrendAnalysis, SpreadAnalysis, ForecastPoint, PriceForecast as AnalyticsPriceForecast, } from "./resources/analytics.js";
|
|
18
|
+
export type { MonthlyForecast, ForecastAccuracy, ArchivedForecast, } from "./resources/forecasts.js";
|
|
19
|
+
export type { DataQualitySummary, DataQualityReportMeta, DataQualityReport, } from "./resources/data-quality.js";
|
|
20
|
+
export type { DrillingIntelligenceData, LatestDrillingData, DrillingSummary, DrillingTrend, FracSpreadData, WellPermitData, DUCWellData, CompletionData, WellsDrilledData, BasinDrillingData, } from "./resources/drilling.js";
|
|
21
|
+
export type { WellTimelineEvent, WellTimeline, RigCountRecord, RigCountByBasin, RigCountByState, HistoricalRigCount, OilInventoryRecord, OilInventorySummary, InventoryByProduct, HistoricalInventory, CushingInventory, OPECProductionRecord, TotalOPECProduction, ProductionByCountry, HistoricalProduction, TopProducer, DrillingProductivityRecord, DrillingProductivitySummary, DUCWellInventory, ProductivityByBasin, HistoricalProductivity, ProductivityTrend, ForecastRecord, ForecastSummary, PriceForecast, ProductionForecast, HistoricalForecast, ForecastComparison, WellPermitRecord, WellPermitSummary, PermitsByState, PermitsByOperator, PermitsByFormation, WellPermitSearchQuery, FracFocusRecord, FracFocusSummary, DisclosuresByState, DisclosuresByOperator, ChemicalUsage, WellChemical, FracFocusSearchQuery, } from "./resources/ei/index.js";
|
|
22
|
+
export type { WebhookEndpoint, CreateWebhookParams, UpdateWebhookParams, WebhookTestResponse as WebhookTestResult, WebhookEvent, } from "./resources/webhooks.js";
|
|
23
|
+
export type { DataSourceType, DataSourceStatus, DataSource, CreateDataSourceParams, UpdateDataSourceParams, DataSourceTestResponse, DataSourceLog, DataSourceHealth, CredentialRotationResponse, } from "./resources/data-sources.js";
|
|
24
|
+
export { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from "./errors.js";
|
|
25
|
+
export { DieselResource } from "./resources/diesel.js";
|
|
26
|
+
export { AlertsResource } from "./resources/alerts.js";
|
|
27
|
+
export { CommoditiesResource } from "./resources/commodities.js";
|
|
28
|
+
export { FuturesResource } from "./resources/futures.js";
|
|
29
|
+
export { StorageResource } from "./resources/storage.js";
|
|
30
|
+
export { RigCountsResource } from "./resources/rig-counts.js";
|
|
31
|
+
export { BunkerFuelsResource } from "./resources/bunker-fuels.js";
|
|
32
|
+
export { AnalyticsResource } from "./resources/analytics.js";
|
|
33
|
+
export { ForecastsResource } from "./resources/forecasts.js";
|
|
34
|
+
export { DataQualityResource } from "./resources/data-quality.js";
|
|
35
|
+
export { DrillingIntelligenceResource } from "./resources/drilling.js";
|
|
36
|
+
export { EnergyIntelligenceResource, EIRigCountsResource, EIOilInventoriesResource, EIOPECProductionResource, EIDrillingProductivityResource, EIForecastsResource, EIWellPermitsResource, EIFracFocusResource, } from "./resources/ei/index.js";
|
|
37
|
+
export { WebhooksResource } from "./resources/webhooks.js";
|
|
38
|
+
export { DataSourcesResource } from "./resources/data-sources.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,20 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
export { OilPriceAPI } from
|
|
9
|
-
export { SDK_VERSION, SDK_NAME } from
|
|
10
|
-
export { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from
|
|
8
|
+
export { OilPriceAPI } from "./client.js";
|
|
9
|
+
export { SDK_VERSION, SDK_NAME } from "./version.js";
|
|
10
|
+
export { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from "./errors.js";
|
|
11
|
+
export { DieselResource } from "./resources/diesel.js";
|
|
12
|
+
export { AlertsResource } from "./resources/alerts.js";
|
|
13
|
+
export { CommoditiesResource } from "./resources/commodities.js";
|
|
14
|
+
export { FuturesResource } from "./resources/futures.js";
|
|
15
|
+
export { StorageResource } from "./resources/storage.js";
|
|
16
|
+
export { RigCountsResource } from "./resources/rig-counts.js";
|
|
17
|
+
export { BunkerFuelsResource } from "./resources/bunker-fuels.js";
|
|
18
|
+
export { AnalyticsResource } from "./resources/analytics.js";
|
|
19
|
+
export { ForecastsResource } from "./resources/forecasts.js";
|
|
20
|
+
export { DataQualityResource } from "./resources/data-quality.js";
|
|
21
|
+
export { DrillingIntelligenceResource } from "./resources/drilling.js";
|
|
22
|
+
export { EnergyIntelligenceResource, EIRigCountsResource, EIOilInventoriesResource, EIOPECProductionResource, EIDrillingProductivityResource, EIForecastsResource, EIWellPermitsResource, EIFracFocusResource, } from "./resources/ei/index.js";
|
|
23
|
+
export { WebhooksResource } from "./resources/webhooks.js";
|
|
24
|
+
export { DataSourcesResource } from "./resources/data-sources.js";
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Manage price alert configurations for automated notifications.
|
|
5
5
|
*/
|
|
6
|
-
import type { OilPriceAPI } from
|
|
6
|
+
import type { OilPriceAPI } from "../client.js";
|
|
7
7
|
/**
|
|
8
8
|
* Valid condition operators for price alerts
|
|
9
9
|
*/
|
|
10
|
-
export type AlertOperator =
|
|
10
|
+
export type AlertOperator = "greater_than" | "less_than" | "equals" | "greater_than_or_equal" | "less_than_or_equal";
|
|
11
11
|
/**
|
|
12
12
|
* Price alert configuration
|
|
13
13
|
*/
|
|
@@ -275,24 +275,61 @@ export declare class AlertsResource {
|
|
|
275
275
|
*/
|
|
276
276
|
delete(id: string): Promise<void>;
|
|
277
277
|
/**
|
|
278
|
-
* Test
|
|
278
|
+
* Test an alert
|
|
279
279
|
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* backend endpoint is added.
|
|
280
|
+
* Triggers a test run of the alert to verify it's working correctly.
|
|
281
|
+
* Does not affect the alert's cooldown or trigger count.
|
|
283
282
|
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
283
|
+
* @param alertId - The alert ID to test
|
|
284
|
+
* @returns Test results
|
|
285
|
+
*
|
|
286
|
+
* @throws {NotFoundError} If alert not found
|
|
287
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const result = await client.alerts.test(alertId);
|
|
292
|
+
* console.log(`Test ${result.success ? 'passed' : 'failed'}`);
|
|
293
|
+
* if (result.response_time_ms) {
|
|
294
|
+
* console.log(`Webhook response time: ${result.response_time_ms}ms`);
|
|
295
|
+
* }
|
|
288
296
|
* ```
|
|
297
|
+
*/
|
|
298
|
+
test(alertId: string): Promise<WebhookTestResponse>;
|
|
299
|
+
/**
|
|
300
|
+
* Get available alert triggers
|
|
301
|
+
*
|
|
302
|
+
* Returns list of supported trigger conditions and event types.
|
|
289
303
|
*
|
|
290
|
-
* @
|
|
291
|
-
* @returns Test results including response time and status
|
|
304
|
+
* @returns Array of available triggers
|
|
292
305
|
*
|
|
293
|
-
* @throws {
|
|
306
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
294
307
|
*
|
|
295
|
-
* @
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const triggers = await client.alerts.triggers();
|
|
311
|
+
* triggers.forEach(trigger => {
|
|
312
|
+
* console.log(`${trigger.name}: ${trigger.description}`);
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
triggers(): Promise<any[]>;
|
|
317
|
+
/**
|
|
318
|
+
* Get alert analytics history
|
|
319
|
+
*
|
|
320
|
+
* Returns historical analytics data for alerts including trigger frequency,
|
|
321
|
+
* success rates, and response times.
|
|
322
|
+
*
|
|
323
|
+
* @returns Analytics history data
|
|
324
|
+
*
|
|
325
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const analytics = await client.alerts.analyticsHistory();
|
|
330
|
+
* console.log(`Total triggers: ${analytics.total_triggers}`);
|
|
331
|
+
* console.log(`Success rate: ${analytics.success_rate}%`);
|
|
332
|
+
* ```
|
|
296
333
|
*/
|
|
297
|
-
|
|
334
|
+
analyticsHistory(): Promise<any>;
|
|
298
335
|
}
|