Stock Information
Stock Information API
Get basic stock information including company name, industry, market, and financial ratios.
Endpoint
| Method | Endpoint |
|---|---|
| GET | /ticker_info |
Try It
GET
/ticker_infoRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | ✅ | Stock code (e.g., 000001.SZ, 002415.SZ) |
Code Examples
Python
import requests
API_KEY = "your_api_key"
response = requests.get(
"https://tickerlab.org/ticker_info",
params={"symbol": "000001.SZ"},
headers={"X-API-Key": API_KEY}
)
info = response.json()
print(f"Name: {info.get('name')}")
print(f"Industry: {info.get('industry')}")
print(f"Market: {info.get('market')}")
JavaScript
const response = await fetch(
'https://tickerlab.org/ticker_info?symbol=000001.SZ',
{ headers: { 'X-API-Key': 'your_api_key' } }
);
const info = await response.json();
console.log(`${info.name} - ${info.industry}`);
cURL
curl "https://tickerlab.org/ticker_info?symbol=000001.SZ" \
-H "X-API-Key: your_api_key"
Response Example
{
"code": "000001",
"name": "Ping An Bank",
"market": "SZ",
"industry": "Banking",
"list_date": "1991-04-03",
"total_share": 19405918198,
"float_share": 19380084397,
"pe_ratio": 5.23,
"pb_ratio": 0.58
}
Field Descriptions
| Field | Description |
|---|---|
code | Stock code (6 digits) |
name | Stock name |
market | Market (SZ/SH) |
industry | Industry sector |
list_date | IPO date |
total_share | Total shares |
float_share | Float shares |
pe_ratio | P/E ratio |
pb_ratio | P/B ratio |
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 get_info(self, symbol):
"""Get basic stock information."""
r = requests.get(
f"{self.base_url}/ticker_info",
params={"symbol": symbol},
headers=self.headers
)
return r.json()
def get_kline(self, symbol, days=60):
"""Get K-line data."""
r = requests.get(
f"{self.base_url}/v1/indicators/time_series",
params={"symbol": symbol, "outputsize": days},
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, symbol):
"""Comprehensive analysis."""
info = self.get_info(symbol)
kline = self.get_kline(symbol)
indicators = self.get_indicators(symbol)
print(f"=== {info['name']} ({symbol}) ===")
print(f"Industry: {info.get('industry', 'N/A')}")
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 {"info": info, "kline": kline, "indicators": indicators}
# Usage
analyzer = StockAnalyzer("your_api_key")
result = analyzer.analyze("000001.SZ")