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.

Base URL: https://asharehub.com Version: v1 Format: JSON
Interactive API → You can also explore and test endpoints via Swagger UI or ReDoc.

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
curl -H "X-API-Key: ash_your_key_here" \
  "https://asharehub.com/v1/market/daily?ts_code=000001.SZ&limit=5"
Python SDK
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
⚠️ Keep your API key secret. Do not expose it in client-side code or public repositories.

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$0100
Pro$49/mo10,000
Business$99/mo50,000
Market Data

Market Daily

Daily OHLCV price data for A-share stocks.

GET /v1/market/daily

Parameters

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
trade_datestringTrading date
opennumberOpening price
highnumberHighest price
lownumberLowest price
closenumberClosing price
pre_closenumberPrevious close
changenumberPrice change
pct_chgnumberChange %
volnumberVolume (lots)
amountnumberTurnover (CNY thousands)
Example
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

FieldDescription
pe / pe_ttmPrice-to-Earnings ratio (static / trailing 12m)
pbPrice-to-Book ratio
ps / ps_ttmPrice-to-Sales ratio
turnover_rate / turnover_rate_fTurnover rate (total / free float)
total_mv / circ_mvTotal / circulating market cap (CNY 10k)
volume_ratioVolume ratio

Margin Trading

Daily margin trading and short selling data per stock.

GET /v1/market/margin

Parameters

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
trade_datestringTrading date
ts_codestringStock code
namestringStock name
rzyenumberMargin buy balance (CNY)
rqyenumberShort sell balance (CNY)
rzmrenumberMargin buy amount today
rqylnumberShort sell volume today
rzchenumberMargin repayment today
rqchlnumberShort cover volume today
rqmclnumberShort sell volume today
rzrqyenumberTotal margin + short balance
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
trade_datestringTrading date
pricenumberTrade price (CNY)
volnumberVolume (10k shares)
amountnumberAmount (10k CNY)
buyerstringBuyer broker
sellerstringSeller broker
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
trade_datestringTrading date
ts_codestringStock code
namestringStock name
closenumberClosing price
pct_changenumberPrice change %
turnover_ratenumberTurnover rate %
amountnumberTotal turnover (CNY)
l_sellnumberInstitutional sell (CNY)
l_buynumberInstitutional buy (CNY)
l_amountnumberInstitutional total (CNY)
Example
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"

Shareholders

Quarterly shareholder count. Declining count suggests chip concentration.

GET /v1/market/shareholders

Parameters

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
ann_datestringAnnouncement date
end_datestringReport period end
holder_numnumberNumber of shareholders
Example
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v1/market/shareholders?ts_code=000001.SZ&limit=5"

Holder Trade

Major shareholder and executive trades.

GET /v1/market/holder-trade

Parameters

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
ann_datestringAnnouncement date
holder_namestringHolder name
holder_typestringG=executive, P=individual, C=company
in_destringIN=buy, DE=sell
change_volnumberChange volume
change_rationumberChange ratio
after_sharenumberShares after trade
after_rationumberRatio after trade
avg_pricenumberAverage price
total_sharenumberTotal shares
begin_datestringTrade begin date
close_datestringTrade close date
Example
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

NameTypeRequiredDescription
ts_codestringNoConcept code, e.g. BK0425.DC
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringConcept code (e.g. BK0425.DC)
trade_datestringTrading date
namestringConcept name
leadingstringLeading stock name
leading_codestringLeading stock code
pct_changenumberDaily return %
leading_pctnumberLeading stock return %
total_mvnumberTotal market value (10k CNY)
turnover_ratenumberTurnover rate
up_numnumberNumber of stocks up
down_numnumberNumber of stocks down
idx_typestringIndex type
levelstringLevel
Example
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

NameTypeRequiredDescription
ts_codestringNoConcept index code
con_codestringNoConstituent stock code
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
trade_datestringTrading date
ts_codestringConcept index code
con_codestringConstituent stock code
namestringStock name
Example
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

FieldTypeDescription
ts_codestringStock code
trade_datestringTrading date
adj_factornumberAdjustment factor
Example
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

