Stock Information

Stock Information API

Get basic stock information including company name, industry, market, and financial ratios.

Endpoint

MethodEndpoint
GET/v1/stocks/info

Try It

GET/v1/stocks/info

Request Parameters

ParameterTypeRequiredDescription
pageint-Page number, starting at 1
page_sizeint-Records per page (1-1000)
keywordstring-Search by code, name, or type
exchangestring-Exchange filter (SSE/SZSE/BSE)
security_typestring-Security type filter

Code Examples

Python

import requests

API_KEY = "your_api_key"

response = requests.get(
    "https://tickerlab.org/v1/stocks/info",
    params={"page": 1, "page_size": 10, "keyword": "平安"},
    headers={"X-API-Key": API_KEY}
)

data = response.json()
print(f"Total matches: {data['total']}")
for stock in data['data'][:5]:
    print(f"{stock['symbol']}: {stock['short_name']}")

JavaScript

const response = await fetch(
  'https://tickerlab.org/v1/stocks/info?page=1&page_size=10&keyword=平安',
  { headers: { 'X-API-Key': 'your_api_key' } }
);

const data = await response.json();
console.log(`Total matches: ${data.total}`);
data.data.forEach(stock => {
  console.log(`${stock.symbol}: ${stock.short_name}`);
});

cURL

curl "https://tickerlab.org/v1/stocks/info?page=1&page_size=10&keyword=平安" \
  -H "X-API-Key: your_api_key"

Response Example

{
  "status": "ok",
  "count": 10,
  "total": 138,
  "page": 1,
  "page_size": 10,
  "data": [
    {
      "symbol": "sh.600000",
      "short_name": "浦发银行",
      "list_date": "1999-11-10",
      "security_type": "stock"
    }
  ]
}

Field Descriptions

FieldDescription
statusResponse status
countNumber of records in this page
totalTotal number of matching records
pageCurrent page number
page_sizeRecords per page
dataArray of stock information
symbolStock code
short_nameStock name
list_dateIPO date
security_typeSecurity type

Complete Example: Building a Stock Analysis Tool

Here’s a complete Python example showing how to combine multiple APIs:

import requests
import pandas as pd

class StockAnalyzer:
    def __init__(self, api_key, base_url="https://tickerlab.org"):
        self.api_key = api_key
        self.base_url = base_url
        self.headers = {"X-API-Key": api_key}
    
    def search_stocks(self, keyword):
        """Search for stocks by keyword."""
        r = requests.get(
            f"{self.base_url}/v1/stocks/info",
            params={"keyword": keyword, "page_size": 10},
            headers=self.headers
        )
        return r.json()
    
    def get_kline(self, symbol, start_date=None, end_date=None):
        """Get K-line data."""
        r = requests.get(
            f"{self.base_url}/v1/markets/history",
            params={"symbol": symbol, "start_date": start_date, "end_date": end_date},
            headers=self.headers
        )
        data = r.json()
        df = pd.DataFrame(data["values"])
        df["datetime"] = pd.to_datetime(df["datetime"])
        for col in ["open", "high", "low", "close"]:
            df[col] = df[col].astype(float)
        return df
    
    def get_indicators(self, symbol):
        """Get technical indicators."""
        indicators = {}
        
        # RSI
        r = requests.get(
            f"{self.base_url}/v1/indicators/rsi",
            params={"symbol": symbol},
            headers=self.headers
        )
        indicators["rsi"] = float(r.json()["values"][0]["rsi"])
        
        # MACD
        r = requests.get(
            f"{self.base_url}/v1/indicators/macd",
            params={"symbol": symbol},
            headers=self.headers
        )
        macd_data = r.json()["values"][0]
        indicators["macd"] = float(macd_data["macd"])
        indicators["macd_signal"] = float(macd_data["macd_signal"])
        
        return indicators
    
    def analyze(self, keyword, symbol, start_date=None, end_date=None):
        """Comprehensive analysis."""
        # Search for stocks
        search_results = self.search_stocks(keyword)
        print(f"Found {search_results['total']} stocks matching '{keyword}'")
        
        kline = self.get_kline(symbol, start_date, end_date)
        indicators = self.get_indicators(symbol)
        
        print(f"=== Analysis for {symbol} ===")
        print(f"Latest Price: {kline['close'].iloc[0]:.2f}")
        print(f"RSI: {indicators['rsi']:.2f}")
        print(f"MACD: {indicators['macd']:.4f}")
        
        # Simple signal detection
        if indicators["rsi"] > 70:
            print("⚠️ RSI Overbought")
        elif indicators["rsi"] < 30:
            print("📈 RSI Oversold")
        
        return {"search_results": search_results, "kline": kline, "indicators": indicators}

# Usage
analyzer = StockAnalyzer("your_api_key")
result = analyzer.analyze("平安", "sz.000001", start_date="2024-01-01", end_date="2024-12-31")