Tencent HTTP Stock Market Data Interface

Recently, while creating a cost reference table for options trading, I needed the spot quotes for the three index options varieties corresponding to the SSE 50, CSI 300, and CSI 1000 indices. I used the Tencent HTTP market data interface, and since the online guides are quite scattered, I will organize this information for friends who need it.URL Request:https://qt.gtimg.cn/q=sh000016,sh000300,sh000905,sh000852,sh000001,sz399001,sz399006,sh000688,sh601398,sh600519,sh688981,sz000002,sz300059Response Data (Text Format):The overall format consists of multi-line records separated by ‘;’ (with ‘
‘ for line breaks). Each record is organized in the format v_sh/sz stock code=”field information”, where the field information is further separated by ‘~’. Some fields are also combined fields separated by ‘/’, and some fields, such as trading volume, are repeated multiple times. There is limited information available online,
with a total of 87 fields, of which only the first 50 fields are confirmed; the rest are left for users to guess.

v_sh000016="1~SSE 50~000016~2789.17~2798.31~2795.78~38923878~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161410~-9.14~-0.33~2801.08~2784.38~2789.17/38923878/82804572799~38923878~8280457~0.23~11.46~~2801.08~2784.38~0.60~214200.51~288655.05~0.00~-1~-1~0.90~0~2792.97~~~~~~8280457.2799~0.0000~0~ ~ZS~3.89~1.27~~~~3016.87~2199.45~-0.23~1.18~1.78~1705881434195~~-7.63~2.23~1705881434195~~~20.20~-0.01~~CNY~0~~0.00~0";v_sh000300="1~CSI 300~000300~4104.97~4114.67~4109.27~173171201~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161428~-9.70~-0.24~4122.21~4097.42~4104.97/173171201/308507687635~173171201~30850769~0.53~13.30~~4122.21~4097.42~0.60~460379.08~610809.40~0.00~-1~-1~0.95~0~4110.05~~~~~~30850768.7635~0.0000~0~ ~ZS~4.32~1.23~~~~4450.37~3145.79~-0.54~2.25~5.06~3293003025056~~-4.87~-0.14~3293003025056~~~22.80~-0.02~~CNY~0~~0.00~0";v_sh000905="1~CSI 500~000905~6323.50~6337.54~6324.17~172507526~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161404~-14.04~-0.22~6351.33~6308.15~6323.50/172507526/259175300068~172507526~25917530~1.54~30.68~~6351.33~6308.15~0.68~130376.05~148788.12~0.00~-1~-1~1.07~0~6327.58~~~~~~25917530.0068~0.0000~0~ ~ZS~10.44~1.78~~~~6417.81~4397.16~0.38~4.92~10.64~1122736197176~~-10.28~1.02~1122736197176~~~32.96~-0.02~~CNY~0~~0.00~0";v_sh000852="1~CSI 1000~000852~6838.13~6862.15~6844.44~251465671~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161404~-24.02~-0.35~6865.84~6816.09~6838.13/251465671/381544614397~251465671~38154461~2.61~42.16~~6865.84~6816.09~0.72~115179.11~134436.56~0.00~-1~-1~1.06~0~6840.80~~~~~~38154461.4397~0.0000~0~ ~ZS~14.78~2.51~~~~6876.50~4342.21~1.96~5.84~12.90~964195045865~~-2.96~5.62~964195045865~~~44.28~-0.03~~CNY~0~~0.00~0";v_sh000001="1~SSE Index~000001~3635.13~3639.67~3634.85~526407572~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161410~-4.54~-0.12~3645.37~3625.45~3635.13/526407572/713569731142~526407572~71356973~1.09~15.70~~3645.37~3625.45~0.55~543035.37~697145.41~0.00~-1~-1~1.05~0~3636.20~~~~~~71356973.1142~0.0000~0~ ~ZS~8.45~2.11~~~~3674.40~2689.70~1.15~3.56~7.52~4713929285688~~-6.93~5.69~4713929285688~~~26.66~-0.00~~CNY~0~~0.00~0";v_sz399001="51~Shenzhen Component Index~399001~11128.67~11157.94~11136.34~681934695~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161415~-29.27~-0.26~11184.55~11108.46~11128.67/681934695/996656917079~681934695~99665692~2.86~45.05~~11184.55~11108.46~0.68~322489.94~388256.03~0.00~-1~-1~1.05~0~11140.11~~~~~~99665691.7079~0.0000~0~ ~ZS~6.86~1.25~~~~11864.11~7908.52~-0.35~4.04~9.25~2380175168769~~-1.07~-2.03~2380175168769~~~31.76~-0.02~~CNY~0~~0.00~0";v_sz399006="51~ChiNext Index~399006~2333.96~2342.86~2338.25~243495473~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161430~-8.90~-0.38~2353.99~2330.01~2333.96/243495473/500290277555~243495473~50029028~4.79~63.69~~2353.99~2330.01~1.02~115665.84~148352.36~0.00~-1~-1~1.03~0~2338.65~~~~~~50029027.7555~0.0000~0~ ~ZS~8.98~0.49~~~~2576.22~1512.17~-0.26~5.75~14.23~507897710070~~2.58~-3.45~507897710070~~~44.83~-0.05~~CNY~0~~0.00~0";v_sh000688="1~STAR 50~000688~1043.54~1058.21~1052.46~6792742~0~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20250808161404~-14.67~-1.39~1052.74~1042.84~1043.54/6792742/33381498692~6792742~3338150~1.10~138.89~~1052.74~1042.84~0.94~25116.55~36177.79~0.00~-1~-1~1.13~0~1047.34~~~~~~3338149.8692~0.0000~0~ ~ZS~5.52~0.65~~~~1140.37~640.35~-1.01~4.94~4.25~61761218149~~-37.52~-1.68~61761218149~~~47.20~-0.00~~CNY~0~~0.00~0";v_sh601398="1~Industrial and Commercial Bank of China~601398~7.79~7.84~7.84~2739258~1119204~1620054~7.78~34433~7.77~50009~7.76~39763~7.75~23331~7.74~11247~7.79~14720~7.80~44507~7.81~11068~7.82~13119~7.83~11875~~20250808161422~-0.05~-0.64~7.90~7.77~7.79/2739258/2144008142~2739258~214401~0.10~7.66~~7.90~7.77~1.66~21002.79~27764.05~0.76~8.62~7.06~0.69~63494~7.83~8.25~7.59~~~0.34~214400.8142~0.0000~0~ ~GP-A~17.82~2.23~3.95~8.98~0.71~8.20~5.14~4.01~-0.70~9.64~269612212539~356406257089~24.99~35.90~269612212539~~~40.06~0.13~~CNY~0~___D__F__N~7.88~-26465";v_sh600519="1~Kweichow Moutai~600519~1420.97~1422.35~1423.05~18655~7333~11323~1420.96~23~1420.95~38~1420.94~4~1420.90~2~1420.80~17~1420.97~13~1420.98~2~1420.99~5~1421.00~22~1421.03~1~~20250808161419~-1.38~-0.10~1426.50~1418.00~1420.97/18655/2651478118~18655~265148~0.15~20.05~~1426.50~1418.00~0.60~17850.19~17850.19~7.98~1564.59~1280.12~0.74~41~1421.30~16.62~20.70~~~0.99~265147.8118~0.0000~0~ ~GP-A~-5.04~0.28~3.62~34.45~29.53~1858.52~1194.35~-2.34~-0.42~-11.43~1256197800~1256197800~32.28~-6.94~1256197800~~~3.03~0.01~~CNY~0~___D__F__N~1420.63~5";v_sh688981="1~SMIC~688981~86.66~90.59~88.00~58473050~22386146~36086904~86.66~571~86.65~810~86.64~105~86.63~107~86.62~182~86.67~322~86.68~112~86.70~108~86.71~67~86.72~61~~20250808161431~-3.93~-4.34~88.50~86.66~86.66/58473050/5098977106~58473050~509898~2.94~152.24~~88.50~86.66~2.03~1723.11~6920.95~4.63~108.71~72.47~2.18~1105~87.20~127.56~187.12~~~1.37~509897.7106~46.0511~5314~A R~GP-A-KCB~-8.41~-1.85~0.00~3.04~2.10~109.50~42.40~-7.29~-1.70~2.65~1988359129~7986322759~45.19~-12.59~1988359129~~~82.52~-0.03~~CNY~0~___D__F__NY~86.60~1449";v_sz000002="51~Wanke A~000002~6.45~6.47~6.46~514307~177511~336797~6.44~2367~6.43~26807~6.42~22303~6.41~11603~6.40~19140~6.45~16179~6.46~10032~6.47~10143~6.48~10443~6.49~7180~~20250808161415~-0.02~-0.31~6.47~6.42~6.45/514307/331191661~514307~33119~0.53~-1.39~~6.47~6.42~0.77~626.73~769.53~0.39~7.12~5.82~0.73~28243~6.44~-3.08~-1.56~~~1.35~33119.1661~0.0000~0~ ~GP-A~-11.16~0.94~0.00~-28.14~-4.46~10.69~6.18~-4.87~-4.59~-5.01~9716812790~11930709471~20.74~-28.89~9716812790~~~-6.79~0.00~~CNY~0~~6.50~-9119";v_sz300059="51~East Money~300059~23.20~23.54~23.46~2356087~951324~1404763~23.20~37897~23.19~6315~23.18~9805~23.17~2084~23.16~2505~23.21~2303~23.22~5134~23.23~2833~23.24~1870~23.25~3214~~20250808161454~-0.34~-1.44~23.47~23.20~23.20/2356087/5490472674~2356087~549047~1.76~35.35~~23.47~23.20~1.15~3103.32~3666.54~4.44~28.25~18.83~0.95~43252~23.30~33.76~38.15~~~2.26~549047.2674~65.6560~283~ A~GP-A-CYB~-9.94~0.13~0.26~12.45~3.13~30.94~10.05~-3.29~-2.77~6.32~13376386383~15804037675~58.48~-17.50~13376386383~~~118.66~-0.09~~CNY~0~~23.15~3989";

