Stock API

Real-time stock data from Eastmoney

Cloudflare Pages

Getting Started

This API provides real-time stock data from Eastmoney. All endpoints return JSON responses.

Base URL

https://your-domain.pages.dev

Response Format

All responses include success field and either data or error.

API Endpoints

GET
/api/stock/price

Get current stock price

Parameters

NameTypeRequiredDescription
stock_codestring
Required
6-digit stock code (e.g., 600519)

Example Request

GET /api/stock/price?stock_code=600519

Example Response

{
  "success": true,
  "data": {
    "stockCode": "600519",
    "price": 1688.88
  }
}
GET
/api/stock/klines

Get K-line (candlestick) data

Parameters

NameTypeRequiredDescription
stock_codestring
Required
6-digit stock code
limitnumber
Optional
Number of data points (default: 120, max: 1000)

Example Request

GET /api/stock/klines?stock_code=600519&limit=30

Example Response

{
  "success": true,
  "data": [
    {
      "date": "2024-01-15",
      "open": 1680.00,
      "close": 1688.88,
      "high": 1695.00,
      "low": 1675.50,
      "volume": 12345678,
      "amount": 20876543210
    }
  ]
}
GET
/api/stock/ma20_breakout

Check MA20 breakout condition

Parameters

NameTypeRequiredDescription
stock_codestring
Required
6-digit stock code
min_daysnumber
Optional
Minimum breakout days (default: 3)
max_daysnumber
Optional
Maximum breakout days (default: 7)

Example Request

GET /api/stock/ma20_breakout?stock_code=600519

Example Response

{
  "success": true,
  "data": {
    "breakout": true,
    "breakoutDays": 5,
    "ma20": 1650.25,
    "currentPrice": 1688.88,
    "priorTrend": "sideways"
  }
}
GET
/api/stock/info

Get comprehensive stock information

Parameters

NameTypeRequiredDescription
stock_codestring
Required
6-digit stock code

Example Request

GET /api/stock/info?stock_code=600519

Example Response

{
  "success": true,
  "data": {
    "stockCode": "600519",
    "name": "贵州茅台",
    "price": 1688.88,
    "open": 1680.00,
    "high": 1695.00,
    "low": 1675.50,
    "prevClose": 1678.00,
    "volume": 12345678,
    "amount": 20876543210,
    "turnoverRate": 0.98
  }
}

Health Check

GET
/api/health- Check API status