oilpriceapi 0.7.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 (60) hide show
  1. package/README.md +43 -11
  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 +33 -2
  30. package/dist/client.js +70 -14
  31. package/dist/errors.d.ts +6 -0
  32. package/dist/errors.js +25 -16
  33. package/dist/index.d.ts +16 -2
  34. package/dist/index.js +24 -1
  35. package/dist/resources/alerts.js +31 -77
  36. package/dist/resources/analytics.js +8 -7
  37. package/dist/resources/bunker-fuels.js +5 -4
  38. package/dist/resources/commodities.js +2 -1
  39. package/dist/resources/data-quality.js +2 -1
  40. package/dist/resources/data-sources.js +21 -77
  41. package/dist/resources/diesel.d.ts +1 -1
  42. package/dist/resources/diesel.js +9 -38
  43. package/dist/resources/drilling.js +2 -1
  44. package/dist/resources/ei/drilling-productivity.js +2 -1
  45. package/dist/resources/ei/forecasts.js +2 -1
  46. package/dist/resources/ei/frac-focus.js +4 -3
  47. package/dist/resources/ei/index.js +2 -1
  48. package/dist/resources/ei/oil-inventories.js +2 -1
  49. package/dist/resources/ei/opec-production.js +2 -1
  50. package/dist/resources/ei/rig-counts.js +2 -1
  51. package/dist/resources/ei/well-permits.js +2 -1
  52. package/dist/resources/forecasts.js +2 -1
  53. package/dist/resources/futures.js +9 -8
  54. package/dist/resources/storage.js +2 -1
  55. package/dist/resources/webhooks.d.ts +36 -0
  56. package/dist/resources/webhooks.js +60 -67
  57. package/dist/types.d.ts +2 -1
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +2 -2
  60. package/package.json +15 -6
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+ /**
3
+ * Data Sources Resource
4
+ *
5
+ * Manage custom data source integrations for Bring Your Own Source (BYOS) feature.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DataSourcesResource = void 0;
9
+ const errors_js_1 = require("../errors.js");
10
+ /**
11
+ * Data Sources Resource
12
+ *
13
+ * Manage custom data source integrations for importing your own price data
14
+ * into the platform (BYOS - Bring Your Own Source feature).
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { OilPriceAPI } from 'oilpriceapi';
19
+ *
20
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
21
+ *
22
+ * // Create a data source
23
+ * const source = await client.dataSources.create({
24
+ * name: 'Internal Price Feed',
25
+ * type: 'api',
26
+ * config: {
27
+ * url: 'https://internal.company.com/api/prices',
28
+ * auth_type: 'bearer',
29
+ * token: 'secret-token'
30
+ * },
31
+ * sync_frequency_minutes: 30
32
+ * });
33
+ *
34
+ * // Test the data source
35
+ * const test = await client.dataSources.test(source.id);
36
+ * console.log(`Test result: ${test.success}`);
37
+ *
38
+ * // Check health
39
+ * const health = await client.dataSources.health(source.id);
40
+ * console.log(`Health: ${health.status}`);
41
+ * console.log(`Success rate: ${health.success_rate}%`);
42
+ *
43
+ * // View sync logs
44
+ * const logs = await client.dataSources.logs(source.id);
45
+ * logs.forEach(log => {
46
+ * console.log(`${log.started_at}: ${log.status} - ${log.records_synced} records`);
47
+ * });
48
+ * ```
49
+ */
50
+ class DataSourcesResource {
51
+ constructor(client) {
52
+ this.client = client;
53
+ }
54
+ /**
55
+ * List all data sources
56
+ *
57
+ * @returns Array of data sources
58
+ *
59
+ * @throws {OilPriceAPIError} If API request fails
60
+ * @throws {AuthenticationError} If API key is invalid
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const sources = await client.dataSources.list();
65
+ * sources.forEach(source => {
66
+ * console.log(`${source.name}: ${source.status}`);
67
+ * console.log(` Success rate: ${source.successful_syncs}/${source.successful_syncs + source.failed_syncs}`);
68
+ * });
69
+ * ```
70
+ */
71
+ async list() {
72
+ const response = await this.client["request"]("/v1/data-sources", {});
73
+ return Array.isArray(response) ? response : response.data_sources;
74
+ }
75
+ /**
76
+ * Get a specific data source
77
+ *
78
+ * @param id - Data source ID
79
+ * @returns Data source details
80
+ *
81
+ * @throws {NotFoundError} If data source not found
82
+ * @throws {OilPriceAPIError} If API request fails
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const source = await client.dataSources.get('source-id');
87
+ * console.log(`${source.name} (${source.type})`);
88
+ * console.log(`Last sync: ${source.last_sync_at}`);
89
+ * ```
90
+ */
91
+ async get(id) {
92
+ if (!id || typeof id !== "string") {
93
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
94
+ }
95
+ const response = await this.client["request"](`/v1/data-sources/${id}`, {});
96
+ return "data_source" in response ? response.data_source : response;
97
+ }
98
+ /**
99
+ * Create a new data source
100
+ *
101
+ * @param params - Data source configuration
102
+ * @returns Created data source
103
+ *
104
+ * @throws {OilPriceAPIError} If API request fails
105
+ * @throws {AuthenticationError} If API key is invalid
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const source = await client.dataSources.create({
110
+ * name: 'SFTP Price Feed',
111
+ * type: 'sftp',
112
+ * config: {
113
+ * host: 'sftp.example.com',
114
+ * username: 'user',
115
+ * password: 'pass',
116
+ * path: '/prices/daily.csv'
117
+ * },
118
+ * sync_frequency_minutes: 1440 // Daily
119
+ * });
120
+ * ```
121
+ */
122
+ async create(params) {
123
+ if (!params.name || typeof params.name !== "string") {
124
+ throw new errors_js_1.ValidationError("Data source name is required");
125
+ }
126
+ if (!params.type) {
127
+ throw new errors_js_1.ValidationError("Data source type is required");
128
+ }
129
+ if (!params.config || typeof params.config !== "object") {
130
+ throw new errors_js_1.ValidationError("Data source config is required");
131
+ }
132
+ const response = await this.client["request"]("/v1/data-sources", {}, {
133
+ method: "POST",
134
+ body: {
135
+ data_source: {
136
+ name: params.name,
137
+ type: params.type,
138
+ config: params.config,
139
+ enabled: params.enabled ?? true,
140
+ sync_frequency_minutes: params.sync_frequency_minutes ?? 60,
141
+ metadata: params.metadata,
142
+ },
143
+ },
144
+ });
145
+ return "data_source" in response ? response.data_source : response;
146
+ }
147
+ /**
148
+ * Update a data source
149
+ *
150
+ * @param id - Data source ID
151
+ * @param params - Fields to update
152
+ * @returns Updated data source
153
+ *
154
+ * @throws {NotFoundError} If data source not found
155
+ * @throws {OilPriceAPIError} If API request fails
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * // Pause a data source
160
+ * await client.dataSources.update(sourceId, { enabled: false });
161
+ *
162
+ * // Update sync frequency
163
+ * await client.dataSources.update(sourceId, {
164
+ * sync_frequency_minutes: 120
165
+ * });
166
+ * ```
167
+ */
168
+ async update(id, params) {
169
+ if (!id || typeof id !== "string") {
170
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
171
+ }
172
+ const response = await this.client["request"](`/v1/data-sources/${id}`, {}, {
173
+ method: "PATCH",
174
+ body: { data_source: params },
175
+ });
176
+ return "data_source" in response ? response.data_source : response;
177
+ }
178
+ /**
179
+ * Delete a data source
180
+ *
181
+ * @param id - Data source ID
182
+ *
183
+ * @throws {NotFoundError} If data source not found
184
+ * @throws {OilPriceAPIError} If API request fails
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * await client.dataSources.delete(sourceId);
189
+ * console.log('Data source deleted');
190
+ * ```
191
+ */
192
+ async delete(id) {
193
+ if (!id || typeof id !== "string") {
194
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
195
+ }
196
+ await this.client["request"](`/v1/data-sources/${id}`, {}, { method: "DELETE" });
197
+ }
198
+ /**
199
+ * Test a data source connection
200
+ *
201
+ * @param id - Data source ID
202
+ * @returns Test results
203
+ *
204
+ * @throws {NotFoundError} If data source not found
205
+ * @throws {OilPriceAPIError} If API request fails
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const test = await client.dataSources.test(sourceId);
210
+ * console.log(`Connection test: ${test.success ? 'passed' : 'failed'}`);
211
+ * console.log(`Duration: ${test.duration_ms}ms`);
212
+ * if (test.sample_data) {
213
+ * console.log(`Sample records: ${test.sample_data.length}`);
214
+ * }
215
+ * ```
216
+ */
217
+ async test(id) {
218
+ if (!id || typeof id !== "string") {
219
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
220
+ }
221
+ return this.client["request"](`/v1/data-sources/${id}/test`, {}, { method: "POST" });
222
+ }
223
+ /**
224
+ * Get data source sync logs
225
+ *
226
+ * @param id - Data source ID
227
+ * @returns Array of sync log entries
228
+ *
229
+ * @throws {NotFoundError} If data source not found
230
+ * @throws {OilPriceAPIError} If API request fails
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * const logs = await client.dataSources.logs(sourceId);
235
+ * logs.forEach(log => {
236
+ * console.log(`${log.started_at}: ${log.status}`);
237
+ * if (log.records_synced) {
238
+ * console.log(` ${log.records_synced} records in ${log.duration_ms}ms`);
239
+ * }
240
+ * });
241
+ * ```
242
+ */
243
+ async logs(id) {
244
+ if (!id || typeof id !== "string") {
245
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
246
+ }
247
+ const response = await this.client["request"](`/v1/data-sources/${id}/logs`, {});
248
+ return Array.isArray(response) ? response : response.logs;
249
+ }
250
+ /**
251
+ * Get data source health metrics
252
+ *
253
+ * @param id - Data source ID
254
+ * @returns Health metrics
255
+ *
256
+ * @throws {NotFoundError} If data source not found
257
+ * @throws {OilPriceAPIError} If API request fails
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * const health = await client.dataSources.health(sourceId);
262
+ * console.log(`Status: ${health.status}`);
263
+ * console.log(`Success rate: ${health.success_rate}%`);
264
+ * console.log(`Avg duration: ${health.avg_duration_ms}ms`);
265
+ * ```
266
+ */
267
+ async health(id) {
268
+ if (!id || typeof id !== "string") {
269
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
270
+ }
271
+ return this.client["request"](`/v1/data-sources/${id}/health`, {});
272
+ }
273
+ /**
274
+ * Rotate data source credentials
275
+ *
276
+ * Updates stored credentials with new values and re-encrypts them.
277
+ *
278
+ * @param id - Data source ID
279
+ * @returns Rotation result
280
+ *
281
+ * @throws {NotFoundError} If data source not found
282
+ * @throws {OilPriceAPIError} If API request fails
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const result = await client.dataSources.rotateCredentials(sourceId);
287
+ * console.log(`Credential rotation: ${result.success ? 'success' : 'failed'}`);
288
+ * ```
289
+ */
290
+ async rotateCredentials(id) {
291
+ if (!id || typeof id !== "string") {
292
+ throw new errors_js_1.ValidationError("Data source ID must be a non-empty string");
293
+ }
294
+ return this.client["request"](`/v1/data-sources/${id}/rotate-credentials`, {}, { method: "POST" });
295
+ }
296
+ }
297
+ exports.DataSourcesResource = DataSourcesResource;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DieselResource = void 0;
4
+ const errors_js_1 = require("../errors.js");
5
+ /**
6
+ * Diesel Prices resource
7
+ *
8
+ * Provides access to state-level diesel averages and station-level pricing.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Get state average
13
+ * const caPrice = await client.diesel.getPrice('CA');
14
+ * console.log(`California diesel: $${caPrice.price}/gal`);
15
+ *
16
+ * // Get nearby stations
17
+ * const stations = await client.diesel.getStations({
18
+ * lat: 37.7749,
19
+ * lng: -122.4194,
20
+ * radius: 8047 // 5 miles in meters
21
+ * });
22
+ *
23
+ * console.log(`Found ${stations.stations.length} stations`);
24
+ * stations.stations.forEach(station => {
25
+ * console.log(`${station.name}: ${station.formatted_price}`);
26
+ * });
27
+ * ```
28
+ */
29
+ class DieselResource {
30
+ constructor(client) {
31
+ this.client = client;
32
+ }
33
+ /**
34
+ * Get average diesel price for a US state
35
+ *
36
+ * Returns EIA state-level average diesel price. This endpoint is free
37
+ * and included in all tiers.
38
+ *
39
+ * @param state - Two-letter US state code (e.g., "CA", "TX", "NY")
40
+ * @returns State average diesel price
41
+ *
42
+ * @throws {NotFoundError} If state code is invalid
43
+ * @throws {AuthenticationError} If API key is invalid
44
+ * @throws {RateLimitError} If rate limit exceeded
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Get California diesel price
49
+ * const caPrice = await client.diesel.getPrice('CA');
50
+ * console.log(`CA diesel: $${caPrice.price}/gal`);
51
+ * console.log(`Source: ${caPrice.source}`);
52
+ * console.log(`Updated: ${caPrice.updated_at}`);
53
+ * ```
54
+ */
55
+ async getPrice(state) {
56
+ if (!state || state.length !== 2) {
57
+ throw new errors_js_1.ValidationError('State must be a 2-letter US state code (e.g., "CA", "TX")');
58
+ }
59
+ const response = await this.client["request"]("/v1/diesel-prices", { state: state.toUpperCase() });
60
+ return response.regional_average;
61
+ }
62
+ /**
63
+ * Get nearby diesel stations with current pricing
64
+ *
65
+ * Returns station-level diesel prices within specified radius using Google Maps data.
66
+ *
67
+ * **Pricing:** Included in paid tiers:
68
+ * - Exploration: 100 station queries/month
69
+ * - Starter: 500 station queries/month
70
+ * - Professional: 2,000 station queries/month
71
+ * - Business: 5,000 station queries/month
72
+ *
73
+ * **Caching:** Results are cached for 24 hours to minimize costs.
74
+ *
75
+ * @param options - Search parameters (lat, lng, radius)
76
+ * @returns Nearby stations with prices and regional average
77
+ *
78
+ * @throws {AuthenticationError} If API key is invalid
79
+ * @throws {RateLimitError} If monthly station query limit exceeded
80
+ * @throws {Error} If coordinates are invalid
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Get stations near San Francisco
85
+ * const result = await client.diesel.getStations({
86
+ * lat: 37.7749,
87
+ * lng: -122.4194,
88
+ * radius: 8047 // 5 miles
89
+ * });
90
+ *
91
+ * console.log(`Regional avg: $${result.regional_average.price}/gal`);
92
+ * console.log(`Found ${result.stations.length} stations`);
93
+ *
94
+ * // Find cheapest station
95
+ * const cheapest = result.stations.reduce((min, s) =>
96
+ * s.diesel_price < min.diesel_price ? s : min
97
+ * );
98
+ * console.log(`Cheapest: ${cheapest.name} at ${cheapest.formatted_price}`);
99
+ * ```
100
+ */
101
+ async getStations(options) {
102
+ const { lat, lng, radius = 8047 } = options;
103
+ // Validate coordinates
104
+ if (lat < -90 || lat > 90) {
105
+ throw new errors_js_1.ValidationError("Latitude must be between -90 and 90");
106
+ }
107
+ if (lng < -180 || lng > 180) {
108
+ throw new errors_js_1.ValidationError("Longitude must be between -180 and 180");
109
+ }
110
+ if (radius < 0 || radius > 50000) {
111
+ throw new errors_js_1.ValidationError("Radius must be between 0 and 50000 meters");
112
+ }
113
+ return this.client["request"]("/v1/diesel-prices/stations", {}, {
114
+ method: "POST",
115
+ body: { lat, lng, radius },
116
+ });
117
+ }
118
+ }
119
+ exports.DieselResource = DieselResource;
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+ /**
3
+ * Drilling Intelligence Resource
4
+ *
5
+ * Access US onshore drilling activity data including rig counts, well permits,
6
+ * frac spreads, DUC wells, completions, and production trends by basin.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DrillingIntelligenceResource = void 0;
10
+ const errors_js_1 = require("../errors.js");
11
+ /**
12
+ * Drilling Intelligence Resource
13
+ *
14
+ * Access US onshore drilling activity data from EIA and Baker Hughes.
15
+ * Includes rig counts, well permits, frac spreads, DUC wells, completions,
16
+ * and basin-level breakdowns.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { OilPriceAPI } from 'oilpriceapi';
21
+ *
22
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
23
+ *
24
+ * // Get latest drilling intelligence
25
+ * const latest = await client.drilling.latest();
26
+ * console.log(`Active rigs: ${latest.total_rigs}`);
27
+ *
28
+ * // Get drilling trends
29
+ * const trends = await client.drilling.trends();
30
+ * trends.forEach(trend => {
31
+ * console.log(`${trend.date}: ${trend.metric} = ${trend.value}`);
32
+ * });
33
+ *
34
+ * // Get basin-specific data
35
+ * const permian = await client.drilling.basin('Permian');
36
+ * console.log(`Permian rigs: ${permian.active_rigs}`);
37
+ * ```
38
+ */
39
+ class DrillingIntelligenceResource {
40
+ constructor(client) {
41
+ this.client = client;
42
+ }
43
+ /**
44
+ * List all drilling intelligence records
45
+ *
46
+ * Returns all available drilling intelligence data points.
47
+ *
48
+ * @returns Array of drilling intelligence data
49
+ *
50
+ * @throws {OilPriceAPIError} If API request fails
51
+ * @throws {AuthenticationError} If API key is invalid
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const data = await client.drilling.list();
56
+ * console.log(`${data.length} records found`);
57
+ * ```
58
+ */
59
+ async list() {
60
+ const response = await this.client["request"]("/v1/drilling-intelligence", {});
61
+ return Array.isArray(response) ? response : response.data;
62
+ }
63
+ /**
64
+ * Get latest drilling intelligence summary
65
+ *
66
+ * Returns the most recent snapshot of drilling activity metrics.
67
+ *
68
+ * @returns Latest drilling intelligence data
69
+ *
70
+ * @throws {OilPriceAPIError} If API request fails
71
+ * @throws {AuthenticationError} If API key is invalid
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const latest = await client.drilling.latest();
76
+ * console.log(`Total active rigs: ${latest.total_rigs}`);
77
+ * console.log(`Frac spreads: ${latest.total_frac_spreads}`);
78
+ * console.log(`As of: ${latest.as_of_date}`);
79
+ * ```
80
+ */
81
+ async latest() {
82
+ return this.client["request"]("/v1/drilling-intelligence/latest", {});
83
+ }
84
+ /**
85
+ * Get drilling intelligence summary
86
+ *
87
+ * Returns aggregated summary of drilling metrics by type.
88
+ *
89
+ * @returns Array of drilling summaries by metric
90
+ *
91
+ * @throws {OilPriceAPIError} If API request fails
92
+ * @throws {AuthenticationError} If API key is invalid
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const summary = await client.drilling.summary();
97
+ * summary.forEach(metric => {
98
+ * console.log(`${metric.metric}: ${metric.total}`);
99
+ * if (metric.change_percent) {
100
+ * console.log(` Change: ${metric.change_percent}%`);
101
+ * }
102
+ * });
103
+ * ```
104
+ */
105
+ async summary() {
106
+ const response = await this.client["request"]("/v1/drilling-intelligence/summary", {});
107
+ return Array.isArray(response) ? response : response.summary;
108
+ }
109
+ /**
110
+ * Get drilling activity trends
111
+ *
112
+ * Returns time series data showing trends in drilling metrics.
113
+ *
114
+ * @returns Array of drilling trend data points
115
+ *
116
+ * @throws {OilPriceAPIError} If API request fails
117
+ * @throws {AuthenticationError} If API key is invalid
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const trends = await client.drilling.trends();
122
+ * trends.forEach(point => {
123
+ * console.log(`${point.date}: ${point.metric} = ${point.value} (${point.trend})`);
124
+ * });
125
+ * ```
126
+ */
127
+ async trends() {
128
+ const response = await this.client["request"]("/v1/drilling-intelligence/trends", {});
129
+ return Array.isArray(response) ? response : response.trends;
130
+ }
131
+ /**
132
+ * Get frac spread data
133
+ *
134
+ * Returns active frac spread counts by basin.
135
+ *
136
+ * @returns Array of frac spread data by basin
137
+ *
138
+ * @throws {OilPriceAPIError} If API request fails
139
+ * @throws {AuthenticationError} If API key is invalid
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const fracSpreads = await client.drilling.fracSpreads();
144
+ * fracSpreads.forEach(spread => {
145
+ * console.log(`${spread.basin}: ${spread.active_spreads} spreads`);
146
+ * });
147
+ * ```
148
+ */
149
+ async fracSpreads() {
150
+ const response = await this.client["request"]("/v1/drilling-intelligence/frac-spreads", {});
151
+ return Array.isArray(response) ? response : response.data;
152
+ }
153
+ /**
154
+ * Get well permit data
155
+ *
156
+ * Returns well permits issued by state and basin.
157
+ *
158
+ * @returns Array of well permit data
159
+ *
160
+ * @throws {OilPriceAPIError} If API request fails
161
+ * @throws {AuthenticationError} If API key is invalid
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const permits = await client.drilling.wellPermits();
166
+ * permits.forEach(permit => {
167
+ * console.log(`${permit.state}: ${permit.permits} permits`);
168
+ * });
169
+ * ```
170
+ */
171
+ async wellPermits() {
172
+ const response = await this.client["request"]("/v1/drilling-intelligence/well-permits", {});
173
+ return Array.isArray(response) ? response : response.data;
174
+ }
175
+ /**
176
+ * Get DUC well data
177
+ *
178
+ * Returns drilled but uncompleted (DUC) well counts by basin.
179
+ *
180
+ * @returns Array of DUC well data
181
+ *
182
+ * @throws {OilPriceAPIError} If API request fails
183
+ * @throws {AuthenticationError} If API key is invalid
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const ducWells = await client.drilling.ducWells();
188
+ * ducWells.forEach(duc => {
189
+ * console.log(`${duc.basin}: ${duc.duc_count} DUC wells`);
190
+ * });
191
+ * ```
192
+ */
193
+ async ducWells() {
194
+ const response = await this.client["request"]("/v1/drilling-intelligence/duc-wells", {});
195
+ return Array.isArray(response) ? response : response.data;
196
+ }
197
+ /**
198
+ * Get well completion data
199
+ *
200
+ * Returns well completion counts by basin.
201
+ *
202
+ * @returns Array of completion data
203
+ *
204
+ * @throws {OilPriceAPIError} If API request fails
205
+ * @throws {AuthenticationError} If API key is invalid
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const completions = await client.drilling.completions();
210
+ * completions.forEach(comp => {
211
+ * console.log(`${comp.basin}: ${comp.completions} completions`);
212
+ * });
213
+ * ```
214
+ */
215
+ async completions() {
216
+ const response = await this.client["request"]("/v1/drilling-intelligence/completions", {});
217
+ return Array.isArray(response) ? response : response.data;
218
+ }
219
+ /**
220
+ * Get wells drilled data
221
+ *
222
+ * Returns wells drilled counts by basin.
223
+ *
224
+ * @returns Array of wells drilled data
225
+ *
226
+ * @throws {OilPriceAPIError} If API request fails
227
+ * @throws {AuthenticationError} If API key is invalid
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const drilled = await client.drilling.wellsDrilled();
232
+ * drilled.forEach(data => {
233
+ * console.log(`${data.basin}: ${data.wells_drilled} wells drilled`);
234
+ * });
235
+ * ```
236
+ */
237
+ async wellsDrilled() {
238
+ const response = await this.client["request"]("/v1/drilling-intelligence/wells-drilled", {});
239
+ return Array.isArray(response) ? response : response.data;
240
+ }
241
+ /**
242
+ * Get basin-specific drilling intelligence
243
+ *
244
+ * Returns comprehensive drilling data for a specific basin.
245
+ *
246
+ * @param name - Basin name (e.g., "Permian", "Eagle Ford", "Bakken")
247
+ * @returns Basin drilling intelligence data
248
+ *
249
+ * @throws {NotFoundError} If basin not found
250
+ * @throws {OilPriceAPIError} If API request fails
251
+ * @throws {AuthenticationError} If API key is invalid
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * const permian = await client.drilling.basin('Permian');
256
+ * console.log(`Permian Basin as of ${permian.as_of_date}:`);
257
+ * console.log(` Active rigs: ${permian.active_rigs}`);
258
+ * console.log(` Frac spreads: ${permian.frac_spreads}`);
259
+ * console.log(` DUC wells: ${permian.duc_wells}`);
260
+ * ```
261
+ */
262
+ async basin(name) {
263
+ if (!name || typeof name !== "string") {
264
+ throw new errors_js_1.ValidationError("Basin name must be a non-empty string");
265
+ }
266
+ return this.client["request"](`/v1/drilling-intelligence/basin/${name}`, {});
267
+ }
268
+ }
269
+ exports.DrillingIntelligenceResource = DrillingIntelligenceResource;