Field Description:

<

Field Number Field Name Description
1 Exchange ID 1 – Shanghai; 51 – Shenzhen
2 Contract Name
3 Contract ID
4 Latest Price
5 Previous Close
6 Opening Price
7 Volume Lots
8 Open Interest Lots
9 Close Interest Lots
10 Buy 1 Price
11 Buy 1 Volume
Buy 2, 3, 4 Levels
18 Buy 5 Price
19 Buy 5 Volume
20 Sell 1 Price
21 Sell 1 Volume
Sell 2, 3, 4 Levels
28 Sell 5 Volume
29 Sell 5 Price
30 Recent Transactions
31 Time Format: yyyymmddhhmmss
32 Change
33 Change Percentage
34 Highest Price
35 Lowest Price
36 Combined Field Latest Price/Volume/Turnover (CNY)
37 Volume Lots
38 Turnover Ten Thousand
39 Turnover Rate
40 Price-Earnings Ratio
41 Empty
42 Highest Price
43 Lowest Price
44 Amplitude
45 Market Capitalization
46 Total Market Value
47 Price-Book Ratio
48 Limit Up Price
49 Limit Down Price
50 Volume Ratio
51
52 Average Price

Note:The query frequency should not be too high, or the IP may be blocked. You can refer to our Tencent CTPAPI market data interface source code. For example, if you call it every 100ms and query only 100 stocks at a time, you can complete the query for all stocks in the A-share market in 6 seconds by calling it 10 times per second for 1000 stocks.Here is the corresponding CTPAPI market data structure parsing code:

