Hong Kong market data API guide (HK)

Connect to Hong Kong market data with ZaFeed. Includes HKEX:00700 examples, historical candles, live WebSocket subscriptions, and market key authentication.

简体中文

Published March 21, 2026
Market: Hong Kong (HK)
Exchange: HKEX

Verify the Hong Kong market code, symbol format, and response fields before launch.

Use this guide to review the implementation and verify requests before release.

Overview

This guide covers HK parameter mapping, exchange identifiers, and symbol conventions.

Use cases

  • Hong Kong dashboards and market rankings
  • Live HKEX subscriptions and alerts
  • Historical candles for backtesting and validating strategies with HKEX:00700
  • A single data gateway for multiple markets

From integration to production

Use WebSocket for live data and REST for historical data:

  • WebSocket: Stream order books and latest prices, and trigger alerts.
  • Historical REST API: Load and backfill data for charts, backtests, and audits.
  • Authentication: Use the same market key for REST and WebSocket. Send it in the X-API-Key header for REST and the key connection parameter for WebSocket. Each market has its own key.

The two interfaces work together:

Live updates stay responsive, while REST provides a way to recover missing data.

Prelaunch checklist

  • Before testing, verify that the market key is valid and market matches it.
  • Check that the market and symbol use the documented formats.
  • Add heartbeats, reconnect logic, and deduplication to the stream.
  • Fetch historical data in batches to avoid overload.
  • Use consistent precision and time zones in storage.

Integration tip

Use the historical API to establish a baseline before connecting to the Hong Kong live feed.

Quick start

REST (historical candles)

GET https://api.zafeed.com/v1/klines?market=HK&symbol=HKEX:00700&interval=1m&limit=200
X-API-Key: YOUR_HK_KEY

WebSocket (live quotes)

wss://api.zafeed.com/v1/stream?key=YOUR_HK_KEY
{"op":"subscribe","market":"HK","symbols":["HKEX:00700"]}

Parameters and fields

Main request parameters:

  • market: Market code, for example HK.
  • symbol: Full symbol code, for example HKEX:00700.
  • interval: Candle interval, such as 1m, 5m, 15m, 1h, or 1d.
  • limit: Number of items. Defaults to 200, up to 1,000.

Use consistent fields when storing data:

  • symbol, venue, and time (Unix milliseconds)
  • open/high/low/close、volume
  • Live updates can include price/change/changePct and other snapshot fields.

Integration examples

cURL (initial checks)

curl "https://api.zafeed.com/v1/klines?market=HK&symbol=HKEX:00700&interval=1m&limit=200" \
  -H "X-API-Key: YOUR_HK_KEY"

JavaScript (Node.js)

const url = "https://api.zafeed.com/v1/klines?market=HK&symbol=HKEX:00700&interval=1m&limit=200";
const resp = await fetch(url, {
  headers: {
    "X-API-Key": "YOUR_HK_KEY"
  }
});
const data = await resp.json();
console.log(data);

Python (data jobs)

import requests

url = "https://api.zafeed.com/v1/klines?market=HK&symbol=HKEX:00700&interval=1m&limit=200"
headers = {"X-API-Key": "YOUR_HK_KEY"}
res = requests.get(url, headers=headers, timeout=20)
print(res.status_code, res.json())

Go (backend services)

req, _ := http.NewRequest("GET", "https://api.zafeed.com/v1/klines?market=HK&symbol=HKEX:00700&interval=1m&limit=200", nil)
req.Header.Set("X-API-Key", "YOUR_HK_KEY")
resp, _ := http.DefaultClient.Do(req)

WebSocket (live subscriptions)

const ws = new WebSocket("wss://api.zafeed.com/v1/stream?key=YOUR_HK_KEY");
ws.onopen = () => ws.send(JSON.stringify({
  op: "subscribe",
  market: "HK",
  symbols: ["HKEX:00700"]
}));

Example parameters

  • market:HK
  • symbol:HKEX:00700
  • venue:HKEX

Troubleshooting

1. HTTP 401

If the key is missing, invalid, rotated, or expired, check its status in the member center. Copy the current key without spaces.

2. Market and symbol mismatch

Check that market=HK and symbol=HKEX:00700 belong to the same market.

3. WebSocket disconnects soon after connecting

Check heartbeats, proxy timeouts, and duplicate connections. Each market key allows one concurrent WebSocket connection by default.

4. Delayed updates

Show incoming changes in the UI and write or validate data asynchronously on the server.

Performance and reliability

  • Reuse connections and retry with backoff to limit the impact of temporary failures.
  • Request historical data in batches and respect rate limits.
  • Deduplicate live messages by symbol and time.
  • Monitor error rates, latency, and reconnection counts.

Frequently asked questions

1) When should I use WebSocket?

Use WebSocket to update quotes and order books in real time or to trigger alerts.

2) When should I use historical candles?

Use historical candles for backtesting, calculating indicators, and filling data gaps.

3) Where do I send my market key?

Send the market key in the REST header X-API-Key or the WebSocket connection parameter key. The market parameter must match the key or the API returns 403. Keep the key on your server.

4) What can I build with these APIs?

Market data terminals, trading signals, backtesting platforms, risk controls, and alerting tools.

Common issues and fixes

  • Add retries and rate limits before using examples in production.
  • Check symbol naming conventions across services.
  • Check that repeated updates are safe and duplicates are removed.

Production monitoring

  • Monitor each market separately to spot regional issues.
  • Track error rates, P95 latency, and reconnection counts.
  • Save sample responses for incident reviews.

After launch

Add troubleshooting findings to your runbook after each incident.

References