photonichat-api-www

Quote proxy for the photonichat ESP32 clock — Sina Finance (stocks/FX/futures/indices) + CoinGecko (crypto).

Live sample

loading…

Updates every 10s via /clock. Upstream cache: 30s quotes, 60s metals, 30s crypto.

Endpoints

MethodPathReturnsTry it
GET/q/{symbol} Single-symbol JSON quote (alias for /quote/{symbol}) /q/sh600519 · /q/hk00700 · /q/gb_aapl
GET/q?syms=A,B,C Batch JSON (single Sina request for the whole list) /q?syms=…
GET/quote/{symbol} Full JSON: name, price, change, change_pct, currency, exchange, ts, ts_utc /quote/sh600519
GET/metals Gold + silver USD/oz (Sina hf_GC, hf_SI) /metals
GET/crypto?ids=… CoinGecko prices in USD with 24h change /crypto
GET/clock?stocks=…&coins=… One-shot bundle for the clock face: stocks + metals + crypto /clock
GET/symbols Full catalog as JSON/symbols
GET/cache Cache hit/miss stats and entry ages/cache
GET/healthz {"ok":true}/healthz

Symbol formats

All Sina hq.sinajs.cn codes work natively. Yahoo-style aliases (AAPL, 0700.HK, 600519.SS, USDCNY=X, GC=F, ^GSPC) are auto-translated.

MarketSina codeYahoo alias accepted
Shanghai A-sharesh600519600519.SS
Shenzhen A-sharesz000001000001.SZ
Beijing Exchangebj430047430047.BJ
Hong Konghk007000700.HK
US stockgb_aaplAAPL
Index (CN)sh000001, sz399001
Index (intl)int_sp500, int_nasdaq, int_hangseng^GSPC, ^IXIC, ^HSI
Forexfx_susdcny, fx_seurusdUSDCNY=X, EURUSD=X
NYMEX futurehf_GC, hf_SI, hf_CLGC=F, SI=F, CL=F
Spot precious metalhf_XAU, hf_XAGXAUUSD, XAGUSD

Full A-share universe

The complete Shanghai + Shenzhen + Beijing A-share listing, loaded from Sina at startup and cached to disk for 7 days. Reload manually with /symbols/reload.

loading universe…

browse SH · browse SZ · browse BJ · browse all

Curated catalog

Hand-picked highlights across markets (including HK, US, indices, FX, futures, crypto). Or grab the whole curated list via /symbols JSON.

A-shares (Shanghai) · 8 symbols
SymbolName
sh600000Pudong Development Bank
sh600036China Merchants Bank
sh600519Kweichow Moutai
sh600490Penghui Energy
sh601318Ping An Insurance
sh601398ICBC
sh601857PetroChina
sh688981SMIC (STAR Market)
A-shares (Shenzhen) · 8 symbols
SymbolName
sz000001Ping An Bank
sz000002Vanke
sz000333Midea Group
sz000651Gree Electric
sz000725BOE Technology
sz000858Wuliangye
sz300750CATL
sz300760Mindray Medical
Hong Kong · 9 symbols
SymbolName
hk00700Tencent
hk00939CCB
hk00941China Mobile
hk01024Kuaishou
hk01299AIA
hk01810Xiaomi
hk03690Meituan
hk09988Alibaba
hk09618JD.com
US stocks (gb_) · 12 symbols
SymbolName
gb_aaplApple
gb_msftMicrosoft
gb_googlAlphabet
gb_amznAmazon
gb_nvdaNVIDIA
gb_tslaTesla
gb_metaMeta
gb_nflxNetflix
gb_amdAMD
gb_babaAlibaba ADR
gb_pddPDD Holdings
gb_nioNIO
Indices · 10 symbols
SymbolName
sh000001Shanghai Composite
sz399001Shenzhen Component
sz399006ChiNext
sh000300CSI 300
int_sp500S&P 500
int_nasdaqNasdaq Composite
int_djiDow Jones
int_hangsengHang Seng
int_nikkeiNikkei 225
int_ftseFTSE 100
Forex (fx_) · 8 symbols
SymbolName
fx_susdcnyUSD/CNY
fx_susdhkdUSD/HKD
fx_susdjpyUSD/JPY
fx_seurusdEUR/USD
fx_sgbpusdGBP/USD
fx_saudusdAUD/USD
fx_susdsgdUSD/SGD
fx_susdkrwUSD/KRW
Commodity futures (NYMEX, hf_) · 9 symbols
SymbolName
hf_GCGold (NY)
hf_SISilver (NY)
hf_CLWTI Crude Oil
hf_NGNatural Gas
hf_HGCopper
hf_PLPlatinum
hf_PAPalladium
hf_XAUSpot Gold (XAUUSD)
hf_XAGSpot Silver (XAGUSD)
Crypto (CoinGecko ids) · 7 symbols
SymbolName
bitcoinBTC
ethereumETH
solanaSOL
binancecoinBNB
rippleXRP
cardanoADA
dogecoinDOGE