FieldDescription
close_qfq / close_hfqForward / backward adjusted close price
macd_dif, macd_dea, macdMACD indicator (DIF, DEA, histogram)
kdj_k, kdj_d, kdj_jKDJ oscillator
rsi_6, rsi_12, rsi_24RSI (6/12/24 period)
boll_upper, boll_mid, boll_lowerBollinger Bands
cciCommodity Channel Index
Example
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

FieldDescription
ts_code / nameStock code and name
close / pct_chgClosing price and change %
first_time / last_timeFirst/last limit hit time
open_timesTimes limit was broken
limit_timesConsecutive limit days
limitType: U=up, D=down, Z=broken
Example
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v1/market/limit-list?limit_type=U&start_date=2024-03-01&limit=10"
Capital Flows

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

NameTypeRequiredDescription
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 1000)
offsetintNoPagination offset

Response Fields

FieldTypeDescription
trade_datestringTrading date
north_moneynumberTotal northbound net buy (CNY million)
south_moneynumberTotal southbound net buy (CNY million)
ggt_ssnumberShanghai Connect northbound (CNY million)
ggt_sznumberShenzhen Connect northbound (CNY million)
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Key Response Fields

FieldTypeDescription
ts_codestringStock code
trade_datestringTrading date
buy_sm_vol / buy_sm_amountnumberSmall order buy (<50K)
sell_sm_vol / sell_sm_amountnumberSmall order sell
buy_md_vol / buy_md_amountnumberMedium order buy (50K–200K)
sell_md_vol / sell_md_amountnumberMedium order sell
buy_lg_vol / buy_lg_amountnumberLarge order buy (200K–1M)
sell_lg_vol / sell_lg_amountnumberLarge order sell
buy_elg_vol / buy_elg_amountnumberExtra-large order buy (>=1M)
sell_elg_vol / sell_elg_amountnumberExtra-large order sell
net_mf_volnumberNet money flow volume
net_mf_amountnumberNet money flow (10k CNY)
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
trade_datestringTrading date
ts_codestringStock code
namestringStock name
volnumberShares held
rationumber% of total shares
exchangestringExchange (SH/SZ)
Example
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"
Financials

Financial Indicators

Quarterly financial indicators including ROE, margins, EPS, and 50+ metrics per company.

GET /v1/financials/indicators

Parameters

NameTypeRequiredDescription
ts_codestringYesStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 1000)

Key Response Fields

FieldTypeDescription
ts_codestringStock code
end_datestringReporting period end date
ann_datestringAnnouncement date
roenumberReturn on equity (%)
epsnumberEarnings per share (CNY)
grossprofit_marginnumberGross profit margin (%)
netprofit_marginnumberNet profit margin (%)
current_rationumberCurrent ratio
debt_to_assetsnumberDebt-to-asset ratio (%)
Example
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

FieldDescription
revenue / total_revenueOperating / total revenue
operate_profit / total_profitOperating / pre-tax profit
n_income / n_income_attr_pNet income / attributable to parent
basic_eps / diluted_epsEarnings per share
sell_exp / admin_exp / fin_exp / rd_expOperating expenses breakdown
ebit / ebitdaEBIT / EBITDA
Example
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

FieldDescription
total_assetsTotal assets
total_liabTotal liabilities
total_hldr_eqy_exc_min_intEquity attributable to parent
money_capCash and equivalents
accounts_receiv / inventoriesReceivables / inventory
goodwill / intan_assetsGoodwill / intangible assets
Example
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

FieldDescription
n_cashflow_actNet operating cash flow
n_cashflow_inv_actNet investing cash flow
n_cash_flows_fnc_actNet financing cash flow
free_cashflowFree cash flow
c_cash_equ_end_periodCash at period end
Example
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

FieldDescription
typeForecast type (预增/预减/扭亏/首亏/续亏/略增/略减)
p_change_min / p_change_maxNet profit change range %
net_profit_min / net_profit_maxForecast net profit range (10k CNY)
summary / change_reasonSummary and reason for change
Example
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