DepthMarketData.InstrumentID = fields[2]if fields[0] == "1":    DepthMarketData.ExchangeID = "SSE"elif fields[0] == "51":    DepthMarketData.ExchangeID = "SZSE"DepthMarketData.LastPrice = float(fields[3])DepthMarketData.PreClosePrice = float(fields[4])DepthMarketData.OpenPrice = float(fields[5])DepthMarketData.Volume = int(fields[6])DepthMarketData.HighestPrice = float(fields[33])DepthMarketData.LowestPrice = float(fields[34])last_fields = fields[35].split('/')if len(last_fields)==3:    DepthMarketData.Turnover = float(last_fields[2])else:    DepthMarketData.Turnover = float(fields[37])*10000DepthMarketData.ActionDay = fields[30][:8]DepthMarketData.UpdateTime = f"{fields[30][8:10]}:{fields[30][10:12]}:{fields[30][12:14]}"DepthMarketData.TradingDay = fields[30][:8]

Output Effect (Stock Code, Exchange, Latest Price, Volume, Turnover, Opening, Highest, Lowest, Previous Close, Date, Time):

000016 SSE 2789.17 38923878 82804572799.0 2795.78 2801.08 2784.38 2798.31 20250808 16:14:10000300 SSE 4104.97 173171201 308507687635.0 4109.27 4122.21 4097.42 4114.67 20250808 16:14:28000905 SSE 6323.5 172507526 259175300068.0 6324.17 6351.33 6308.15 6337.54 20250808 16:14:04000852 SSE 6838.13 251465671 381544614397.0 6844.44 6865.84 6816.09 6862.15 20250808 16:14:04000001 SSE 3635.13 526407572 713569731142.0 3634.85 3645.37 3625.45 3639.67 20250808 16:14:10399001 SZSE 11128.67 681934695 996656917079.0 11136.34 11184.55 11108.46 11157.94 20250808 16:14:15399006 SZSE 2333.96 243495473 500290277555.0 2338.25 2353.99 2330.01 2342.86 20250808 16:14:30000688 SSE 1043.54 6792742 33381498692.0 1052.46 1052.74 1042.84 1058.21 20250808 16:14:04601398 SSE 7.79 2739258 2144008142.0 7.84 7.9 7.77 7.84 20250808 16:14:22600519 SSE 1420.97 18655 2651478118.0 1423.05 1426.5 1418.0 1422.35 20250808 16:14:19688981 SSE 86.66 58473050 5098977106.0 88.0 88.5 86.66 90.59 20250808 16:14:31000002 SZSE 6.45 514307 331191661.0 6.46 6.47 6.42 6.47 20250808 16:14:15300059 SZSE 23.2 2356087 5490472674.0 23.46 23.47 23.2 23.54 20250808 16:14:54

Leave a Comment