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.
- package/README.md +418 -123
- package/dist/cjs/client.js +490 -0
- package/dist/cjs/errors.js +80 -0
- package/dist/cjs/index.js +82 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/alerts.js +387 -0
- package/dist/cjs/resources/analytics.js +226 -0
- package/dist/cjs/resources/bunker-fuels.js +196 -0
- package/dist/cjs/resources/commodities.js +115 -0
- package/dist/cjs/resources/data-quality.js +144 -0
- package/dist/cjs/resources/data-sources.js +297 -0
- package/dist/cjs/resources/diesel.js +119 -0
- package/dist/cjs/resources/drilling.js +269 -0
- package/dist/cjs/resources/ei/drilling-productivity.js +108 -0
- package/dist/cjs/resources/ei/forecasts.js +106 -0
- package/dist/cjs/resources/ei/frac-focus.js +155 -0
- package/dist/cjs/resources/ei/index.js +98 -0
- package/dist/cjs/resources/ei/oil-inventories.js +97 -0
- package/dist/cjs/resources/ei/opec-production.js +97 -0
- package/dist/cjs/resources/ei/rig-counts.js +93 -0
- package/dist/cjs/resources/ei/well-permits.js +124 -0
- package/dist/cjs/resources/forecasts.js +162 -0
- package/dist/cjs/resources/futures.js +233 -0
- package/dist/cjs/resources/rig-counts.js +161 -0
- package/dist/cjs/resources/storage.js +166 -0
- package/dist/cjs/resources/webhooks.js +294 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/version.js +24 -0
- package/dist/client.d.ts +116 -5
- package/dist/client.js +169 -47
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +25 -16
- package/dist/index.d.ts +45 -6
- package/dist/index.js +40 -3
- package/dist/resources/alerts.d.ts +52 -15
- package/dist/resources/alerts.js +121 -109
- package/dist/resources/analytics.d.ts +325 -0
- package/dist/resources/analytics.js +222 -0
- package/dist/resources/bunker-fuels.d.ts +270 -0
- package/dist/resources/bunker-fuels.js +192 -0
- package/dist/resources/commodities.d.ts +148 -0
- package/dist/resources/commodities.js +111 -0
- package/dist/resources/data-quality.d.ts +229 -0
- package/dist/resources/data-quality.js +140 -0
- package/dist/resources/data-sources.d.ts +365 -0
- package/dist/resources/data-sources.js +293 -0
- package/dist/resources/diesel.d.ts +1 -1
- package/dist/resources/diesel.js +9 -38
- package/dist/resources/drilling.d.ts +403 -0
- package/dist/resources/drilling.js +265 -0
- package/dist/resources/ei/drilling-productivity.d.ts +173 -0
- package/dist/resources/ei/drilling-productivity.js +104 -0
- package/dist/resources/ei/forecasts.d.ts +177 -0
- package/dist/resources/ei/forecasts.js +102 -0
- package/dist/resources/ei/frac-focus.d.ts +212 -0
- package/dist/resources/ei/frac-focus.js +151 -0
- package/dist/resources/ei/index.d.ts +140 -0
- package/dist/resources/ei/index.js +88 -0
- package/dist/resources/ei/oil-inventories.d.ts +155 -0
- package/dist/resources/ei/oil-inventories.js +93 -0
- package/dist/resources/ei/opec-production.d.ts +146 -0
- package/dist/resources/ei/opec-production.js +93 -0
- package/dist/resources/ei/rig-counts.d.ts +131 -0
- package/dist/resources/ei/rig-counts.js +89 -0
- package/dist/resources/ei/well-permits.d.ts +178 -0
- package/dist/resources/ei/well-permits.js +120 -0
- package/dist/resources/forecasts.d.ts +200 -0
- package/dist/resources/forecasts.js +158 -0
- package/dist/resources/futures.d.ts +322 -0
- package/dist/resources/futures.js +229 -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 +162 -0
- package/dist/resources/webhooks.d.ts +326 -0
- package/dist/resources/webhooks.js +290 -0
- package/dist/types.d.ts +79 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/package.json +17 -8
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bunker Fuels Resource
|
|
3
|
+
*
|
|
4
|
+
* Access bunker fuel prices at major ports worldwide, including VLSFO, MGO,
|
|
5
|
+
* and IFO380. Compare prices across ports and track historical trends.
|
|
6
|
+
*/
|
|
7
|
+
import type { OilPriceAPI } from "../client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Bunker fuel price data
|
|
10
|
+
*/
|
|
11
|
+
export interface BunkerFuelPrice {
|
|
12
|
+
/** Port code */
|
|
13
|
+
port: string;
|
|
14
|
+
/** Port name */
|
|
15
|
+
port_name?: string;
|
|
16
|
+
/** Fuel type (e.g., "VLSFO", "MGO", "IFO380") */
|
|
17
|
+
fuel_type: string;
|
|
18
|
+
/** Price per metric ton */
|
|
19
|
+
price: number;
|
|
20
|
+
/** Currency code (typically "USD") */
|
|
21
|
+
currency: string;
|
|
22
|
+
/** Unit (typically "MT" for metric ton) */
|
|
23
|
+
unit: string;
|
|
24
|
+
/** ISO timestamp when price was recorded */
|
|
25
|
+
timestamp: string;
|
|
26
|
+
/** Price change from previous day */
|
|
27
|
+
change?: number;
|
|
28
|
+
/** Additional metadata */
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Port-specific bunker fuel prices
|
|
33
|
+
*/
|
|
34
|
+
export interface PortBunkerPrices {
|
|
35
|
+
/** Port code */
|
|
36
|
+
port: string;
|
|
37
|
+
/** Port name */
|
|
38
|
+
port_name: string;
|
|
39
|
+
/** Geographic region */
|
|
40
|
+
region?: string;
|
|
41
|
+
/** ISO timestamp */
|
|
42
|
+
timestamp: string;
|
|
43
|
+
/** Fuel prices by type */
|
|
44
|
+
prices: {
|
|
45
|
+
/** VLSFO price */
|
|
46
|
+
VLSFO?: number;
|
|
47
|
+
/** MGO price */
|
|
48
|
+
MGO?: number;
|
|
49
|
+
/** IFO380 price */
|
|
50
|
+
IFO380?: number;
|
|
51
|
+
/** Other fuel types */
|
|
52
|
+
[fuelType: string]: number | undefined;
|
|
53
|
+
};
|
|
54
|
+
/** Currency code */
|
|
55
|
+
currency: string;
|
|
56
|
+
/** Unit of measurement */
|
|
57
|
+
unit: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Price comparison between ports
|
|
61
|
+
*/
|
|
62
|
+
export interface PortPriceComparison {
|
|
63
|
+
/** Fuel type being compared */
|
|
64
|
+
fuel_type: string;
|
|
65
|
+
/** ISO timestamp */
|
|
66
|
+
timestamp: string;
|
|
67
|
+
/** Array of port prices */
|
|
68
|
+
ports: Array<{
|
|
69
|
+
/** Port code */
|
|
70
|
+
port: string;
|
|
71
|
+
/** Port name */
|
|
72
|
+
port_name: string;
|
|
73
|
+
/** Price */
|
|
74
|
+
price: number;
|
|
75
|
+
/** Rank (1 = cheapest) */
|
|
76
|
+
rank?: number;
|
|
77
|
+
}>;
|
|
78
|
+
/** Currency code */
|
|
79
|
+
currency: string;
|
|
80
|
+
/** Unit of measurement */
|
|
81
|
+
unit: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Bunker fuel price spreads
|
|
85
|
+
*/
|
|
86
|
+
export interface BunkerFuelSpreads {
|
|
87
|
+
/** ISO timestamp */
|
|
88
|
+
timestamp: string;
|
|
89
|
+
/** Spreads between fuel grades */
|
|
90
|
+
spreads: Array<{
|
|
91
|
+
/** High-grade fuel */
|
|
92
|
+
fuel1: string;
|
|
93
|
+
/** Low-grade fuel */
|
|
94
|
+
fuel2: string;
|
|
95
|
+
/** Average spread across ports */
|
|
96
|
+
average_spread: number;
|
|
97
|
+
/** Spread range */
|
|
98
|
+
min_spread: number;
|
|
99
|
+
max_spread: number;
|
|
100
|
+
}>;
|
|
101
|
+
/** Currency code */
|
|
102
|
+
currency: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Historical bunker fuel price data
|
|
106
|
+
*/
|
|
107
|
+
export interface HistoricalBunkerPrice {
|
|
108
|
+
/** Date in YYYY-MM-DD format */
|
|
109
|
+
date: string;
|
|
110
|
+
/** Price */
|
|
111
|
+
price: number;
|
|
112
|
+
/** Currency code */
|
|
113
|
+
currency: string;
|
|
114
|
+
/** Unit of measurement */
|
|
115
|
+
unit: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Options for historical bunker fuel query
|
|
119
|
+
*/
|
|
120
|
+
export interface HistoricalBunkerOptions {
|
|
121
|
+
/** Start date in ISO 8601 format (YYYY-MM-DD) */
|
|
122
|
+
startDate?: string;
|
|
123
|
+
/** End date in ISO 8601 format (YYYY-MM-DD) */
|
|
124
|
+
endDate?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Bunker Fuels Resource
|
|
128
|
+
*
|
|
129
|
+
* Access bunker fuel prices at major ports worldwide. Track VLSFO, MGO, and
|
|
130
|
+
* IFO380 prices, compare across ports, and analyze historical trends.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
135
|
+
*
|
|
136
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
137
|
+
*
|
|
138
|
+
* // Get all bunker fuel prices
|
|
139
|
+
* const prices = await client.bunkerFuels.all();
|
|
140
|
+
*
|
|
141
|
+
* // Get prices for specific port
|
|
142
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
143
|
+
* console.log(`Singapore VLSFO: $${singapore.prices.VLSFO}/MT`);
|
|
144
|
+
*
|
|
145
|
+
* // Compare prices across ports
|
|
146
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU']);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare class BunkerFuelsResource {
|
|
150
|
+
private client;
|
|
151
|
+
constructor(client: OilPriceAPI);
|
|
152
|
+
/**
|
|
153
|
+
* Get all current bunker fuel prices
|
|
154
|
+
*
|
|
155
|
+
* Returns prices for all tracked ports and fuel types.
|
|
156
|
+
*
|
|
157
|
+
* @returns Array of bunker fuel prices
|
|
158
|
+
*
|
|
159
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
160
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const prices = await client.bunkerFuels.all();
|
|
165
|
+
* prices.forEach(price => {
|
|
166
|
+
* console.log(`${price.port_name} ${price.fuel_type}: $${price.price}/${price.unit}`);
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
all(): Promise<BunkerFuelPrice[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Get bunker fuel prices for a specific port
|
|
173
|
+
*
|
|
174
|
+
* @param code - Port code (e.g., "SIN" for Singapore, "RTM" for Rotterdam)
|
|
175
|
+
* @returns Port-specific prices across fuel types
|
|
176
|
+
*
|
|
177
|
+
* @throws {NotFoundError} If port code not found
|
|
178
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
183
|
+
* console.log(`Singapore Bunker Prices (${singapore.timestamp}):`);
|
|
184
|
+
* console.log(`VLSFO: $${singapore.prices.VLSFO}/${singapore.unit}`);
|
|
185
|
+
* console.log(`MGO: $${singapore.prices.MGO}/${singapore.unit}`);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
port(code: string): Promise<PortBunkerPrices>;
|
|
189
|
+
/**
|
|
190
|
+
* Compare prices across multiple ports
|
|
191
|
+
*
|
|
192
|
+
* @param ports - Array of port codes to compare
|
|
193
|
+
* @returns Price comparison data
|
|
194
|
+
*
|
|
195
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU', 'FUJ']);
|
|
200
|
+
*
|
|
201
|
+
* console.log(`Comparing ${comparison.fuel_type} prices:`);
|
|
202
|
+
* comparison.ports.forEach((port, index) => {
|
|
203
|
+
* console.log(`${index + 1}. ${port.port_name}: $${port.price}`);
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
compare(ports: string[]): Promise<PortPriceComparison>;
|
|
208
|
+
/**
|
|
209
|
+
* Get bunker fuel price spreads
|
|
210
|
+
*
|
|
211
|
+
* Returns spreads between different fuel grades (e.g., VLSFO-IFO380).
|
|
212
|
+
*
|
|
213
|
+
* @returns Fuel price spreads
|
|
214
|
+
*
|
|
215
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const spreads = await client.bunkerFuels.spreads();
|
|
220
|
+
* spreads.spreads.forEach(spread => {
|
|
221
|
+
* console.log(`${spread.fuel1}-${spread.fuel2} spread: $${spread.average_spread}`);
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
spreads(): Promise<BunkerFuelSpreads>;
|
|
226
|
+
/**
|
|
227
|
+
* Get historical bunker fuel prices
|
|
228
|
+
*
|
|
229
|
+
* @param port - Port code (e.g., "SIN", "RTM")
|
|
230
|
+
* @param fuelType - Fuel type (e.g., "VLSFO", "MGO", "IFO380")
|
|
231
|
+
* @param options - Date range filters
|
|
232
|
+
* @returns Array of historical prices
|
|
233
|
+
*
|
|
234
|
+
* @throws {NotFoundError} If port or fuel type not found
|
|
235
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const history = await client.bunkerFuels.historical('SIN', 'VLSFO', {
|
|
240
|
+
* startDate: '2024-01-01',
|
|
241
|
+
* endDate: '2024-12-31'
|
|
242
|
+
* });
|
|
243
|
+
*
|
|
244
|
+
* history.forEach(point => {
|
|
245
|
+
* console.log(`${point.date}: $${point.price}/${point.unit}`);
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
historical(port: string, fuelType: string, options?: HistoricalBunkerOptions): Promise<HistoricalBunkerPrice[]>;
|
|
250
|
+
/**
|
|
251
|
+
* Export bunker fuel data
|
|
252
|
+
*
|
|
253
|
+
* Export bunker fuel prices in specified format (CSV, JSON, Excel).
|
|
254
|
+
*
|
|
255
|
+
* @param format - Export format (default: "csv")
|
|
256
|
+
* @returns Export data or download URL
|
|
257
|
+
*
|
|
258
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* // Export as CSV
|
|
263
|
+
* const csvData = await client.bunkerFuels.export('csv');
|
|
264
|
+
*
|
|
265
|
+
* // Export as JSON
|
|
266
|
+
* const jsonData = await client.bunkerFuels.export('json');
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
export(format?: string): Promise<any>;
|
|
270
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bunker Fuels Resource
|
|
3
|
+
*
|
|
4
|
+
* Access bunker fuel prices at major ports worldwide, including VLSFO, MGO,
|
|
5
|
+
* and IFO380. Compare prices across ports and track historical trends.
|
|
6
|
+
*/
|
|
7
|
+
import { ValidationError } from "../errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* Bunker Fuels Resource
|
|
10
|
+
*
|
|
11
|
+
* Access bunker fuel prices at major ports worldwide. Track VLSFO, MGO, and
|
|
12
|
+
* IFO380 prices, compare across ports, and analyze historical trends.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
17
|
+
*
|
|
18
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
19
|
+
*
|
|
20
|
+
* // Get all bunker fuel prices
|
|
21
|
+
* const prices = await client.bunkerFuels.all();
|
|
22
|
+
*
|
|
23
|
+
* // Get prices for specific port
|
|
24
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
25
|
+
* console.log(`Singapore VLSFO: $${singapore.prices.VLSFO}/MT`);
|
|
26
|
+
*
|
|
27
|
+
* // Compare prices across ports
|
|
28
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU']);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class BunkerFuelsResource {
|
|
32
|
+
constructor(client) {
|
|
33
|
+
this.client = client;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get all current bunker fuel prices
|
|
37
|
+
*
|
|
38
|
+
* Returns prices for all tracked ports and fuel types.
|
|
39
|
+
*
|
|
40
|
+
* @returns Array of bunker fuel prices
|
|
41
|
+
*
|
|
42
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
43
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const prices = await client.bunkerFuels.all();
|
|
48
|
+
* prices.forEach(price => {
|
|
49
|
+
* console.log(`${price.port_name} ${price.fuel_type}: $${price.price}/${price.unit}`);
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async all() {
|
|
54
|
+
const response = await this.client["request"]("/v1/bunker-fuels", {});
|
|
55
|
+
return Array.isArray(response) ? response : response.prices;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get bunker fuel prices for a specific port
|
|
59
|
+
*
|
|
60
|
+
* @param code - Port code (e.g., "SIN" for Singapore, "RTM" for Rotterdam)
|
|
61
|
+
* @returns Port-specific prices across fuel types
|
|
62
|
+
*
|
|
63
|
+
* @throws {NotFoundError} If port code not found
|
|
64
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
69
|
+
* console.log(`Singapore Bunker Prices (${singapore.timestamp}):`);
|
|
70
|
+
* console.log(`VLSFO: $${singapore.prices.VLSFO}/${singapore.unit}`);
|
|
71
|
+
* console.log(`MGO: $${singapore.prices.MGO}/${singapore.unit}`);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
async port(code) {
|
|
75
|
+
if (!code || typeof code !== "string") {
|
|
76
|
+
throw new ValidationError("Port code must be a non-empty string");
|
|
77
|
+
}
|
|
78
|
+
return this.client["request"](`/v1/bunker-fuels/ports/${code}`, {});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compare prices across multiple ports
|
|
82
|
+
*
|
|
83
|
+
* @param ports - Array of port codes to compare
|
|
84
|
+
* @returns Price comparison data
|
|
85
|
+
*
|
|
86
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU', 'FUJ']);
|
|
91
|
+
*
|
|
92
|
+
* console.log(`Comparing ${comparison.fuel_type} prices:`);
|
|
93
|
+
* comparison.ports.forEach((port, index) => {
|
|
94
|
+
* console.log(`${index + 1}. ${port.port_name}: $${port.price}`);
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
async compare(ports) {
|
|
99
|
+
if (!Array.isArray(ports) || ports.length === 0) {
|
|
100
|
+
throw new ValidationError("Ports must be a non-empty array of port codes");
|
|
101
|
+
}
|
|
102
|
+
return this.client["request"]("/v1/bunker-fuels/compare", {
|
|
103
|
+
ports: ports.join(","),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get bunker fuel price spreads
|
|
108
|
+
*
|
|
109
|
+
* Returns spreads between different fuel grades (e.g., VLSFO-IFO380).
|
|
110
|
+
*
|
|
111
|
+
* @returns Fuel price spreads
|
|
112
|
+
*
|
|
113
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const spreads = await client.bunkerFuels.spreads();
|
|
118
|
+
* spreads.spreads.forEach(spread => {
|
|
119
|
+
* console.log(`${spread.fuel1}-${spread.fuel2} spread: $${spread.average_spread}`);
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
async spreads() {
|
|
124
|
+
return this.client["request"]("/v1/bunker-fuels/spreads", {});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get historical bunker fuel prices
|
|
128
|
+
*
|
|
129
|
+
* @param port - Port code (e.g., "SIN", "RTM")
|
|
130
|
+
* @param fuelType - Fuel type (e.g., "VLSFO", "MGO", "IFO380")
|
|
131
|
+
* @param options - Date range filters
|
|
132
|
+
* @returns Array of historical prices
|
|
133
|
+
*
|
|
134
|
+
* @throws {NotFoundError} If port or fuel type not found
|
|
135
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const history = await client.bunkerFuels.historical('SIN', 'VLSFO', {
|
|
140
|
+
* startDate: '2024-01-01',
|
|
141
|
+
* endDate: '2024-12-31'
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* history.forEach(point => {
|
|
145
|
+
* console.log(`${point.date}: $${point.price}/${point.unit}`);
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
async historical(port, fuelType, options) {
|
|
150
|
+
if (!port || typeof port !== "string") {
|
|
151
|
+
throw new ValidationError("Port code must be a non-empty string");
|
|
152
|
+
}
|
|
153
|
+
if (!fuelType || typeof fuelType !== "string") {
|
|
154
|
+
throw new ValidationError("Fuel type must be a non-empty string");
|
|
155
|
+
}
|
|
156
|
+
const params = {
|
|
157
|
+
port,
|
|
158
|
+
fuel_type: fuelType,
|
|
159
|
+
};
|
|
160
|
+
if (options?.startDate)
|
|
161
|
+
params.start_date = options.startDate;
|
|
162
|
+
if (options?.endDate)
|
|
163
|
+
params.end_date = options.endDate;
|
|
164
|
+
const response = await this.client["request"]("/v1/bunker-fuels/historical", params);
|
|
165
|
+
return Array.isArray(response) ? response : response.data;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Export bunker fuel data
|
|
169
|
+
*
|
|
170
|
+
* Export bunker fuel prices in specified format (CSV, JSON, Excel).
|
|
171
|
+
*
|
|
172
|
+
* @param format - Export format (default: "csv")
|
|
173
|
+
* @returns Export data or download URL
|
|
174
|
+
*
|
|
175
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Export as CSV
|
|
180
|
+
* const csvData = await client.bunkerFuels.export('csv');
|
|
181
|
+
*
|
|
182
|
+
* // Export as JSON
|
|
183
|
+
* const jsonData = await client.bunkerFuels.export('json');
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
async export(format) {
|
|
187
|
+
const params = {};
|
|
188
|
+
if (format)
|
|
189
|
+
params.format = format;
|
|
190
|
+
return this.client["request"]("/v1/bunker-fuels/export", params);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commodities Resource
|
|
3
|
+
*
|
|
4
|
+
* Get metadata about supported commodities and categories.
|
|
5
|
+
*/
|
|
6
|
+
import type { OilPriceAPI } from "../client.js";
|
|
7
|
+
/**
|
|
8
|
+
* Commodity metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface Commodity {
|
|
11
|
+
/** Unique commodity identifier */
|
|
12
|
+
code: string;
|
|
13
|
+
/** Human-readable commodity name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Base currency for pricing */
|
|
16
|
+
currency: string;
|
|
17
|
+
/** Commodity category (e.g., "oil", "gas", "renewable") */
|
|
18
|
+
category: string;
|
|
19
|
+
/** Detailed description */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Unit of measurement (e.g., "barrel", "gallon") */
|
|
22
|
+
unit: string;
|
|
23
|
+
/** Detailed unit description */
|
|
24
|
+
unit_description?: string;
|
|
25
|
+
/** Storage multiplier for price values */
|
|
26
|
+
multiplier?: number;
|
|
27
|
+
/** Price validation ranges */
|
|
28
|
+
validation?: {
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
};
|
|
32
|
+
/** Threshold for significant price change alerts */
|
|
33
|
+
price_change_threshold?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Response from /v1/commodities endpoint
|
|
37
|
+
*/
|
|
38
|
+
export interface CommoditiesResponse {
|
|
39
|
+
commodities: Commodity[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Category with its commodities
|
|
43
|
+
*/
|
|
44
|
+
export interface CommodityCategory {
|
|
45
|
+
name: string;
|
|
46
|
+
commodities: Commodity[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response from /v1/commodities/categories endpoint
|
|
50
|
+
*/
|
|
51
|
+
export interface CategoriesResponse {
|
|
52
|
+
[categoryKey: string]: CommodityCategory;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Commodities Resource
|
|
56
|
+
*
|
|
57
|
+
* Access metadata about supported commodities and categories.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
62
|
+
*
|
|
63
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
64
|
+
*
|
|
65
|
+
* // List all commodities
|
|
66
|
+
* const response = await client.commodities.list();
|
|
67
|
+
* console.log(`${response.commodities.length} commodities available`);
|
|
68
|
+
*
|
|
69
|
+
* // Get specific commodity
|
|
70
|
+
* const wti = await client.commodities.get('WTI_USD');
|
|
71
|
+
* console.log(`${wti.name}: ${wti.description}`);
|
|
72
|
+
*
|
|
73
|
+
* // Get categories
|
|
74
|
+
* const categories = await client.commodities.categories();
|
|
75
|
+
* console.log(`Oil category has ${categories.oil.commodities.length} commodities`);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class CommoditiesResource {
|
|
79
|
+
private client;
|
|
80
|
+
constructor(client: OilPriceAPI);
|
|
81
|
+
/**
|
|
82
|
+
* List all supported commodities
|
|
83
|
+
*
|
|
84
|
+
* Returns metadata for all commodities available in the API, including
|
|
85
|
+
* codes, names, units, and validation ranges.
|
|
86
|
+
*
|
|
87
|
+
* @returns Object containing array of commodities
|
|
88
|
+
*
|
|
89
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
90
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const response = await client.commodities.list();
|
|
95
|
+
*
|
|
96
|
+
* response.commodities.forEach(commodity => {
|
|
97
|
+
* console.log(`${commodity.code}: ${commodity.name} (${commodity.unit})`);
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
list(): Promise<CommoditiesResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get metadata for a specific commodity by code
|
|
104
|
+
*
|
|
105
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
106
|
+
* @returns Commodity metadata object
|
|
107
|
+
*
|
|
108
|
+
* @throws {NotFoundError} If commodity code is invalid
|
|
109
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
110
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const commodity = await client.commodities.get('WTI_USD');
|
|
115
|
+
* console.log(`Name: ${commodity.name}`);
|
|
116
|
+
* console.log(`Unit: ${commodity.unit}`);
|
|
117
|
+
* console.log(`Currency: ${commodity.currency}`);
|
|
118
|
+
* console.log(`Category: ${commodity.category}`);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
get(code: string): Promise<Commodity>;
|
|
122
|
+
/**
|
|
123
|
+
* Get all commodity categories with their commodities
|
|
124
|
+
*
|
|
125
|
+
* Returns commodities grouped by category (oil, gas, renewable, etc.).
|
|
126
|
+
* Useful for building navigation or filtering UIs.
|
|
127
|
+
*
|
|
128
|
+
* @returns Object with category keys mapped to category objects
|
|
129
|
+
*
|
|
130
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
131
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const categories = await client.commodities.categories();
|
|
136
|
+
*
|
|
137
|
+
* // Access by category key
|
|
138
|
+
* console.log(`Oil: ${categories.oil.name}`);
|
|
139
|
+
* console.log(`Commodities: ${categories.oil.commodities.length}`);
|
|
140
|
+
*
|
|
141
|
+
* // Iterate all categories
|
|
142
|
+
* Object.entries(categories).forEach(([key, category]) => {
|
|
143
|
+
* console.log(`${category.name}: ${category.commodities.length} commodities`);
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
categories(): Promise<CategoriesResponse>;
|
|
148
|
+
}
|