oilpriceapi 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +39 -1
- package/dist/client.js +45 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +68 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OilPriceAPIConfig, Price, LatestPricesOptions, HistoricalPricesOptions } from './types.js';
|
|
1
|
+
import type { OilPriceAPIConfig, Price, LatestPricesOptions, HistoricalPricesOptions, Commodity, CommoditiesResponse, CategoriesResponse } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Official Node.js client for Oil Price API
|
|
4
4
|
*
|
|
@@ -93,4 +93,42 @@ export declare class OilPriceAPI {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
getHistoricalPrices(options?: HistoricalPricesOptions): Promise<Price[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Get metadata for all supported commodities
|
|
98
|
+
*
|
|
99
|
+
* @returns Object containing array of commodities
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const response = await client.getCommodities();
|
|
104
|
+
* console.log(response.commodities); // Array of commodity objects
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
getCommodities(): Promise<CommoditiesResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Get all commodity categories with their commodities
|
|
110
|
+
*
|
|
111
|
+
* @returns Object with category keys mapped to category objects
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const categories = await client.getCommodityCategories();
|
|
116
|
+
* console.log(categories.oil.name); // "Oil"
|
|
117
|
+
* console.log(categories.oil.commodities.length); // 11
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
getCommodityCategories(): Promise<CategoriesResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Get metadata for a specific commodity by code
|
|
123
|
+
*
|
|
124
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
125
|
+
* @returns Commodity metadata object
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const commodity = await client.getCommodity('WTI_USD');
|
|
130
|
+
* console.log(commodity.name); // "WTI Crude Oil"
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
getCommodity(code: string): Promise<Commodity>;
|
|
96
134
|
}
|
package/dist/client.js
CHANGED
|
@@ -121,7 +121,7 @@ export class OilPriceAPI {
|
|
|
121
121
|
headers: {
|
|
122
122
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
123
123
|
'Content-Type': 'application/json',
|
|
124
|
-
'User-Agent': 'oilpriceapi-node/0.
|
|
124
|
+
'User-Agent': 'oilpriceapi-node/0.3.0',
|
|
125
125
|
},
|
|
126
126
|
signal: controller.signal,
|
|
127
127
|
});
|
|
@@ -288,4 +288,48 @@ export class OilPriceAPI {
|
|
|
288
288
|
}
|
|
289
289
|
return this.request('/v1/prices', params);
|
|
290
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Get metadata for all supported commodities
|
|
293
|
+
*
|
|
294
|
+
* @returns Object containing array of commodities
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const response = await client.getCommodities();
|
|
299
|
+
* console.log(response.commodities); // Array of commodity objects
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
async getCommodities() {
|
|
303
|
+
return this.request('/v1/commodities', {});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get all commodity categories with their commodities
|
|
307
|
+
*
|
|
308
|
+
* @returns Object with category keys mapped to category objects
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const categories = await client.getCommodityCategories();
|
|
313
|
+
* console.log(categories.oil.name); // "Oil"
|
|
314
|
+
* console.log(categories.oil.commodities.length); // 11
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
async getCommodityCategories() {
|
|
318
|
+
return this.request('/v1/commodities/categories', {});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get metadata for a specific commodity by code
|
|
322
|
+
*
|
|
323
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
324
|
+
* @returns Commodity metadata object
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* const commodity = await client.getCommodity('WTI_USD');
|
|
329
|
+
* console.log(commodity.name); // "WTI Crude Oil"
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
async getCommodity(code) {
|
|
333
|
+
return this.request(`/v1/commodities/${code}`, {});
|
|
334
|
+
}
|
|
291
335
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
export { OilPriceAPI } from './client.js';
|
|
9
|
-
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, } from './types.js';
|
|
9
|
+
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, Commodity, CommoditiesResponse, CommodityCategory, CategoriesResponse, } from './types.js';
|
|
10
10
|
export { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from './errors.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -143,3 +143,71 @@ export interface HistoricalPricesOptions {
|
|
|
143
143
|
*/
|
|
144
144
|
endDate?: string;
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Represents commodity metadata
|
|
148
|
+
*/
|
|
149
|
+
export interface Commodity {
|
|
150
|
+
/**
|
|
151
|
+
* Unique commodity identifier
|
|
152
|
+
*/
|
|
153
|
+
code: string;
|
|
154
|
+
/**
|
|
155
|
+
* Human-readable commodity name
|
|
156
|
+
*/
|
|
157
|
+
name: string;
|
|
158
|
+
/**
|
|
159
|
+
* Base currency for pricing
|
|
160
|
+
*/
|
|
161
|
+
currency: string;
|
|
162
|
+
/**
|
|
163
|
+
* Commodity category (e.g., "oil", "gas", "renewable")
|
|
164
|
+
*/
|
|
165
|
+
category: string;
|
|
166
|
+
/**
|
|
167
|
+
* Detailed description
|
|
168
|
+
*/
|
|
169
|
+
description?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Unit of measurement (e.g., "barrel", "gallon")
|
|
172
|
+
*/
|
|
173
|
+
unit: string;
|
|
174
|
+
/**
|
|
175
|
+
* Detailed unit description
|
|
176
|
+
*/
|
|
177
|
+
unit_description?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Storage multiplier for price values
|
|
180
|
+
*/
|
|
181
|
+
multiplier?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Price validation ranges
|
|
184
|
+
*/
|
|
185
|
+
validation?: {
|
|
186
|
+
min: number;
|
|
187
|
+
max: number;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Threshold for significant price change alerts
|
|
191
|
+
*/
|
|
192
|
+
price_change_threshold?: number;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Response from /v1/commodities endpoint
|
|
196
|
+
*/
|
|
197
|
+
export interface CommoditiesResponse {
|
|
198
|
+
commodities: Commodity[];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Category with its commodities
|
|
202
|
+
*/
|
|
203
|
+
export interface CommodityCategory {
|
|
204
|
+
name: string;
|
|
205
|
+
commodities: Commodity[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Response from /v1/commodities/categories endpoint
|
|
209
|
+
* Returns object with category keys mapped to CommodityCategory objects
|
|
210
|
+
*/
|
|
211
|
+
export interface CategoriesResponse {
|
|
212
|
+
[categoryKey: string]: CommodityCategory;
|
|
213
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oilpriceapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official Node.js SDK for Oil Price API - Real-time and historical oil & commodity prices",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/OilpriceAPI/oilpriceapi-node.git"
|
|
43
|
+
"url": "git+https://github.com/OilpriceAPI/oilpriceapi-node.git"
|
|
44
44
|
},
|
|
45
45
|
"bugs": {
|
|
46
46
|
"url": "https://github.com/OilpriceAPI/oilpriceapi-node/issues"
|