FieldDescription
revenue / n_incomeRevenue / net income (CNY)
diluted_eps / diluted_roeDiluted EPS and ROE
yoy_net_profitNet profit YoY growth %
perf_summaryPerformance summary
Example
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v1/financials/express?ts_code=000001.SZ&limit=5"
Shareholders

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

FieldDescription
cash_divCash dividend per share pre-tax (CNY)
stk_divTotal stock dividend per share
ex_dateEx-dividend date
record_date / pay_dateRecord date / payment date
div_procProgress (预案/实施)
Example
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v1/shareholders/dividend?ts_code=600519.SH&limit=10"
Indices

Index Daily

Daily OHLCV data for major Chinese market indices.

GET /v1/indices/daily

Parameters

NameTypeRequiredDescription
ts_codestringNoIndex code (default: 000001.SH — SSE Composite)
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)

Common Index Codes

CodeName
000001.SHSSE Composite (上证综指)
000300.SHCSI 300 (沪深300)
399001.SZSZSE Component (深证成指)
399006.SZChiNext (创业板指)
000016.SHSSE 50 (上证50)
Example
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

FieldTypeDescription
index_codestringIndex code
trade_datestringEffective date
con_codestringConstituent stock code
weightnumberWeight in index %
Example
curl -H "X-API-Key: YOUR_KEY" \
  "https://asharehub.com/v1/indices/index-weight?index_code=399300.SZ&limit=10"
Microstructure

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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 2000)
offsetintNoPagination offset

Response Fields

FieldTypeDescription
ts_codestringStock code
trade_datestringTrading date
winner_ratenumberWinner rate (% of shareholders in profit)
weight_avgnumberWeighted average cost
cost_5pctnumber5th percentile cost
cost_25pctnumber25th percentile cost
cost_50pctnumberMedian cost
cost_75pctnumber75th percentile cost
cost_95pctnumber95th percentile cost
Reference Data

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

NameTypeRequiredDescription
ts_codestringNoCurrency pair (default: USDCNH.FXCM)
start_datestringNoStart date (YYYY-MM-DD)
end_datestringNoEnd date (YYYY-MM-DD)
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset

Response Fields

FieldTypeDescription
ts_codestringCurrency pair code
trade_datestringTrading date
bid_opennumberBid opening price
bid_closenumberBid closing price
bid_highnumberBid highest price
bid_lownumberBid lowest price
ask_opennumberAsk opening price
ask_closenumberAsk closing price
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
symbolstringSymbol
namestringStock name
areastringRegion
industrystringIndustry
fullnamestringFull company name
ennamestringEnglish name
cnspellstringChinese pinyin abbreviation
marketstringMarket
exchangestringExchange
curr_typestringCurrency type
list_statusstringL=listed, D=delisted, P=paused
list_datestringListing date
delist_datestringDelisting date
is_hsstringStock Connect: H/S/N
Example
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

NameTypeRequiredDescription
ts_codestringNoStock code, e.g. 000001.SZ
limitintNoMax rows (default 100, max 5000)
offsetintNoPagination offset (default 0)

Response Fields

FieldTypeDescription
ts_codestringStock code
namestringStock name
l1_codestringL1 industry code
l1_namestringL1 industry name (31 industries)
l2_codestringL2 industry code
l2_namestringL2 industry name
l3_codestringL3 industry code
l3_namestringL3 industry name
Example
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

FieldTypeDescription
exchangestringExchange code (SSE / SZSE)
cal_datestringCalendar date
is_openint1=trading day, 0=closed
pretrade_datestringPrevious trading date
Example
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

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:

MethodEndpointDescription
market_daily()/v1/market/dailyDaily OHLCV prices
fundamentals()/v1/market/fundamentalsPE, PB, turnover, market cap
northbound_flows()/v1/flows/northboundStock Connect capital flows
chip_distribution()/v1/chips/distributionCost distribution & winner rates
fx_daily()/v1/fx/dailyFX rates (default USD/CNH)
index_daily()/v1/indices/dailyIndex OHLCV data
financial_indicators()/v1/financials/indicatorsQuarterly financial metrics