AShareHub API Documentation
AShareHub provides RESTful API access to Chinese A-Share market data through 29 endpoints, covering 5000+ stocks on the Shanghai and Shenzhen exchanges. Our API delivers daily OHLCV prices, fundamental indicators, northbound capital flows, money flow by order size, chip distribution, margin trading, block trades, shareholder data, concept/theme sectors, FX rates, index data, industry classifications, and financial statements.
https://asharehub.com
Version: v1
Format: JSON
Quick Start
Step 1: Create a free account at asharehub.com/console/register
Step 2: Generate your API key in the Dashboard
Step 3: Make your first request:
curl -H "X-API-Key: ash_your_key_here" \
"https://asharehub.com/v1/market/daily?ts_code=000001.SZ&limit=5"
pip install asharehub
from asharehub import AShareHub
client = AShareHub(api_key="ash_your_key_here")
df = client.market_daily(ts_code="000001.SZ", limit=5)
print(df)
Authentication
All data API endpoints require an API key passed via the X-API-Key header.
curl -H "X-API-Key: ash_your_key_here" https://asharehub.com/v1/market/daily
Rate Limits
Requests are limited per API key on a daily basis. When exceeded, the API returns 429 Too Many Requests.
| Plan | Price | Daily Limit |
|---|---|---|
| Free | $0 | 100 |
| Pro | $49/mo | 10,000 |
| Business | $99/mo | 50,000 |
Market Daily
Daily OHLCV price data for A-share stocks.
GET /v1/market/daily
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| trade_date | string | Trading date |
| open | number | Opening price |
| high | number | Highest price |
| low | number | Lowest price |
| close | number | Closing price |
| pre_close | number | Previous close |
| change | number | Price change |
| pct_chg | number | Change % |
| vol | number | Volume (lots) |
| amount | number | Turnover (CNY thousands) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/daily?ts_code=000001.SZ&start_date=2024-01-01&end_date=2024-01-31&limit=5"
Fundamentals
Daily fundamental indicators including PE, PB, turnover rate, market cap, etc.
GET /v1/market/fundamentals
Parameters
Same as Market Daily: ts_code, start_date, end_date, limit, offset
Key Response Fields
| Field | Description |
|---|---|
| pe / pe_ttm | Price-to-Earnings ratio (static / trailing 12m) |
| pb | Price-to-Book ratio |
| ps / ps_ttm | Price-to-Sales ratio |
| turnover_rate / turnover_rate_f | Turnover rate (total / free float) |
| total_mv / circ_mv | Total / circulating market cap (CNY 10k) |
| volume_ratio | Volume ratio |
Margin Trading
Daily margin trading and short selling data per stock.
GET /v1/market/margin
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| trade_date | string | Trading date |
| ts_code | string | Stock code |
| name | string | Stock name |
| rzye | number | Margin buy balance (CNY) |
| rqye | number | Short sell balance (CNY) |
| rzmre | number | Margin buy amount today |
| rqyl | number | Short sell volume today |
| rzche | number | Margin repayment today |
| rqchl | number | Short cover volume today |
| rqmcl | number | Short sell volume today |
| rzrqye | number | Total margin + short balance |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/margin?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Block Trade
Block (large-lot) trade records for A-share stocks.
GET /v1/market/block-trade
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| trade_date | string | Trading date |
| price | number | Trade price (CNY) |
| vol | number | Volume (10k shares) |
| amount | number | Amount (10k CNY) |
| buyer | string | Buyer broker |
| seller | string | Seller broker |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/block-trade?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Top List
Dragon & Tiger list — stocks triggering exchange disclosure rules.
GET /v1/market/top-list
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| trade_date | string | Trading date |
| ts_code | string | Stock code |
| name | string | Stock name |
| close | number | Closing price |
| pct_change | number | Price change % |
| turnover_rate | number | Turnover rate % |
| amount | number | Total turnover (CNY) |
| l_sell | number | Institutional sell (CNY) |
| l_buy | number | Institutional buy (CNY) |
| l_amount | number | Institutional total (CNY) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/top-list?start_date=2024-01-01&end_date=2024-01-31&limit=5"
Holder Trade
Major shareholder and executive trades.
GET /v1/market/holder-trade
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| ann_date | string | Announcement date |
| holder_name | string | Holder name |
| holder_type | string | G=executive, P=individual, C=company |
| in_de | string | IN=buy, DE=sell |
| change_vol | number | Change volume |
| change_ratio | number | Change ratio |
| after_share | number | Shares after trade |
| after_ratio | number | Ratio after trade |
| avg_price | number | Average price |
| total_share | number | Total shares |
| begin_date | string | Trade begin date |
| close_date | string | Trade close date |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/holder-trade?ts_code=000001.SZ&limit=5"
Concepts
Concept/theme sector indices (AI, new energy, semiconductors, etc.).
GET /v1/market/concepts
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Concept code, e.g. BK0425.DC |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Concept code (e.g. BK0425.DC) |
| trade_date | string | Trading date |
| name | string | Concept name |
| leading | string | Leading stock name |
| leading_code | string | Leading stock code |
| pct_change | number | Daily return % |
| leading_pct | number | Leading stock return % |
| total_mv | number | Total market value (10k CNY) |
| turnover_rate | number | Turnover rate |
| up_num | number | Number of stocks up |
| down_num | number | Number of stocks down |
| idx_type | string | Index type |
| level | string | Level |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/concepts?start_date=2024-01-01&end_date=2024-01-31&limit=5"
Concept Members
Constituent stocks of concept/theme indices.
GET /v1/market/concept-members
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Concept index code |
| con_code | string | No | Constituent stock code |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| trade_date | string | Trading date |
| ts_code | string | Concept index code |
| con_code | string | Constituent stock code |
| name | string | Stock name |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/concept-members?ts_code=BK0425.DC&limit=10"
Adjustment Factor
Daily adjustment factors for calculating forward/backward adjusted prices. Essential for accurate historical price analysis across splits and dividends.
GET /v1/market/adj-factor
Parameters
ts_code, start_date, end_date, limit (max 5000), offset
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| trade_date | string | Trading date |
| adj_factor | number | Adjustment factor |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/adj-factor?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Technical Factors
Daily technical indicators (MACD, KDJ, RSI, Bollinger Bands, CCI) and forward/backward adjusted prices.
GET /v1/market/technical-factors
Parameters
ts_code, start_date, end_date, limit (max 5000), offset
Key Response Fields
| Field | Description |
|---|---|
| close_qfq / close_hfq | Forward / backward adjusted close price |
| macd_dif, macd_dea, macd | MACD indicator (DIF, DEA, histogram) |
| kdj_k, kdj_d, kdj_j | KDJ oscillator |
| rsi_6, rsi_12, rsi_24 | RSI (6/12/24 period) |
| boll_upper, boll_mid, boll_lower | Bollinger Bands |
| cci | Commodity Channel Index |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/technical-factors?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Limit List
Daily limit-up and limit-down stocks. A-share stocks have ±10% (±20% for ChiNext/STAR) daily price limits.
GET /v1/market/limit-list
Parameters
ts_code, start_date, end_date, limit_type (U=up, D=down, Z=broken), limit (max 5000), offset
Key Response Fields
| Field | Description |
|---|---|
| ts_code / name | Stock code and name |
| close / pct_chg | Closing price and change % |
| first_time / last_time | First/last limit hit time |
| open_times | Times limit was broken |
| limit_times | Consecutive limit days |
| limit | Type: U=up, D=down, Z=broken |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/market/limit-list?limit_type=U&start_date=2024-03-01&limit=10"
Northbound Capital Flows
Daily northbound capital flows via Stock Connect (Shanghai & Shenzhen). A key indicator of foreign investor sentiment toward A-shares.
GET /v1/flows/northbound
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 1000) |
| offset | int | No | Pagination offset |
Response Fields
| Field | Type | Description |
|---|---|---|
| trade_date | string | Trading date |
| north_money | number | Total northbound net buy (CNY million) |
| south_money | number | Total southbound net buy (CNY million) |
| ggt_ss | number | Shanghai Connect northbound (CNY million) |
| ggt_sz | number | Shenzhen Connect northbound (CNY million) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/flows/northbound?start_date=2024-01-01&end_date=2024-01-31"
Money Flow
Individual stock money flow by order size.
GET /v1/flows/moneyflow
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Key Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| trade_date | string | Trading date |
| buy_sm_vol / buy_sm_amount | number | Small order buy (<50K) |
| sell_sm_vol / sell_sm_amount | number | Small order sell |
| buy_md_vol / buy_md_amount | number | Medium order buy (50K–200K) |
| sell_md_vol / sell_md_amount | number | Medium order sell |
| buy_lg_vol / buy_lg_amount | number | Large order buy (200K–1M) |
| sell_lg_vol / sell_lg_amount | number | Large order sell |
| buy_elg_vol / buy_elg_amount | number | Extra-large order buy (>=1M) |
| sell_elg_vol / sell_elg_amount | number | Extra-large order sell |
| net_mf_vol | number | Net money flow volume |
| net_mf_amount | number | Net money flow (10k CNY) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/flows/moneyflow?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Northbound Holdings
Northbound (foreign) investor holdings per stock.
GET /v1/flows/northbound-holdings
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| trade_date | string | Trading date |
| ts_code | string | Stock code |
| name | string | Stock name |
| vol | number | Shares held |
| ratio | number | % of total shares |
| exchange | string | Exchange (SH/SZ) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/flows/northbound-holdings?ts_code=000001.SZ&start_date=2024-01-01&limit=5"
Financial Indicators
Quarterly financial indicators including ROE, margins, EPS, and 50+ metrics per company.
GET /v1/financials/indicators
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | Yes | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 1000) |
Key Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| end_date | string | Reporting period end date |
| ann_date | string | Announcement date |
| roe | number | Return on equity (%) |
| eps | number | Earnings per share (CNY) |
| grossprofit_margin | number | Gross profit margin (%) |
| netprofit_margin | number | Net profit margin (%) |
| current_ratio | number | Current ratio |
| debt_to_assets | number | Debt-to-asset ratio (%) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/indicators?ts_code=000001.SZ&limit=4"
Income Statement
Quarterly/annual income statement data. All monetary values in CNY.
GET /v1/financials/income
Parameters
ts_code, start_date, end_date (report period), limit (max 200), offset
Key Response Fields
| Field | Description |
|---|---|
| revenue / total_revenue | Operating / total revenue |
| operate_profit / total_profit | Operating / pre-tax profit |
| n_income / n_income_attr_p | Net income / attributable to parent |
| basic_eps / diluted_eps | Earnings per share |
| sell_exp / admin_exp / fin_exp / rd_exp | Operating expenses breakdown |
| ebit / ebitda | EBIT / EBITDA |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/income?ts_code=000001.SZ&start_date=2023-01-01&limit=4"
Balance Sheet
Quarterly/annual balance sheet data. All monetary values in CNY.
GET /v1/financials/balance-sheet
Parameters
ts_code, start_date, end_date (report period), limit (max 200), offset
Key Response Fields
| Field | Description |
|---|---|
| total_assets | Total assets |
| total_liab | Total liabilities |
| total_hldr_eqy_exc_min_int | Equity attributable to parent |
| money_cap | Cash and equivalents |
| accounts_receiv / inventories | Receivables / inventory |
| goodwill / intan_assets | Goodwill / intangible assets |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/balance-sheet?ts_code=000001.SZ&limit=4"
Cash Flow Statement
Quarterly/annual cash flow statement. Three sections: operating, investing, and financing activities.
GET /v1/financials/cash-flow
Parameters
ts_code, start_date, end_date (report period), limit (max 200), offset
Key Response Fields
| Field | Description |
|---|---|
| n_cashflow_act | Net operating cash flow |
| n_cashflow_inv_act | Net investing cash flow |
| n_cash_flows_fnc_act | Net financing cash flow |
| free_cashflow | Free cash flow |
| c_cash_equ_end_period | Cash at period end |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/cash-flow?ts_code=600519.SH&limit=4"
Earnings Forecast
Earnings forecasts (业绩预告) — early profit guidance disclosures required by exchange rules. Types include significant increase, decrease, turnaround, first loss, etc.
GET /v1/financials/forecast
Parameters
ts_code, start_date, end_date (announcement date), limit (max 1000), offset
Key Response Fields
| Field | Description |
|---|---|
| type | Forecast type (预增/预减/扭亏/首亏/续亏/略增/略减) |
| p_change_min / p_change_max | Net profit change range % |
| net_profit_min / net_profit_max | Forecast net profit range (10k CNY) |
| summary / change_reason | Summary and reason for change |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/forecast?ts_code=000001.SZ&limit=5"
Earnings Express
Preliminary earnings flash reports (业绩快报) released before formal financial statements.
GET /v1/financials/express
Parameters
ts_code, start_date, end_date (announcement date), limit (max 1000), offset
Key Response Fields
| Field | Description |
|---|---|
| revenue / n_income | Revenue / net income (CNY) |
| diluted_eps / diluted_roe | Diluted EPS and ROE |
| yoy_net_profit | Net profit YoY growth % |
| perf_summary | Performance summary |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/financials/express?ts_code=000001.SZ&limit=5"
Dividend
Cash and stock dividend distribution data. Includes ex-dividend dates, record dates, and payment dates.
GET /v1/shareholders/dividend
Parameters
ts_code, start_date, end_date (announcement date), limit (max 1000), offset
Key Response Fields
| Field | Description |
|---|---|
| cash_div | Cash dividend per share pre-tax (CNY) |
| stk_div | Total stock dividend per share |
| ex_date | Ex-dividend date |
| record_date / pay_date | Record date / payment date |
| div_proc | Progress (预案/实施) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/shareholders/dividend?ts_code=600519.SH&limit=10"
Index Daily
Daily OHLCV data for major Chinese market indices.
GET /v1/indices/daily
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Index code (default: 000001.SH — SSE Composite) |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
Common Index Codes
| Code | Name |
|---|---|
| 000001.SH | SSE Composite (上证综指) |
| 000300.SH | CSI 300 (沪深300) |
| 399001.SZ | SZSE Component (深证成指) |
| 399006.SZ | ChiNext (创业板指) |
| 000016.SH | SSE 50 (上证50) |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/indices/daily?ts_code=000300.SH&start_date=2024-01-01&limit=10"
Index Weight
Constituent stock weights for major indices. Useful for tracking index rebalancing and passive fund flows.
GET /v1/indices/index-weight
Parameters
index_code (e.g. 399300.SZ), start_date, end_date, limit (max 5000), offset
Response Fields
| Field | Type | Description |
|---|---|---|
| index_code | string | Index code |
| trade_date | string | Effective date |
| con_code | string | Constituent stock code |
| weight | number | Weight in index % |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/indices/index-weight?index_code=399300.SZ&limit=10"
Chip Distribution
Cost distribution and winner rates — unique A-share market microstructure data showing the percentage of shareholders in profit at various price levels.
GET /v1/chips/distribution
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 2000) |
| offset | int | No | Pagination offset |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| trade_date | string | Trading date |
| winner_rate | number | Winner rate (% of shareholders in profit) |
| weight_avg | number | Weighted average cost |
| cost_5pct | number | 5th percentile cost |
| cost_25pct | number | 25th percentile cost |
| cost_50pct | number | Median cost |
| cost_75pct | number | 75th percentile cost |
| cost_95pct | number | 95th percentile cost |
FX Rates
Daily foreign exchange rates with bid/ask prices. Default pair is USD/CNH — essential for cross-border portfolio valuation.
GET /v1/fx/daily
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Currency pair (default: USDCNH.FXCM) |
| start_date | string | No | Start date (YYYY-MM-DD) |
| end_date | string | No | End date (YYYY-MM-DD) |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Currency pair code |
| trade_date | string | Trading date |
| bid_open | number | Bid opening price |
| bid_close | number | Bid closing price |
| bid_high | number | Bid highest price |
| bid_low | number | Bid lowest price |
| ask_open | number | Ask opening price |
| ask_close | number | Ask closing price |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/fx/daily?start_date=2024-01-01&end_date=2024-01-31&limit=5"
Stock List
A-share stock list with basic reference info.
GET /v1/reference/stocks
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| symbol | string | Symbol |
| name | string | Stock name |
| area | string | Region |
| industry | string | Industry |
| fullname | string | Full company name |
| enname | string | English name |
| cnspell | string | Chinese pinyin abbreviation |
| market | string | Market |
| exchange | string | Exchange |
| curr_type | string | Currency type |
| list_status | string | L=listed, D=delisted, P=paused |
| list_date | string | Listing date |
| delist_date | string | Delisting date |
| is_hs | string | Stock Connect: H/S/N |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/reference/stocks?limit=10"
Industries
Shenwan 3-level industry classification (SW2021).
GET /v1/reference/industries
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ts_code | string | No | Stock code, e.g. 000001.SZ |
| limit | int | No | Max rows (default 100, max 5000) |
| offset | int | No | Pagination offset (default 0) |
Response Fields
| Field | Type | Description |
|---|---|---|
| ts_code | string | Stock code |
| name | string | Stock name |
| l1_code | string | L1 industry code |
| l1_name | string | L1 industry name (31 industries) |
| l2_code | string | L2 industry code |
| l2_name | string | L2 industry name |
| l3_code | string | L3 industry code |
| l3_name | string | L3 industry name |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/reference/industries?ts_code=000001.SZ"
Trade Calendar
Trading calendar for Shanghai (SSE) and Shenzhen (SZSE) exchanges. Useful for scheduling data pulls and handling holidays.
GET /v1/reference/trade-calendar
Parameters
exchange (SSE/SZSE), start_date, end_date, is_open (1=trading days, 0=closed), limit (max 5000), offset
Response Fields
| Field | Type | Description |
|---|---|---|
| exchange | string | Exchange code (SSE / SZSE) |
| cal_date | string | Calendar date |
| is_open | int | 1=trading day, 0=closed |
| pretrade_date | string | Previous trading date |
curl -H "X-API-Key: YOUR_KEY" \
"https://asharehub.com/v1/reference/trade-calendar?exchange=SSE&is_open=1&start_date=2024-01-01&limit=20"
Python SDK
The official Python SDK wraps all API endpoints and returns pandas DataFrames.
Installation
pip install asharehub
Requires Python 3.8+. Dependencies: httpx, pydantic.
SDK Usage Examples
Initialize the client:
from asharehub import AShareHub
client = AShareHub(api_key="ash_your_key_here")
Fetch daily prices:
df = client.market_daily(ts_code="000001.SZ", start_date="2024-01-01", end_date="2024-03-31")
print(df.head())
Fetch northbound capital flows:
flows = client.northbound_flows(start_date="2024-01-01", end_date="2024-01-31")
print(flows[["trade_date", "north_money"]].head())
Fetch financial indicators:
fina = client.financial_indicators(ts_code="000001.SZ")
print(fina[["end_date", "roe", "grossprofit_margin", "eps"]].head())
All available methods:
| Method | Endpoint | Description |
|---|---|---|
| market_daily() | /v1/market/daily | Daily OHLCV prices |
| fundamentals() | /v1/market/fundamentals | PE, PB, turnover, market cap |
| northbound_flows() | /v1/flows/northbound | Stock Connect capital flows |
| chip_distribution() | /v1/chips/distribution | Cost distribution & winner rates |
| fx_daily() | /v1/fx/daily | FX rates (default USD/CNH) |
| index_daily() | /v1/indices/daily | Index OHLCV data |
| financial_indicators() | /v1/financials/indicators | Quarterly financial metrics |