data.stats.gov.cn EasyQuery API Example

How the NBS EasyQuery QueryData request works, what the main parameters mean, how to test it with Python, how to think about the NBS metadata code catalog, and when a cleaned China data API is easier to use.

Developer quick start

Use NBS to verify the official source. Use chinadata.live when overseas reliability matters.

The NBS EasyQuery API is powerful, Chinese-only, and sometimes unstable from non-China networks. For common China GDP, population, CPI, PMI, retail sales, industrial output, money supply, and other macro workflows, the faster path is often the free China Data API docs and ready-made dataset endpoints.

NBS EasyQuery

POST https://data.stats.gov.cn/easyquery.htm?m=QueryData

Simpler JSON / CSV

curl https://chinadata.live/api/v2/data/china-gdp
curl -L "https://chinadata.live/api/v2/data/china-gdp?format=csv"

What Searchers Usually Need

Queries such as data.stats.gov.cn easyquery api example, querydata example, or look China API usually mix two different jobs: finding the official NBS source query, and getting a stable English dataset for an app, spreadsheet, or research workflow.

Use NBS EasyQuery for source discovery

  • Find the official indicator title and database.
  • Confirm the source unit and frequency.
  • Capture the dbcode, dimension code, and value code.
  • Record retrieval date and source URL for audit trails.

Use ChinaData.live for reusable outputs

  • Fetch clean JSON or CSV from stable URLs.
  • Read English titles, units, and source notes.
  • Avoid nested EasyQuery payload parsing in production apps.
  • Use documented unit conversions and known limitations.

NBS EasyQuery API (data.stats.gov.cn)

The NBS provides an undocumented JSON API at data.stats.gov.cn/easyquery.htm. It is useful for source verification, but it is complex and can be unreliable from overseas networks:

# Example: Query annual GDP data
GET https://data.stats.gov.cn/easyquery.htm?m=QueryData
dbcode=hgnd&rowcode=sj&colcode=zb&wds=[]&dfwds=[{"wdcode":"zb","valuecode":"A020101"}]

Overseas access caveat

From servers or laptops outside mainland China, data.stats.gov.cn may intermittently time out, return 403, or respond slowly. Treat direct EasyQuery calls as a research and verification tool, not as the only dependency for a public production app.

Key parameters:

Parameter Value Meaning
mQueryDataQuery mode used by EasyQuery
dbcodehgnd / hgydAnnual or monthly national database
rowcodesjTime dimension (rows)
colcodezbIndicator dimension (columns)
wds[]Fixed filters; often empty for simple indicator queries
dfwdsJSON arrayIndicator filters, usually wdcode plus valuecode

The API is in Chinese, requires knowledge of NBS indicator codes (like A020101 for GDP), and responses vary by database. It's not officially documented for external use.

Python QueryData Example

This is the shape of a typical data.stats.gov.cn/easyquery.htm?m=QueryData request. In real use, add timeouts and retries because overseas access is not guaranteed.

import json
import requests

url = "https://data.stats.gov.cn/easyquery.htm"
params = {
    "m": "QueryData",
    "dbcode": "hgnd",
    "rowcode": "sj",
    "colcode": "zb",
    "wds": "[]",
    "dfwds": json.dumps([
        {"wdcode": "zb", "valuecode": "A020101"}
    ], ensure_ascii=False),
}

response = requests.get(url, params=params, timeout=20)
response.raise_for_status()
payload = response.json()

If the request fails from an overseas network, test again from a mainland China network or use a stable dataset endpoint for application traffic.

CPI City Monthly Query Pattern

Searches like "data.stats.gov.cn easyquery api cpi city monthly" usually need the monthly database and a CPI indicator code. The exact valuecode depends on the NBS table and city dimension selected in the official UI.

# Pattern: monthly CPI-style EasyQuery request
GET https://data.stats.gov.cn/easyquery.htm?m=QueryData
dbcode=hgyd&rowcode=sj&colcode=zb&wds=[]&dfwds=[{"wdcode":"zb","valuecode":"YOUR_CPI_INDICATOR_CODE"}]

Use the official NBS interface to identify the indicator code first, then copy the dfwds pattern into a scripted request. For general CPI time series, the cleaned China CPI dataset is easier to reuse.

Simpler Alternative: chinadata.live API

If you need key China statistics in English with a clean REST API, no registration needed:

# Get China GDP data through a stable global endpoint
curl https://chinadata.live/api/v2/data/china-gdp

NBS API vs chinadata.live API

Feature data.stats.gov.cn chinadata.live
LanguageChinese onlyEnglish ✓
DocumentationNone (reverse engineered)Full docs ✓
Auth requiredNoNo ✓
Data coverageLarge official indicator catalog ✓Curated key datasets
MetadataChinese indicator codes, units, and dimensionsEnglish metadata, source notes, and API slugs ✓
Unit handlingRaw NBS units and index valuesDocumented conversions where needed ✓
Response formatComplex nested JSONClean REST JSON ✓
Overseas availabilityMay block, timeout, or slow downGlobal CDN ✓

FAQ

What is the data.stats.gov.cn EasyQuery API?

The NBS provides an unofficial JSON API at data.stats.gov.cn/easyquery.htm. It powers the official NBS data visualization tool and returns data in JSON format. The API uses POST requests with Chinese indicator codes. It is not officially documented for external use but is widely used by researchers.

