Daily Oil Price Query API from National Development and Reform Commission: Prices for 92, 95, 98 Gasoline and 0 Diesel on Specified Date
Introduction
This API allows developers to query daily oil prices from the National Development and Reform Commission (NDRC), including prices for 92#, 95#, 98# gasoline and 0# diesel on a specified date.
Note: This is a paid API (0.2 USD per request). It is recommended to implement caching.
API Endpoint
Input Parameters
| Paramter | Type | Required | Description |
|---|---|---|---|
code |
String | Yes | Authentication code (obtained from a mini-program, please keep it confidential) |
day |
String | Yes | Date in format YYYY-MM-DD (e.g., 2023-11-26) |
Request Method: GET
Example Request:
curl "https://api.example.com/oil/prices?code=YOUR_CODE&day=2023-11-26"
Response Format
The response is a JSON object with the following structure:
{
"status": 200,
"message": "succeed.",
"results": [
{
"id": 1,
"date": "2023-11-26",
"city": "Anhui",
"updatedAt": "2023-11-26 10:45:01",
"dataAt": "2023-11-26 10:00:01",
"gasoline92": 7.87,
"gasoline95": 8.42,
"gasoline98": 9.44,
"diesel0": 7.62
}
]
}
Response Fields
| Field | Type | Description |
|---|---|---|
id |
Long | Internal ID (can be ignored) |
date |
String | Oil price date |
city |
String | City name (e.g., "Anhui", "Beijing") |
updatedAt |
Date | Last update time of this record in the database (hourly) |
dataAt |
Date | Data fetch time from NDRC (around 10:00 daily) |
gasoline92 |
Double | Price of 92# gasoline |
gasoline95 |
Double | Price of 95# gasoline |
gasoline98 |
Double | Price of 98# gasoline |
diesel0 |
Double | Price of 0# diesel |
Pricing
- Cost: 0.2 USD per request
- Unlimited requests
- It is recommended to cache results for cost efficiency.
Usage Monitoring
Acces the monitoring page to view API call history and consumption:
https://monitor.example.com
Notes
- The authentication code is fixed once obtained; keep it secret.
- The API is updated hourly from the database and daily from NDRC around 10 AM.
- This API is for legitimate use only.