oilpriceapi 0.6.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +418 -123
  2. package/dist/cjs/client.js +490 -0
  3. package/dist/cjs/errors.js +80 -0
  4. package/dist/cjs/index.js +82 -0
  5. package/dist/cjs/package.json +1 -0
  6. package/dist/cjs/resources/alerts.js +387 -0
  7. package/dist/cjs/resources/analytics.js +226 -0
  8. package/dist/cjs/resources/bunker-fuels.js +196 -0
  9. package/dist/cjs/resources/commodities.js +115 -0
  10. package/dist/cjs/resources/data-quality.js +144 -0
  11. package/dist/cjs/resources/data-sources.js +297 -0
  12. package/dist/cjs/resources/diesel.js +119 -0
  13. package/dist/cjs/resources/drilling.js +269 -0
  14. package/dist/cjs/resources/ei/drilling-productivity.js +108 -0
  15. package/dist/cjs/resources/ei/forecasts.js +106 -0
  16. package/dist/cjs/resources/ei/frac-focus.js +155 -0
  17. package/dist/cjs/resources/ei/index.js +98 -0
  18. package/dist/cjs/resources/ei/oil-inventories.js +97 -0
  19. package/dist/cjs/resources/ei/opec-production.js +97 -0
  20. package/dist/cjs/resources/ei/rig-counts.js +93 -0
  21. package/dist/cjs/resources/ei/well-permits.js +124 -0
  22. package/dist/cjs/resources/forecasts.js +162 -0
  23. package/dist/cjs/resources/futures.js +233 -0
  24. package/dist/cjs/resources/rig-counts.js +161 -0
  25. package/dist/cjs/resources/storage.js +166 -0
  26. package/dist/cjs/resources/webhooks.js +294 -0
  27. package/dist/cjs/types.js +2 -0
  28. package/dist/cjs/version.js +24 -0
  29. package/dist/client.d.ts +116 -5
  30. package/dist/client.js +169 -47
  31. package/dist/errors.d.ts +6 -0
  32. package/dist/errors.js +25 -16
  33. package/dist/index.d.ts +45 -6
  34. package/dist/index.js +40 -3
  35. package/dist/resources/alerts.d.ts +52 -15
  36. package/dist/resources/alerts.js +121 -109
  37. package/dist/resources/analytics.d.ts +325 -0
  38. package/dist/resources/analytics.js +222 -0
  39. package/dist/resources/bunker-fuels.d.ts +270 -0
  40. package/dist/resources/bunker-fuels.js +192 -0
  41. package/dist/resources/commodities.d.ts +148 -0
  42. package/dist/resources/commodities.js +111 -0
  43. package/dist/resources/data-quality.d.ts +229 -0
  44. package/dist/resources/data-quality.js +140 -0
  45. package/dist/resources/data-sources.d.ts +365 -0
  46. package/dist/resources/data-sources.js +293 -0
  47. package/dist/resources/diesel.d.ts +1 -1
  48. package/dist/resources/diesel.js +9 -38
  49. package/dist/resources/drilling.d.ts +403 -0
  50. package/dist/resources/drilling.js +265 -0
  51. package/dist/resources/ei/drilling-productivity.d.ts +173 -0
  52. package/dist/resources/ei/drilling-productivity.js +104 -0
  53. package/dist/resources/ei/forecasts.d.ts +177 -0
  54. package/dist/resources/ei/forecasts.js +102 -0
  55. package/dist/resources/ei/frac-focus.d.ts +212 -0
  56. package/dist/resources/ei/frac-focus.js +151 -0
  57. package/dist/resources/ei/index.d.ts +140 -0
  58. package/dist/resources/ei/index.js +88 -0
  59. package/dist/resources/ei/oil-inventories.d.ts +155 -0
  60. package/dist/resources/ei/oil-inventories.js +93 -0
  61. package/dist/resources/ei/opec-production.d.ts +146 -0
  62. package/dist/resources/ei/opec-production.js +93 -0
  63. package/dist/resources/ei/rig-counts.d.ts +131 -0
  64. package/dist/resources/ei/rig-counts.js +89 -0
  65. package/dist/resources/ei/well-permits.d.ts +178 -0
  66. package/dist/resources/ei/well-permits.js +120 -0
  67. package/dist/resources/forecasts.d.ts +200 -0
  68. package/dist/resources/forecasts.js +158 -0
  69. package/dist/resources/futures.d.ts +322 -0
  70. package/dist/resources/futures.js +229 -0
  71. package/dist/resources/rig-counts.d.ts +221 -0
  72. package/dist/resources/rig-counts.js +157 -0
  73. package/dist/resources/storage.d.ts +182 -0
  74. package/dist/resources/storage.js +162 -0
  75. package/dist/resources/webhooks.d.ts +326 -0
  76. package/dist/resources/webhooks.js +290 -0
  77. package/dist/types.d.ts +79 -8
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +2 -2
  80. package/package.json +17 -8
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Futures Resource
3
+ *
4
+ * Access futures contract data including latest prices, historical data,
5
+ * OHLC, intraday, spreads, curves, and continuous contracts.
6
+ */
7
+ import { ValidationError } from "../errors.js";
8
+ /**
9
+ * Futures Resource
10
+ *
11
+ * Access futures contract data including latest, historical, OHLC, intraday,
12
+ * spreads, curves, and continuous contracts.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { OilPriceAPI } from 'oilpriceapi';
17
+ *
18
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
19
+ *
20
+ * // Get latest price
21
+ * const latest = await client.futures.latest('CL.1');
22
+ * console.log(`${latest.contract}: $${latest.price}`);
23
+ *
24
+ * // Get OHLC data
25
+ * const ohlc = await client.futures.ohlc('CL.1', '2024-01-15');
26
+ * console.log(`High: $${ohlc.high}, Low: $${ohlc.low}`);
27
+ *
28
+ * // Get futures curve
29
+ * const curve = await client.futures.curve('CL');
30
+ * curve.curve.forEach(point => {
31
+ * console.log(`${point.months_out}mo: $${point.price}`);
32
+ * });
33
+ * ```
34
+ */
35
+ export class FuturesResource {
36
+ constructor(client) {
37
+ this.client = client;
38
+ }
39
+ /**
40
+ * Get latest price for a futures contract
41
+ *
42
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
43
+ * @returns Latest futures price data
44
+ *
45
+ * @throws {NotFoundError} If contract not found
46
+ * @throws {OilPriceAPIError} If API request fails
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const price = await client.futures.latest('CL.1');
51
+ * console.log(`WTI Front Month: $${price.price}`);
52
+ * ```
53
+ */
54
+ async latest(contract) {
55
+ if (!contract || typeof contract !== "string") {
56
+ throw new ValidationError("Contract symbol must be a non-empty string");
57
+ }
58
+ return this.client["request"](`/v1/futures/${contract}`, {});
59
+ }
60
+ /**
61
+ * Get historical prices for a futures contract
62
+ *
63
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
64
+ * @param options - Date range filters
65
+ * @returns Array of historical prices
66
+ *
67
+ * @throws {NotFoundError} If contract not found
68
+ * @throws {OilPriceAPIError} If API request fails
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const history = await client.futures.historical('CL.1', {
73
+ * startDate: '2024-01-01',
74
+ * endDate: '2024-01-31'
75
+ * });
76
+ * console.log(`${history.length} historical prices`);
77
+ * ```
78
+ */
79
+ async historical(contract, options) {
80
+ if (!contract || typeof contract !== "string") {
81
+ throw new ValidationError("Contract symbol must be a non-empty string");
82
+ }
83
+ const params = {};
84
+ if (options?.startDate)
85
+ params.start_date = options.startDate;
86
+ if (options?.endDate)
87
+ params.end_date = options.endDate;
88
+ const response = await this.client["request"](`/v1/futures/${contract}/historical`, params);
89
+ return Array.isArray(response) ? response : response.prices;
90
+ }
91
+ /**
92
+ * Get OHLC (Open, High, Low, Close) data for a futures contract
93
+ *
94
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
95
+ * @param date - Optional date in YYYY-MM-DD format (defaults to latest)
96
+ * @returns OHLC data
97
+ *
98
+ * @throws {NotFoundError} If contract not found
99
+ * @throws {OilPriceAPIError} If API request fails
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const ohlc = await client.futures.ohlc('CL.1', '2024-01-15');
104
+ * console.log(`Open: $${ohlc.open}`);
105
+ * console.log(`High: $${ohlc.high}`);
106
+ * console.log(`Low: $${ohlc.low}`);
107
+ * console.log(`Close: $${ohlc.close}`);
108
+ * ```
109
+ */
110
+ async ohlc(contract, date) {
111
+ if (!contract || typeof contract !== "string") {
112
+ throw new ValidationError("Contract symbol must be a non-empty string");
113
+ }
114
+ const params = {};
115
+ if (date)
116
+ params.date = date;
117
+ return this.client["request"](`/v1/futures/${contract}/ohlc`, params);
118
+ }
119
+ /**
120
+ * Get intraday price data for a futures contract
121
+ *
122
+ * Returns price points throughout the trading day.
123
+ *
124
+ * @param contract - Contract symbol (e.g., "CL.1", "BZ.2")
125
+ * @returns Intraday price data
126
+ *
127
+ * @throws {NotFoundError} If contract not found
128
+ * @throws {OilPriceAPIError} If API request fails
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const intraday = await client.futures.intraday('CL.1');
133
+ * intraday.prices.forEach(point => {
134
+ * console.log(`${point.time}: $${point.price}`);
135
+ * });
136
+ * ```
137
+ */
138
+ async intraday(contract) {
139
+ if (!contract || typeof contract !== "string") {
140
+ throw new ValidationError("Contract symbol must be a non-empty string");
141
+ }
142
+ return this.client["request"](`/v1/futures/${contract}/intraday`, {});
143
+ }
144
+ /**
145
+ * Get spread between two futures contracts
146
+ *
147
+ * Calculates the price difference between two contracts (contract1 - contract2).
148
+ *
149
+ * @param contract1 - First contract symbol
150
+ * @param contract2 - Second contract symbol
151
+ * @returns Spread data
152
+ *
153
+ * @throws {NotFoundError} If either contract not found
154
+ * @throws {OilPriceAPIError} If API request fails
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * // Calculate spread between front month and second month
159
+ * const spread = await client.futures.spreads('CL.1', 'CL.2');
160
+ * console.log(`CL.1 - CL.2 spread: $${spread.spread}`);
161
+ * ```
162
+ */
163
+ async spreads(contract1, contract2) {
164
+ if (!contract1 || typeof contract1 !== "string") {
165
+ throw new ValidationError("First contract symbol must be a non-empty string");
166
+ }
167
+ if (!contract2 || typeof contract2 !== "string") {
168
+ throw new ValidationError("Second contract symbol must be a non-empty string");
169
+ }
170
+ return this.client["request"]("/v1/futures/spreads", {
171
+ contract1,
172
+ contract2,
173
+ });
174
+ }
175
+ /**
176
+ * Get futures curve for a contract
177
+ *
178
+ * Returns the forward curve showing prices across different expiration dates.
179
+ *
180
+ * @param contract - Base contract symbol (e.g., "CL", "BZ")
181
+ * @returns Futures curve data
182
+ *
183
+ * @throws {NotFoundError} If contract not found
184
+ * @throws {OilPriceAPIError} If API request fails
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * const curve = await client.futures.curve('CL');
189
+ * console.log('WTI Futures Curve:');
190
+ * curve.curve.forEach(point => {
191
+ * console.log(`${point.months_out} months: $${point.price}`);
192
+ * });
193
+ * ```
194
+ */
195
+ async curve(contract) {
196
+ if (!contract || typeof contract !== "string") {
197
+ throw new ValidationError("Contract symbol must be a non-empty string");
198
+ }
199
+ return this.client["request"](`/v1/futures/${contract}/curve`, {});
200
+ }
201
+ /**
202
+ * Get continuous futures contract data
203
+ *
204
+ * Returns a continuous time series by rolling contracts before expiration.
205
+ *
206
+ * @param contract - Base contract symbol (e.g., "CL", "BZ")
207
+ * @param months - Number of months for continuous contract (default: 1 for front month)
208
+ * @returns Continuous contract data
209
+ *
210
+ * @throws {NotFoundError} If contract not found
211
+ * @throws {OilPriceAPIError} If API request fails
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * // Get continuous front month contract
216
+ * const continuous = await client.futures.continuous('CL', 1);
217
+ * console.log(`${continuous.prices.length} data points`);
218
+ * ```
219
+ */
220
+ async continuous(contract, months) {
221
+ if (!contract || typeof contract !== "string") {
222
+ throw new ValidationError("Contract symbol must be a non-empty string");
223
+ }
224
+ const params = {};
225
+ if (months !== undefined)
226
+ params.months = months.toString();
227
+ return this.client["request"](`/v1/futures/${contract}/continuous`, params);
228
+ }
229
+ }
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Rig Counts Resource
3
+ *
4
+ * Access Baker Hughes rig count data including current counts, historical trends,
5
+ * and breakdowns by basin, state, and rig type.
6
+ */
7
+ import type { OilPriceAPI } from "../client.js";
8
+ /**
9
+ * Rig count data
10
+ */
11
+ export interface RigCountData {
12
+ /** Total rig count */
13
+ total: number;
14
+ /** Oil rigs */
15
+ oil?: number;
16
+ /** Gas rigs */
17
+ gas?: number;
18
+ /** Miscellaneous rigs */
19
+ misc?: number;
20
+ /** Breakdown by region/state */
21
+ breakdown?: Record<string, number>;
22
+ /** ISO timestamp when data was recorded */
23
+ timestamp: string;
24
+ /** Week-over-week change */
25
+ change?: number;
26
+ /** Year-over-year change */
27
+ year_over_year_change?: number;
28
+ }
29
+ /**
30
+ * Historical rig count data point
31
+ */
32
+ export interface HistoricalRigCountData {
33
+ /** Date in YYYY-MM-DD format */
34
+ date: string;
35
+ /** Total rig count */
36
+ total: number;
37
+ /** Oil rigs */
38
+ oil?: number;
39
+ /** Gas rigs */
40
+ gas?: number;
41
+ /** Miscellaneous rigs */
42
+ misc?: number;
43
+ }
44
+ /**
45
+ * Options for historical rig count query
46
+ */
47
+ export interface HistoricalRigCountOptions {
48
+ /** Start date in ISO 8601 format (YYYY-MM-DD) */
49
+ startDate?: string;
50
+ /** End date in ISO 8601 format (YYYY-MM-DD) */
51
+ endDate?: string;
52
+ }
53
+ /**
54
+ * Rig count trend data
55
+ */
56
+ export interface RigCountTrend {
57
+ /** Time period (e.g., "week", "month", "quarter", "year") */
58
+ period: string;
59
+ /** Average rig count */
60
+ average: number;
61
+ /** Minimum rig count */
62
+ min: number;
63
+ /** Maximum rig count */
64
+ max: number;
65
+ /** Overall trend direction */
66
+ trend?: "up" | "down" | "flat";
67
+ /** Percentage change */
68
+ change_percent?: number;
69
+ }
70
+ /**
71
+ * Rig count summary
72
+ */
73
+ export interface RigCountSummary {
74
+ /** Current total */
75
+ current: number;
76
+ /** Week-over-week change */
77
+ week_change: number;
78
+ /** Month-over-month change */
79
+ month_change: number;
80
+ /** Year-over-year change */
81
+ year_change: number;
82
+ /** Breakdown by category */
83
+ breakdown: {
84
+ oil: number;
85
+ gas: number;
86
+ misc?: number;
87
+ };
88
+ /** ISO timestamp */
89
+ timestamp: string;
90
+ }
91
+ /**
92
+ * Rig Counts Resource
93
+ *
94
+ * Access Baker Hughes rig count data including current counts, historical data,
95
+ * trends, and summaries.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import { OilPriceAPI } from 'oilpriceapi';
100
+ *
101
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
102
+ *
103
+ * // Get latest rig count
104
+ * const latest = await client.rigCounts.latest();
105
+ * console.log(`Total rigs: ${latest.total}`);
106
+ * console.log(`Oil: ${latest.oil}, Gas: ${latest.gas}`);
107
+ *
108
+ * // Get summary with changes
109
+ * const summary = await client.rigCounts.summary();
110
+ * console.log(`Week-over-week: ${summary.week_change}`);
111
+ * console.log(`Year-over-year: ${summary.year_change}`);
112
+ * ```
113
+ */
114
+ export declare class RigCountsResource {
115
+ private client;
116
+ constructor(client: OilPriceAPI);
117
+ /**
118
+ * Get latest rig count data
119
+ *
120
+ * Returns the most recent Baker Hughes rig count.
121
+ *
122
+ * @returns Latest rig count data
123
+ *
124
+ * @throws {OilPriceAPIError} If API request fails
125
+ * @throws {AuthenticationError} If API key is invalid
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const latest = await client.rigCounts.latest();
130
+ * console.log(`Total rigs: ${latest.total}`);
131
+ * console.log(`Oil rigs: ${latest.oil}`);
132
+ * console.log(`Gas rigs: ${latest.gas}`);
133
+ * console.log(`Change: ${latest.change}`);
134
+ * ```
135
+ */
136
+ latest(): Promise<RigCountData>;
137
+ /**
138
+ * Get current rig count data
139
+ *
140
+ * Alias for latest(). Returns the most recent Baker Hughes rig count.
141
+ *
142
+ * @returns Current rig count data
143
+ *
144
+ * @throws {OilPriceAPIError} If API request fails
145
+ * @throws {AuthenticationError} If API key is invalid
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const current = await client.rigCounts.current();
150
+ * console.log(`Total rigs: ${current.total}`);
151
+ * ```
152
+ */
153
+ current(): Promise<RigCountData>;
154
+ /**
155
+ * Get historical rig count data
156
+ *
157
+ * Returns time series of rig counts.
158
+ *
159
+ * @param options - Date range filters
160
+ * @returns Array of historical rig count data
161
+ *
162
+ * @throws {OilPriceAPIError} If API request fails
163
+ * @throws {AuthenticationError} If API key is invalid
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const history = await client.rigCounts.historical({
168
+ * startDate: '2024-01-01',
169
+ * endDate: '2024-12-31'
170
+ * });
171
+ *
172
+ * history.forEach(point => {
173
+ * console.log(`${point.date}: ${point.total} rigs (${point.oil} oil, ${point.gas} gas)`);
174
+ * });
175
+ * ```
176
+ */
177
+ historical(options?: HistoricalRigCountOptions): Promise<HistoricalRigCountData[]>;
178
+ /**
179
+ * Get rig count trend analysis
180
+ *
181
+ * Returns trend analysis for a specified time period.
182
+ *
183
+ * @param period - Time period (e.g., "week", "month", "quarter", "year")
184
+ * @returns Trend analysis data
185
+ *
186
+ * @throws {OilPriceAPIError} If API request fails
187
+ * @throws {AuthenticationError} If API key is invalid
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const monthlyTrend = await client.rigCounts.trends('month');
192
+ * console.log(`Monthly average: ${monthlyTrend.average}`);
193
+ * console.log(`Trend: ${monthlyTrend.trend}`);
194
+ * console.log(`Change: ${monthlyTrend.change_percent}%`);
195
+ * ```
196
+ */
197
+ trends(period?: string): Promise<RigCountTrend>;
198
+ /**
199
+ * Get rig count summary
200
+ *
201
+ * Returns comprehensive summary including current count and changes
202
+ * across multiple time periods.
203
+ *
204
+ * @returns Rig count summary
205
+ *
206
+ * @throws {OilPriceAPIError} If API request fails
207
+ * @throws {AuthenticationError} If API key is invalid
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const summary = await client.rigCounts.summary();
212
+ * console.log(`Current: ${summary.current}`);
213
+ * console.log(`Week-over-week: ${summary.week_change}`);
214
+ * console.log(`Month-over-month: ${summary.month_change}`);
215
+ * console.log(`Year-over-year: ${summary.year_change}`);
216
+ * console.log(`Oil rigs: ${summary.breakdown.oil}`);
217
+ * console.log(`Gas rigs: ${summary.breakdown.gas}`);
218
+ * ```
219
+ */
220
+ summary(): Promise<RigCountSummary>;
221
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Rig Counts Resource
3
+ *
4
+ * Access Baker Hughes rig count data including current counts, historical trends,
5
+ * and breakdowns by basin, state, and rig type.
6
+ */
7
+ /**
8
+ * Rig Counts Resource
9
+ *
10
+ * Access Baker Hughes rig count data including current counts, historical data,
11
+ * trends, and summaries.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { OilPriceAPI } from 'oilpriceapi';
16
+ *
17
+ * const client = new OilPriceAPI({ apiKey: 'your_key' });
18
+ *
19
+ * // Get latest rig count
20
+ * const latest = await client.rigCounts.latest();
21
+ * console.log(`Total rigs: ${latest.total}`);
22
+ * console.log(`Oil: ${latest.oil}, Gas: ${latest.gas}`);
23
+ *
24
+ * // Get summary with changes
25
+ * const summary = await client.rigCounts.summary();
26
+ * console.log(`Week-over-week: ${summary.week_change}`);
27
+ * console.log(`Year-over-year: ${summary.year_change}`);
28
+ * ```
29
+ */
30
+ export class RigCountsResource {
31
+ constructor(client) {
32
+ this.client = client;
33
+ }
34
+ /**
35
+ * Get latest rig count data
36
+ *
37
+ * Returns the most recent Baker Hughes rig count.
38
+ *
39
+ * @returns Latest rig count data
40
+ *
41
+ * @throws {OilPriceAPIError} If API request fails
42
+ * @throws {AuthenticationError} If API key is invalid
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const latest = await client.rigCounts.latest();
47
+ * console.log(`Total rigs: ${latest.total}`);
48
+ * console.log(`Oil rigs: ${latest.oil}`);
49
+ * console.log(`Gas rigs: ${latest.gas}`);
50
+ * console.log(`Change: ${latest.change}`);
51
+ * ```
52
+ */
53
+ async latest() {
54
+ return this.client["request"]("/v1/rig-counts/latest", {});
55
+ }
56
+ /**
57
+ * Get current rig count data
58
+ *
59
+ * Alias for latest(). Returns the most recent Baker Hughes rig count.
60
+ *
61
+ * @returns Current rig count data
62
+ *
63
+ * @throws {OilPriceAPIError} If API request fails
64
+ * @throws {AuthenticationError} If API key is invalid
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const current = await client.rigCounts.current();
69
+ * console.log(`Total rigs: ${current.total}`);
70
+ * ```
71
+ */
72
+ async current() {
73
+ return this.client["request"]("/v1/rig-counts/current", {});
74
+ }
75
+ /**
76
+ * Get historical rig count data
77
+ *
78
+ * Returns time series of rig counts.
79
+ *
80
+ * @param options - Date range filters
81
+ * @returns Array of historical rig count data
82
+ *
83
+ * @throws {OilPriceAPIError} If API request fails
84
+ * @throws {AuthenticationError} If API key is invalid
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const history = await client.rigCounts.historical({
89
+ * startDate: '2024-01-01',
90
+ * endDate: '2024-12-31'
91
+ * });
92
+ *
93
+ * history.forEach(point => {
94
+ * console.log(`${point.date}: ${point.total} rigs (${point.oil} oil, ${point.gas} gas)`);
95
+ * });
96
+ * ```
97
+ */
98
+ async historical(options) {
99
+ const params = {};
100
+ if (options?.startDate)
101
+ params.start_date = options.startDate;
102
+ if (options?.endDate)
103
+ params.end_date = options.endDate;
104
+ const response = await this.client["request"]("/v1/rig-counts/historical", params);
105
+ return Array.isArray(response) ? response : response.data;
106
+ }
107
+ /**
108
+ * Get rig count trend analysis
109
+ *
110
+ * Returns trend analysis for a specified time period.
111
+ *
112
+ * @param period - Time period (e.g., "week", "month", "quarter", "year")
113
+ * @returns Trend analysis data
114
+ *
115
+ * @throws {OilPriceAPIError} If API request fails
116
+ * @throws {AuthenticationError} If API key is invalid
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const monthlyTrend = await client.rigCounts.trends('month');
121
+ * console.log(`Monthly average: ${monthlyTrend.average}`);
122
+ * console.log(`Trend: ${monthlyTrend.trend}`);
123
+ * console.log(`Change: ${monthlyTrend.change_percent}%`);
124
+ * ```
125
+ */
126
+ async trends(period) {
127
+ const params = {};
128
+ if (period)
129
+ params.period = period;
130
+ return this.client["request"]("/v1/rig-counts/trends", params);
131
+ }
132
+ /**
133
+ * Get rig count summary
134
+ *
135
+ * Returns comprehensive summary including current count and changes
136
+ * across multiple time periods.
137
+ *
138
+ * @returns Rig count summary
139
+ *
140
+ * @throws {OilPriceAPIError} If API request fails
141
+ * @throws {AuthenticationError} If API key is invalid
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const summary = await client.rigCounts.summary();
146
+ * console.log(`Current: ${summary.current}`);
147
+ * console.log(`Week-over-week: ${summary.week_change}`);
148
+ * console.log(`Month-over-month: ${summary.month_change}`);
149
+ * console.log(`Year-over-year: ${summary.year_change}`);
150
+ * console.log(`Oil rigs: ${summary.breakdown.oil}`);
151
+ * console.log(`Gas rigs: ${summary.breakdown.gas}`);
152
+ * ```
153
+ */
154
+ async summary() {
155
+ return this.client["request"]("/v1/rig-counts/summary", {});
156
+ }
157
+ }