Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Daily Oil Price Query API from National Development and Reform Commission: Prices for 92, 95, 98 Gasoline and 0 Diesel on Specified Date

Tech 1

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.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

SBUS Signal Analysis and Communication Implementation Using STM32 with Fus Remote Controller

Overview In a recent project, I utilized the SBUS protocol with the Fus remote controller to control a vehicle's basic operations, including movement, lights, and mode switching. This article is aimed...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.