DEV Community

Exchange Rate API
Exchange Rate API

Posted on Originally published at allratestoday.com

Bank of China Exchange Rate API: CNY Buy and Sell Rates as JSON

Bank of China is one of China’s four large state-owned banks and its oldest foreign-exchange bank. Its board lists spot-exchange and cash buy/sell rates plus a middle rate for about 34 currencies, quoted per 100 units of foreign currency, with a publication time on each row. This guide shows how to read that board as JSON: what the rates mean, how they compare with the People’s Bank of China official rate, and the calls that return them.

What the Bank of China board shows

  • 34 currencies against the Chinese yuan: AED, AUD, CAD, CHF, DKK, EUR, GBP, HKD, HUF, IDR, JPY, KRW, KZT, MNT, MOP, MUR, MXN, MYR, NOK, NZD, PHP, PLN, QAR, RON, RSD, RUB, SAR, SEK, SGD, THB, TRY, USD, ZAR and ZMW. Every value is CNY per 1 unit of the foreign currency.
  • The spot exchange (transfer) buy / sell pair. The People’s Bank of China sets a daily central parity for the yuan, but the rate a customer gets is a bank’s board, and Bank of China’s is the one most quoted. Chinese banks publish spot-exchange (transfer) and cash columns, quoted per 100 units of foreign currency; the pair here is spot exchange, shown per 1 unit.
  • USD on 13 November 2026: Bank of China bought at 6.6606 and sold at 6.6886 CNY, a spread of 0.42%. The People’s Bank of China official rate was 6.7152, so the bank's mid sat -0.60% from it.
  • The bank's own timestamp. The page prints a last-updated stamp (2026/11/13 20:15:16 (Beijing) on the board above), returned as bank_updated_at next to our captured_at.
  • Every day's board is kept permanently, from 20 October 2026. Read one past day with ?date=, or a range for one currency with the /history endpoint (paid plans).

Spreads across the board

On the 13 November 2026 board the tightest spreads were HKD (0.40%), USD (0.42%), MOP (0.46%) and the widest ZMW (22.00%), MUR (22.00%), QAR (22.00%). Spread is (sell − buy) ÷ mid: what a round trip through the bank costs, before any fees. The API returns it on every row as spread_pct, so you can rank currencies or alert when a bank widens its board.

Get the board (REST)

You need an API key; the free key works. The full board:

curl "https://allratestoday.com/api/v1/bank-rates/cn/boccn" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode

What comes back (the 13 November 2026 board, first three rows):

{
  "bank": "boccn",
  "name": "Bank of China",
  "country": "cn",
  "quote_ccy": "CNY",
  "bank_updated_at": "2026/11/13 20:15:16 (Beijing)",
  "basis": "Spot exchange (transfer) buy / sell",
  "captured_at": "2026-11-13T12:18:39.394Z",
  "rates": [
    {"ccy":"AED","buy":1.8036,"sell":1.829,"mid":1.8163,"spread_pct":1.398,"official":1.8227220531141208,"vs_official_pct":-0.352},
    {"ccy":"AUD","buy":4.5179,"sell":4.5538,"mid":4.53585,"spread_pct":0.791,"official":4.5575,"vs_official_pct":-0.475},
    {"ccy":"CAD","buy":4.6635,"sell":4.7001,"mid":4.6818,"spread_pct":0.782,"official":4.6947,"vs_official_pct":-0.275},
    … 31 more currencies
  ],
  "disclaimer": "…",
  "attribution": { … }
}
Enter fullscreen mode Exit fullscreen mode

One currency, with the row fields at the top level:

curl "https://allratestoday.com/api/v1/bank-rates/cn/boccn?ccy=USD" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode
{
  "bank": "boccn",
  "name": "Bank of China",
  "country": "cn",
  "quote_ccy": "CNY",
  "bank_updated_at": "2026/11/13 20:15:16 (Beijing)",
  "basis": "Spot exchange (transfer) buy / sell",
  "captured_at": "2026-11-13T12:18:39.394Z",
  "ccy": "USD",
  "buy": 6.6606,
  "sell": 6.6886,
  "mid": 6.6746,
  "spread_pct": 0.42,
  "official": 6.7152,
  "vs_official_pct": -0.605,
  "disclaimer": "Retail buy/sell rates as displayed on each bank’s own website at capture time, quoted as home currency per 1 unit of foreign currency. Indicative only: banks change these through the day, apply them at the counter or in-app, and they are not official or reference rates. For the rate a regulation names, use the central-bank endpoints.",
  "attribution": {
    "source": "Board rates published by Bank of China on its own website, collected by AllRatesToday",
    "bank_url": "https://www.boc.cn/sourcedb/whpj/enindex_1619.html",
    "url": "https://allratestoday.com/bank-exchange-rate-api/cn/boccn/",
    "terms": "Public pages that show the rates need a visible link to allratestoday.com"
  }
}
Enter fullscreen mode Exit fullscreen mode

The board as it stood on a past day:

curl "https://allratestoday.com/api/v1/bank-rates/cn/boccn?date=2026-11-06" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode

One currency over a date range, one row per day (paid plans; add &format=csv, xml or xlsx for a file):

curl "https://allratestoday.com/api/v1/bank-rates/cn/boccn/history?ccy=USD&from=2026-10-20&to=2026-11-13" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode

JavaScript

npm install @allratestoday/sdk
Enter fullscreen mode Exit fullscreen mode
import { AllRatesToday } from '@allratestoday/sdk';

const client = new AllRatesToday({ apiKey: 'art_live_your_key' });

// Bank of China's USD row
const r = await client.bankRates('cn', { bank: 'boccn', ccy: 'USD' });
console.log(`Bank of China buys USD at ${r.buy}, sells at ${r.sell} CNY`);

// The board as it stood on a past day
const past = await client.bankRates('cn', { bank: 'boccn', date: '2026-11-06' });
console.log(past.snapshot_date, past.rates.length);
Enter fullscreen mode Exit fullscreen mode

Python

import requests

r = requests.get(
    "https://allratestoday.com/api/v1/bank-rates/cn/boccn",
    headers={"Authorization": "Bearer art_live_your_key"},
    timeout=10,
)
r.raise_for_status()
for row in r.json()["rates"]:
    print(row["ccy"], row["buy"], row["sell"], row["spread_pct"])
Enter fullscreen mode Exit fullscreen mode

Board rate or official rate?

The People’s Bank of China rate is the one tax, accounting and customs rules in China name; nobody transacts at it. Bank of China's board is the price a customer actually gets. The API puts both on every row: official is the central bank's rate for the same currency and vs_official_pct is how far the bank's mid sits from it. Use the board to show customers a real price, compare banks for a remittance, or keep a dated record of what the bank quoted; use the People’s Bank of China endpoint when a rule asks for the official rate.

FAQ

Where do the Bank of China rates come from?

From the bank's own public rates page (https://www.boc.cn/sourcedb/whpj/enindex_1619.html), read hourly. AllRatesToday does not change the numbers: each row is the buy and sell price Bank of China shows, with the mid, the spread and the People’s Bank of China rate added.

Are these the official CNY exchange rates?

No. They are Bank of China's retail prices for customers. The official rate in China is the People’s Bank of China rate, which the API returns as official on each row where the central bank has one, and in full from the central-bank endpoint.

How often is the Bank of China board updated?

AllRatesToday reads the page every hour. The bank's own last-updated stamp is returned as bank_updated_at, so you can tell a fresh read of an unchanged board from a new board.

Can I get Bank of China rates for a past date?

Yes, from 20 October 2026 onward; every day's board is kept permanently. Add ?date=YYYY-MM-DD for one day: the response is the board captured that day, or the nearest earlier day within five days, with date_requested and snapshot_date added. For a range, /history?ccy=USD&from=…&to=… returns one row per day as JSON, CSV, XML or XLSX on paid plans.

Do I need an API key?

Yes. Commercial bank boards need an API key; any plan works, the free key included, and each call counts against the plan. Public pages or widgets that show the rates need a visible link to allratestoday.com.


Live board, refreshed hourly: Bank of China rates on AllRatesToday. Every bank in China side by side: China bank rates.

Top comments (0)