Why can't I access data.stats.gov.cn from outside China?

The NBS website sometimes restricts access from non-Chinese IP addresses or slows significantly. This is why researchers use a proxy, VPN, or an alternative data source like chinadata.live which mirrors key datasets on a global CDN.

What is the NBS indicator code for China GDP?

The NBS indicator code for GDP (国内生产总值) is A020101 in the annual database (dbcode=hgnd). Alternatively, use curl https://chinadata.live/api/v2/data/china-gdp for a pre-formatted English response.

How do CPI and PPI index values convert to percentage change?

NBS reports CPI and PPI as indices where 100 = same period last year. For example, a CPI index of 101.5 means 1.5% year-on-year inflation. To convert: change_rate = index_value − 100. The chinadata.live API already returns the converted change rate for CPI and PPI datasets — no manual conversion needed.

How do I cite NBS data from chinadata.live?

Cite as: National Bureau of Statistics of China, [indicator name], retrieved [YYYY-MM-DD] from chinadata.live. Original source: data.stats.gov.cn. Always verify critical figures against the official NBS source before academic or policy use.

NBS Metadata and Code Catalog

EasyQuery is metadata-driven. A reliable NBS workflow needs more than the numeric value: store the indicator name, source unit, frequency, database code, dimension code, value code, source URL, retrieval date, and any unit conversion applied after download.

Important code-catalog note

ChinaData.live slugs such as china-retail-sales are stable website/API identifiers, not official NBS valuecode values. When querying EasyQuery directly, verify the current NBS code in the official UI or a reviewed metadata ledger before automating the request.

The table below maps common research intents to ChinaData.live API pages and the usual EasyQuery database family. Treat it as a catalog bridge, not a guarantee that every slug is the exact NBS valuecode.

Indicator NBS metadata to verify Usual dbcode chinadata.live Endpoint
GDP (annual)Indicator code, current-price unit, annual periodhgnd/data/china-gdp/
GDP (quarterly)Quarterly GDP code, current-price unit, quarter labelshgjd/data/china-gdp-quarterly/
CPI (YoY)Index series where same month last year = 100hgyd/data/china-cpi/
PPI (YoY)Factory-gate price index where same month last year = 100hgyd/data/china-ppi/
Manufacturing PMIPMI index title and monthly period coveragehgyd/data/china-pmi/
M2 Money SupplyMonetary aggregate level, unit, and monthly codehgyd/data/china-m2-money-supply/
M2 YoY GrowthGrowth-rate series, not the level serieshgyd/data/china-m2-money-supply-yoy/
Unemployment rateUrban survey unemployment rate title and unithgyd/data/china-unemployment/
Industrial outputIndustrial value-added growth series and rate unithgyd/data/china-industrial-output/
Retail salesRetail sales level or YoY growth, depending on selected NBS indicatorhgyd/data/china-retail-sales/
Fixed asset investmentGrowth-rate indicator and methodology noteshgyd/data/china-fai/
Electricity generationPhysical output unit and monthly production serieshgyd/data/china-electricity-generation/

For production use, keep the source-side code catalog and the cleaned API slug catalog separate. The source catalog answers "what did NBS publish?", while the API catalog answers "what stable endpoint should my app call?"

JSON API Response Example

The chinadata.live API returns clean English JSON — no nested NBS nodes or Chinese field names:

{
  "success": true,
  "data": {
    "id": "china-ppi",
    "slug": "china-ppi",
    "title": "Producer Price Index (YoY)",
    "unit": "% (YoY, same month last year=100)",
    "frequency": "monthly",
    "source": "National Bureau of Statistics",
    "source_url": "https://data.stats.gov.cn/",
    "data": [
      { "date": "2025-01", "value": -1.8 },
      { "date": "2025-02", "value": -2.0 },
      { "date": "2025-03", "value": -2.3 }
    ],
    "dateRange": { "start": "1996-01", "end": "2026-05" }
  }
}

Note: CPI and PPI values are pre-converted from NBS index format (e.g. 97.7 → −2.3%) so you can use them directly without subtracting 100.

Unit Conversion Notes

Several NBS indicators require unit conversion when using the official EasyQuery API directly. The chinadata.live API handles these conversions for you:

Indicator NBS Raw Format chinadata.live Format Conversion
CPI (YoY)Index (101.5 = +1.5%)1.5 (% change)val − 100
PPI (YoY)Index (97.7 = −2.3%)−2.3 (% change)val − 100
GDP (quarterly)100M CNY100M CNY (unchanged)None
M2 / M1 / M0100M CNY100M CNY (unchanged)None
PMI% (already a rate)% (unchanged)None

Always check the unit field in the API response to confirm the format.

Related Datasets

Source Verification & Citation

chinadata.live is not the official NBS API. It is an independent data portal that mirrors and cleans official Chinese government statistics for English-language users. Always verify critical figures against the original source.

Suggested citation: National Bureau of Statistics of China, [indicator name], retrieved [YYYY-MM-DD] from chinadata.live. Original source: data.stats.gov.cn.

Data is provided "as is" without warranty of completeness or accuracy. Users should verify critical figures against the original NBS source before making business, investment, or policy decisions.

💬 Need custom data?