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
@@ -1,3 +1,4 @@
1
+ import { ValidationError } from "../errors.js";
1
2
  /**
2
3
  * Diesel Prices resource
3
4
  *
@@ -50,9 +51,9 @@ export class DieselResource {
50
51
  */
51
52
  async getPrice(state) {
52
53
  if (!state || state.length !== 2) {
53
- throw new Error('State must be a 2-letter US state code (e.g., "CA", "TX")');
54
+ throw new ValidationError('State must be a 2-letter US state code (e.g., "CA", "TX")');
54
55
  }
55
- const response = await this.client['request']('/v1/diesel-prices', { state: state.toUpperCase() });
56
+ const response = await this.client["request"]("/v1/diesel-prices", { state: state.toUpperCase() });
56
57
  return response.regional_average;
57
58
  }
58
59
  /**
@@ -98,47 +99,17 @@ export class DieselResource {
98
99
  const { lat, lng, radius = 8047 } = options;
99
100
  // Validate coordinates
100
101
  if (lat < -90 || lat > 90) {
101
- throw new Error('Latitude must be between -90 and 90');
102
+ throw new ValidationError("Latitude must be between -90 and 90");
102
103
  }
103
104
  if (lng < -180 || lng > 180) {
104
- throw new Error('Longitude must be between -180 and 180');
105
+ throw new ValidationError("Longitude must be between -180 and 180");
105
106
  }
106
107
  if (radius < 0 || radius > 50000) {
107
- throw new Error('Radius must be between 0 and 50000 meters');
108
+ throw new ValidationError("Radius must be between 0 and 50000 meters");
108
109
  }
109
- // Use POST request for stations endpoint
110
- const response = await fetch(`${this.client['baseUrl']}/v1/diesel-prices/stations`, {
111
- method: 'POST',
112
- headers: {
113
- 'Authorization': `Bearer ${this.client['apiKey']}`,
114
- 'Content-Type': 'application/json',
115
- 'User-Agent': 'oilpriceapi-node/0.4.0',
116
- 'X-SDK-Language': 'javascript',
117
- 'X-SDK-Version': '0.4.0',
118
- 'X-Client-Type': 'sdk',
119
- },
120
- body: JSON.stringify({ lat, lng, radius }),
110
+ return this.client["request"]("/v1/diesel-prices/stations", {}, {
111
+ method: "POST",
112
+ body: { lat, lng, radius },
121
113
  });
122
- if (!response.ok) {
123
- const errorBody = await response.text();
124
- let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
125
- try {
126
- const errorJson = JSON.parse(errorBody);
127
- errorMessage = errorJson.message || errorJson.error || errorMessage;
128
- }
129
- catch {
130
- // Use default error message
131
- }
132
- // Handle specific status codes
133
- if (response.status === 403) {
134
- throw new Error(`Diesel station queries not available on your plan. ${errorMessage}`);
135
- }
136
- if (response.status === 429) {
137
- throw new Error(`Diesel station query limit exceeded. ${errorMessage}`);
138
- }
139
- throw new Error(errorMessage);
140
- }
141
- const data = await response.json();
142
- return data;
143
114
  }
144
115
  }
@@ -0,0 +1,403 @@
1
+ /**
2
+ * Drilling Intelligence Resource
3
+ *
4
+ * Access US onshore drilling activity data including rig counts, well permits,
5
+ * frac spreads, DUC wells, completions, and production trends by basin.
6
+ */
7
+ import type { OilPriceAPI } from "../client.js";
8
+ /**
9
+ * Drilling intelligence data point
10
+ */
11
+ export interface DrillingIntelligenceData {
12
+ /** Record ID */
13
+ id: string;
14
+ /** Basin name */
15
+ basin?: string;
16
+ /** State */
17
+ state?: string;
18
+ /** Operator name */
19
+ operator?: string;
20
+ /** Metric type */
21
+ metric_type: string;
22
+ /** Metric value */
23
+ value: number;
24
+ /** Unit of measurement */
25
+ unit?: string;
26
+ /** Report date */
27
+ date: string;
28
+ /** Week number */
29
+ week?: number;
30
+ /** ISO timestamp when data was recorded */
31
+ timestamp: string;
32
+ /** Additional metadata */
33
+ metadata?: Record<string, unknown>;
34
+ }
35
+ /**
36
+ * Latest drilling intelligence summary
37
+ */
38
+ export interface LatestDrillingData {
39
+ /** Total active rigs */
40
+ total_rigs: number;
41
+ /** Total frac spreads */
42
+ total_frac_spreads: number;
43
+ /** Total well permits */
44
+ total_permits: number;
45
+ /** Total DUC wells */
46
+ total_duc_wells: number;
47
+ /** Total completions */
48
+ total_completions: number;
49
+ /** As of date */
50
+ as_of_date: string;
51
+ /** Additional metrics */
52
+ metrics?: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * Drilling intelligence summary by metric
56
+ */
57
+ export interface DrillingSummary {
58
+ /** Metric type */
59
+ metric: string;
60
+ /** Total count/value */
61
+ total: number;
62
+ /** Change from previous period */
63
+ change?: number;
64
+ /** Percentage change */
65
+ change_percent?: number;
66
+ /** Breakdown by basin or state */
67
+ breakdown?: Array<{
68
+ name: string;
69
+ value: number;
70
+ percentage?: number;
71
+ }>;
72
+ }
73
+ /**
74
+ * Drilling trend data
75
+ */
76
+ export interface DrillingTrend {
77
+ /** Date */
78
+ date: string;
79
+ /** Metric type */
80
+ metric: string;
81
+ /** Value */
82
+ value: number;
83
+ /** Moving average (if applicable) */
84
+ moving_average?: number;
85
+ /** Trend direction */
86
+ trend?: "up" | "down" | "flat";
87
+ }
88
+ /**
89
+ * Frac spread data
90
+ */
91
+ export interface FracSpreadData {
92
+ /** Basin name */
93
+ basin: string;
94
+ /** Number of active frac spreads */
95
+ active_spreads: number;
96
+ /** Change from previous week */
97
+ change?: number;
98
+ /** Date */
99
+ date: string;
100
+ }
101
+ /**
102
+ * Well permit data
103
+ */
104
+ export interface WellPermitData {
105
+ /** State */
106
+ state: string;
107
+ /** Basin */
108
+ basin?: string;
109
+ /** Number of permits issued */
110
+ permits: number;
111
+ /** Change from previous period */
112
+ change?: number;
113
+ /** Date */
114
+ date: string;
115
+ }
116
+ /**
117
+ * DUC (Drilled but Uncompleted) well data
118
+ */
119
+ export interface DUCWellData {
120
+ /** Basin name */
121
+ basin: string;
122
+ /** Number of DUC wells */
123
+ duc_count: number;
124
+ /** Change from previous month */
125
+ change?: number;
126
+ /** Date */
127
+ date: string;
128
+ }
129
+ /**
130
+ * Well completion data
131
+ */
132
+ export interface CompletionData {
133
+ /** Basin name */
134
+ basin: string;
135
+ /** Number of completions */
136
+ completions: number;
137
+ /** Change from previous period */
138
+ change?: number;
139
+ /** Date */
140
+ date: string;
141
+ }
142
+ /**
143
+ * Wells drilled data
144
+ */
145
+ export interface WellsDrilledData {
146
+ /** Basin name */
147
+ basin: string;
148
+ /** Number of wells drilled */
149
+ wells_drilled: number;
150
+ /** Change from previous period */
151
+ change?: number;
152
+ /** Date */
153
+ date: string;
154
+ }
155
+ /**
156
+ * Basin-specific drilling intelligence
157
+ */
158
+ export interface BasinDrillingData {
159
+ /** Basin name */
160
+ basin: string;
161
+ /** Active rigs */
162
+ active_rigs?: number;
163
+ /** Frac spreads */
164
+ frac_spreads?: number;
165
+ /** Well permits */
166
+ permits?: number;
167
+ /** DUC wells */
168
+ duc_wells?: number;
169
+ /** Completions */
170
+ completions?: number;
171
+ /** Wells drilled */
172
+ wells_drilled?: number;
173
+ /** As of date */
174
+ as_of_date: string;
175
+ /** Historical trend */
176
+ trend?: DrillingTrend[];
177
+ }
178
+ /**
179
+ * Drilling Intelligence Resource
180
+ *
181
+ * Access US onshore drilling activity data from EIA and Baker Hughes.
182
+ * Includes rig counts, well permits, frac spreads, DUC wells, completions,
183
+ * and basin-level breakdowns.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * import { OilPriceAPI } from 'oilpriceapi';
188
+ *
189
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
190
+ *
191
+ * // Get latest drilling intelligence
192
+ * const latest = await client.drilling.latest();
193
+ * console.log(`Active rigs: ${latest.total_rigs}`);
194
+ *
195
+ * // Get drilling trends
196
+ * const trends = await client.drilling.trends();
197
+ * trends.forEach(trend => {
198
+ * console.log(`${trend.date}: ${trend.metric} = ${trend.value}`);
199
+ * });
200
+ *
201
+ * // Get basin-specific data
202
+ * const permian = await client.drilling.basin('Permian');
203
+ * console.log(`Permian rigs: ${permian.active_rigs}`);
204
+ * ```
205
+ */
206
+ export declare class DrillingIntelligenceResource {
207
+ private client;
208
+ constructor(client: OilPriceAPI);
209
+ /**
210
+ * List all drilling intelligence records
211
+ *
212
+ * Returns all available drilling intelligence data points.
213
+ *
214
+ * @returns Array of drilling intelligence data
215
+ *
216
+ * @throws {OilPriceAPIError} If API request fails
217
+ * @throws {AuthenticationError} If API key is invalid
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const data = await client.drilling.list();
222
+ * console.log(`${data.length} records found`);
223
+ * ```
224
+ */
225
+ list(): Promise<DrillingIntelligenceData[]>;
226
+ /**
227
+ * Get latest drilling intelligence summary
228
+ *
229
+ * Returns the most recent snapshot of drilling activity metrics.
230
+ *
231
+ * @returns Latest drilling intelligence data
232
+ *
233
+ * @throws {OilPriceAPIError} If API request fails
234
+ * @throws {AuthenticationError} If API key is invalid
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * const latest = await client.drilling.latest();
239
+ * console.log(`Total active rigs: ${latest.total_rigs}`);
240
+ * console.log(`Frac spreads: ${latest.total_frac_spreads}`);
241
+ * console.log(`As of: ${latest.as_of_date}`);
242
+ * ```
243
+ */
244
+ latest(): Promise<LatestDrillingData>;
245
+ /**
246
+ * Get drilling intelligence summary
247
+ *
248
+ * Returns aggregated summary of drilling metrics by type.
249
+ *
250
+ * @returns Array of drilling summaries by metric
251
+ *
252
+ * @throws {OilPriceAPIError} If API request fails
253
+ * @throws {AuthenticationError} If API key is invalid
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * const summary = await client.drilling.summary();
258
+ * summary.forEach(metric => {
259
+ * console.log(`${metric.metric}: ${metric.total}`);
260
+ * if (metric.change_percent) {
261
+ * console.log(` Change: ${metric.change_percent}%`);
262
+ * }
263
+ * });
264
+ * ```
265
+ */
266
+ summary(): Promise<DrillingSummary[]>;
267
+ /**
268
+ * Get drilling activity trends
269
+ *
270
+ * Returns time series data showing trends in drilling metrics.
271
+ *
272
+ * @returns Array of drilling trend data points
273
+ *
274
+ * @throws {OilPriceAPIError} If API request fails
275
+ * @throws {AuthenticationError} If API key is invalid
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const trends = await client.drilling.trends();
280
+ * trends.forEach(point => {
281
+ * console.log(`${point.date}: ${point.metric} = ${point.value} (${point.trend})`);
282
+ * });
283
+ * ```
284
+ */
285
+ trends(): Promise<DrillingTrend[]>;
286
+ /**
287
+ * Get frac spread data
288
+ *
289
+ * Returns active frac spread counts by basin.
290
+ *
291
+ * @returns Array of frac spread data by basin
292
+ *
293
+ * @throws {OilPriceAPIError} If API request fails
294
+ * @throws {AuthenticationError} If API key is invalid
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const fracSpreads = await client.drilling.fracSpreads();
299
+ * fracSpreads.forEach(spread => {
300
+ * console.log(`${spread.basin}: ${spread.active_spreads} spreads`);
301
+ * });
302
+ * ```
303
+ */
304
+ fracSpreads(): Promise<FracSpreadData[]>;
305
+ /**
306
+ * Get well permit data
307
+ *
308
+ * Returns well permits issued by state and basin.
309
+ *
310
+ * @returns Array of well permit data
311
+ *
312
+ * @throws {OilPriceAPIError} If API request fails
313
+ * @throws {AuthenticationError} If API key is invalid
314
+ *
315
+ * @example
316
+ * ```typescript
317
+ * const permits = await client.drilling.wellPermits();
318
+ * permits.forEach(permit => {
319
+ * console.log(`${permit.state}: ${permit.permits} permits`);
320
+ * });
321
+ * ```
322
+ */
323
+ wellPermits(): Promise<WellPermitData[]>;
324
+ /**
325
+ * Get DUC well data
326
+ *
327
+ * Returns drilled but uncompleted (DUC) well counts by basin.
328
+ *
329
+ * @returns Array of DUC well data
330
+ *
331
+ * @throws {OilPriceAPIError} If API request fails
332
+ * @throws {AuthenticationError} If API key is invalid
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * const ducWells = await client.drilling.ducWells();
337
+ * ducWells.forEach(duc => {
338
+ * console.log(`${duc.basin}: ${duc.duc_count} DUC wells`);
339
+ * });
340
+ * ```
341
+ */
342
+ ducWells(): Promise<DUCWellData[]>;
343
+ /**
344
+ * Get well completion data
345
+ *
346
+ * Returns well completion counts by basin.
347
+ *
348
+ * @returns Array of completion data
349
+ *
350
+ * @throws {OilPriceAPIError} If API request fails
351
+ * @throws {AuthenticationError} If API key is invalid
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * const completions = await client.drilling.completions();
356
+ * completions.forEach(comp => {
357
+ * console.log(`${comp.basin}: ${comp.completions} completions`);
358
+ * });
359
+ * ```
360
+ */
361
+ completions(): Promise<CompletionData[]>;
362
+ /**
363
+ * Get wells drilled data
364
+ *
365
+ * Returns wells drilled counts by basin.
366
+ *
367
+ * @returns Array of wells drilled data
368
+ *
369
+ * @throws {OilPriceAPIError} If API request fails
370
+ * @throws {AuthenticationError} If API key is invalid
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * const drilled = await client.drilling.wellsDrilled();
375
+ * drilled.forEach(data => {
376
+ * console.log(`${data.basin}: ${data.wells_drilled} wells drilled`);
377
+ * });
378
+ * ```
379
+ */
380
+ wellsDrilled(): Promise<WellsDrilledData[]>;
381
+ /**
382
+ * Get basin-specific drilling intelligence
383
+ *
384
+ * Returns comprehensive drilling data for a specific basin.
385
+ *
386
+ * @param name - Basin name (e.g., "Permian", "Eagle Ford", "Bakken")
387
+ * @returns Basin drilling intelligence data
388
+ *
389
+ * @throws {NotFoundError} If basin not found
390
+ * @throws {OilPriceAPIError} If API request fails
391
+ * @throws {AuthenticationError} If API key is invalid
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * const permian = await client.drilling.basin('Permian');
396
+ * console.log(`Permian Basin as of ${permian.as_of_date}:`);
397
+ * console.log(` Active rigs: ${permian.active_rigs}`);
398
+ * console.log(` Frac spreads: ${permian.frac_spreads}`);
399
+ * console.log(` DUC wells: ${permian.duc_wells}`);
400
+ * ```
401
+ */
402
+ basin(name: string): Promise<BasinDrillingData>;
403
+ }