ESP32 usage

// Single quote, JSON:
//   GET /q/sh600519
//   -> {"symbol":"SH600519","name":"贵州茅台","price":1450.5,
//        "change":6.1,"change_pct":0.42,"currency":"CNY","exchange":"SH",
//        "ts":1715200000,"ts_utc":"2024-05-08T22:13:20Z","source":"sina",
//        "input_symbol":"SH600519"}

// Full clock bundle in one fetch:
//   GET /clock?stocks=sh600519,hk00700,gb_aapl&coins=bitcoin,ethereum

Agent implementation guide

If you are an AI agent (or an LLM-driven client) reading this page to integrate with this server, follow these rules. Everything here is read-only HTTP GET, no auth, CORS-open, JSON.

1 · Decide which endpoint to call

User intentEndpointWhy
"What's the price of X?" (one symbol) GET /quote/{symbol} or GET /q/{symbol} Full JSON: name, price, change, change_pct, currency, exchange, ts, ts_utc, source.
Multiple symbols at once GET /q?syms=A,B,C One upstream call for the whole batch — always prefer this over N single calls.
Dashboard / "give me everything" GET /clock?stocks=…&coins=… Stocks + metals + crypto in one bundle.
Gold or silver spot price GET /metals USD/oz with 24h change_pct.
Crypto in USD GET /crypto?ids=bitcoin,ethereum,… CoinGecko ids (lowercase full name, not ticker).
"Find a Chinese stock by name" GET /symbols/search?q=… Substring match on symbol or Chinese name across the full A-share universe.

2 · Build a symbol the server understands

Before calling, normalize the user's input to one of the supported forms. The server is tolerant of Yahoo-style aliases, but if you can produce a native Sina code you'll skip a lookup.

Apple                 -> gb_aapl    (or AAPL)
Tencent (HK 0700)     -> hk00700    (or 0700.HK)
Kweichow Moutai       -> sh600519   (or 600519.SS)
Ping An Bank          -> sz000001   (or 000001.SZ)
S&P 500               -> int_sp500  (or ^GSPC)
Hang Seng             -> int_hangseng (or ^HSI)
USD/CNY               -> fx_susdcny (or USDCNY=X)
NYMEX gold future     -> hf_GC      (or GC=F)
Spot gold (XAUUSD)    -> hf_XAU     (or XAUUSD)
Spot silver (XAGUSD)  -> hf_XAG     (or XAGUSD)
Bitcoin (crypto)      -> bitcoin    (CoinGecko id, /crypto endpoint)

Rule of thumb: stocks/FX/futures/indices → /quote or /q; crypto → /crypto. Crypto ids are not tickers — use the lowercase CoinGecko slug (bitcoin, not BTC).

3 · Response schema

Every quote object — whether from /q/{sym}, /quote/{sym}, or as an item inside /q?syms=… — has the same shape. Every envelope response also carries a top-level ts + ts_utc.

{
  "symbol": "SH600519",        // server-normalized
  "input_symbol": "SH600519",  // exactly what you sent (uppercased)
  "name": "贵州茅台",
  "price": 1450.5,
  "change": 6.1,
  "change_pct": 0.42,          // already a percent, not a fraction
  "currency": "CNY",
  "exchange": "SH",
  "ts": 1715200000,            // unix seconds, upstream timestamp when available
  "ts_utc": "2024-05-08T22:13:20Z",  // ISO 8601 UTC, derived from ts
  "source": "sina"
}

404 means "no quote available for that symbol" — either the symbol is unknown or upstream returned an empty body. Treat as a normal "not found", not an error to retry.

4 · Worked examples

curl https://<host>/quote/gb_nvda
curl 'https://<host>/q?syms=sh600519,hk00700,gb_aapl,int_sp500'
curl 'https://<host>/clock?stocks=gb_aapl,gb_tsla&coins=bitcoin,ethereum'
curl 'https://<host>/symbols/search?q=茅台'
# Python
import httpx
r = httpx.get("https://<host>/q", params={"syms": "gb_aapl,hk00700,sh600519"})
for q in r.json()["quotes"]:
    print(q["symbol"], q["price"], q["change_pct"], "%")
// JavaScript
const d = await (await fetch('/q?syms=gb_aapl,hk00700,sh600519')).json();
d.quotes.forEach(q => console.log(q.symbol, q.price, q.change_pct + '%'));

5 · Rules an AI client should follow

Caching

In-memory TTL cache. One upstream fetch per (symbol, TTL window) serves every polling device. See /cache for live stats.