oilpriceapi 0.5.0 → 0.5.3
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 +9 -6
- package/dist/client.js +12 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/version.d.ts +18 -0
- package/dist/version.js +20 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -625,12 +625,15 @@ All errors extend `OilPriceAPIError`:
|
|
|
625
625
|
|
|
626
626
|
The API provides prices for the following commodities:
|
|
627
627
|
|
|
628
|
-
- **Crude Oil**:
|
|
629
|
-
- **Refined Products**:
|
|
630
|
-
- **Natural Gas**:
|
|
631
|
-
- **
|
|
632
|
-
|
|
633
|
-
|
|
628
|
+
- **Crude Oil**: `WTI_USD`, `BRENT_CRUDE_USD`
|
|
629
|
+
- **Refined Products**: `GASOLINE_USD`, `DIESEL_USD` (state averages + station-level), `HEATING_OIL_USD`, `JET_FUEL_USD`
|
|
630
|
+
- **Natural Gas**: `NATURAL_GAS_USD`, `DUTCH_TTF_EUR`, `NATURAL_GAS_GBP`
|
|
631
|
+
- **Coal** (8 Endpoints):
|
|
632
|
+
- **US Spot**: `CAPP_COAL_USD`, `PRB_COAL_USD`, `ILLINOIS_COAL_USD`
|
|
633
|
+
- **International**: `NEWCASTLE_COAL_USD`, `COKING_COAL_USD`, `CME_COAL_USD`
|
|
634
|
+
- **Historical**: `NYMEX_APPALACHIAN_USD`, `NYMEX_WESTERN_RAIL_USD`
|
|
635
|
+
|
|
636
|
+
See the [full list of 79 commodities](https://www.oilpriceapi.com/commodities) in the documentation.
|
|
634
637
|
|
|
635
638
|
## Pricing & Rate Limits
|
|
636
639
|
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from './errors.js';
|
|
2
2
|
import { DieselResource } from './resources/diesel.js';
|
|
3
3
|
import { AlertsResource } from './resources/alerts.js';
|
|
4
|
+
import { SDK_VERSION, SDK_NAME, buildUserAgent } from './version.js';
|
|
4
5
|
/**
|
|
5
6
|
* Official Node.js client for Oil Price API
|
|
6
7
|
*
|
|
@@ -126,10 +127,9 @@ export class OilPriceAPI {
|
|
|
126
127
|
headers: {
|
|
127
128
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
128
129
|
'Content-Type': 'application/json',
|
|
129
|
-
'User-Agent':
|
|
130
|
-
'X-
|
|
131
|
-
'X-
|
|
132
|
-
'X-Client-Type': 'sdk',
|
|
130
|
+
'User-Agent': buildUserAgent(),
|
|
131
|
+
'X-Api-Client': SDK_NAME,
|
|
132
|
+
'X-Client-Version': SDK_VERSION,
|
|
133
133
|
},
|
|
134
134
|
signal: controller.signal,
|
|
135
135
|
});
|
|
@@ -294,7 +294,14 @@ export class OilPriceAPI {
|
|
|
294
294
|
if (options?.endDate) {
|
|
295
295
|
params.end_date = options.endDate;
|
|
296
296
|
}
|
|
297
|
-
|
|
297
|
+
// CRITICAL FIX (December 17, 2025):
|
|
298
|
+
// Use /v1/prices/past_year endpoint instead of /v1/prices
|
|
299
|
+
// The /v1/prices endpoint does NOT correctly handle start_date/end_date parameters
|
|
300
|
+
// This was the same bug that affected the Python SDK (fixed in v1.4.4)
|
|
301
|
+
// Issue: SDK was returning wrong dates for historical queries
|
|
302
|
+
// Root Cause: Backend has_scope :by_period not working on /v1/prices
|
|
303
|
+
// Solution: Use /v1/prices/past_year which uses direct WHERE clauses
|
|
304
|
+
return this.request('/v1/prices/past_year', params);
|
|
298
305
|
}
|
|
299
306
|
/**
|
|
300
307
|
* Get metadata for all supported commodities
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
export { OilPriceAPI } from './client.js';
|
|
9
|
+
export { SDK_VERSION, SDK_NAME } from './version.js';
|
|
9
10
|
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, Commodity, CommoditiesResponse, CommodityCategory, CategoriesResponse, } from './types.js';
|
|
10
11
|
export type { DieselPrice, DieselStation, DieselStationsResponse, GetDieselStationsOptions, } from './resources/diesel.js';
|
|
11
12
|
export type { PriceAlert, CreateAlertParams, UpdateAlertParams, AlertOperator, WebhookTestResponse, } from './resources/alerts.js';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Version - centralized to ensure consistency across all headers
|
|
3
|
+
*
|
|
4
|
+
* This version must be updated when publishing a new release.
|
|
5
|
+
* It's used in:
|
|
6
|
+
* - User-Agent header: oilpriceapi-node/{version}
|
|
7
|
+
* - X-Client-Version header
|
|
8
|
+
* - Package.json (should match)
|
|
9
|
+
*/
|
|
10
|
+
export declare const SDK_VERSION = "0.5.3";
|
|
11
|
+
/**
|
|
12
|
+
* SDK identifier used in User-Agent and X-Api-Client headers
|
|
13
|
+
*/
|
|
14
|
+
export declare const SDK_NAME = "oilpriceapi-node";
|
|
15
|
+
/**
|
|
16
|
+
* Build the full User-Agent string
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildUserAgent(): string;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Version - centralized to ensure consistency across all headers
|
|
3
|
+
*
|
|
4
|
+
* This version must be updated when publishing a new release.
|
|
5
|
+
* It's used in:
|
|
6
|
+
* - User-Agent header: oilpriceapi-node/{version}
|
|
7
|
+
* - X-Client-Version header
|
|
8
|
+
* - Package.json (should match)
|
|
9
|
+
*/
|
|
10
|
+
export const SDK_VERSION = '0.5.3';
|
|
11
|
+
/**
|
|
12
|
+
* SDK identifier used in User-Agent and X-Api-Client headers
|
|
13
|
+
*/
|
|
14
|
+
export const SDK_NAME = 'oilpriceapi-node';
|
|
15
|
+
/**
|
|
16
|
+
* Build the full User-Agent string
|
|
17
|
+
*/
|
|
18
|
+
export function buildUserAgent() {
|
|
19
|
+
return `${SDK_NAME}/${SDK_VERSION} node/${process.version}`;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oilpriceapi",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Official Node.js SDK for Oil Price API - Real-time and historical oil & commodity prices",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^20.10.0",
|
|
58
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
58
59
|
"typescript": "^5.3.0",
|
|
59
60
|
"vitest": "^1.0.0"
|
|
60
61
|
}
|