npx skills add https://github.com/adaptationio/skrillz --skill twelvedata-apiSKILL.md
Twelve Data API Integration
Comprehensive financial data API providing stocks, forex, crypto, ETFs, indices, and 100+ technical indicators with excellent Python SDK support.
Quick Start
Authentication
# Environment variable (recommended)
export TWELVEDATA_API_KEY="your_api_key"
# Or in .env file
TWELVEDATA_API_KEY=your_api_key
Basic Usage (Python)
import requests
import os
API_KEY = os.getenv("TWELVEDATA_API_KEY")
BASE_URL = "https://api.twelvedata.com"
def get_quote(symbol: str) -> dict:
"""Get real-time quote for a symbol."""
response = requests.get(
f"{BASE_URL}/quote",
params={"symbol": symbol, "apikey": API_KEY}
)
return response.json()
# Example
quote = get_quote("AAPL")
print(f"AAPL: ${quote['close']} ({quote['percent_change']}%)")
Using Official SDK
from twelvedata import TDClient
td = TDClient(apikey="your_api_key")
# Get time series
ts = td.time_series(
symbol="AAPL",
interval="1day",
outputsize=30
).as_pandas()
# Get quote
quote = td.quote(symbol="AAPL").as_json()
# Get with technical indicators
ts_with_indicators = td.time_series(
symbol="AAPL",
interval="1day",
outputsize=50
).with_sma(time_period=20).with_rsi().as_pandas()
API Endpoints Reference
Core Data
| Endpoint | Description | Credits |
|---|---|---|
/quote | Real-time quote | 1 |
/price | Current price only | 1 |
/eod | End of day price | 1 |
/time_series | Historical OHLCV | 1 |
/exchange_rate | Currency conversion | 1 |
Reference Data
| Endpoint | Description | Credits |
|---|---|---|
/symbol_search | Search symbols | 1 |
/instruments | List all instruments | Free |
/exchanges | List exchanges | Free |
/instrument_type | List types | Free |
/earliest_timestamp | Data start date | Free |
Fundamental Data
| Endpoint | Description | Credits |
|---|---|---|
/income_statement | Income statement | 100 |
/balance_sheet | Balance sheet | 100 |
/cash_flow | Cash flow | 100 |
/earnings | Earnings history | 100 |
/earnings_calendar | Upcoming earnings | 100 |
/dividends | Dividend history | 1 |
/splits | Split history | 1 |
/statistics | Key statistics | 100 |
/profile | Company profile | 100 |
Technical Indicators (100+)
All indicators cost 1 credit and are included with time_series:
Trend: SMA, EMA, WMA, DEMA, TEMA, KAMA, MAMA, T3, TRIMA, VWMA Momentum: RSI, MACD, Stochastic, Williams %R, ADX, CCI, MFI, ROC, AROON Volatility: Bollinger Bands, ATR, Keltner Channels, Donchian Volume: OBV, AD, ADOSC, VWAP
Rate Limits
| Tier | Calls/Min | Daily | WebSocket |
|---|---|---|---|
| Free | 8 | 800 | Trial only |
| Grow ($29) | 55-377 | Unlimited | ❌ |
| Pro ($99) | 610-1597 | Unlimited | ✅ |
| Enterprise ($329) | 2584+ | Unlimited | ✅ |
Credit System:
- Standard endpoints: 1 credit per symbol
- Fundamental data: 100 credits per symbol
- Batch requests: Same cost as individual
Common Tasks
Task: Get Time Series with Pandas
from twelvedata import TDClient
import pandas as pd
td = TDClient(apikey=API_KEY)
def get_historical_data(symbol: str, days: int = 100) -> pd.DataFrame:
"""Get historical OHLCV data as DataFrame."""
ts = td.time_series(
symbol=symbol,
interval="1day",
outputsize=days
)
return ts.as_pandas()
# Example
df = get_historical_data("AAPL", 100)
print(df.head())
Task: Technical Analysis with Multiple Indicators
def get_technical_analysis(symbol: str) -> pd.DataFrame:
"""Get price data with technical indicators."""
ts = td.time_series(
symbol=symbol,
interval="1day",
outputsize=100
)
# Chain indicators
df = (ts
.with_sma(time_period=20)
.with_sma(time_period=50)
.with_rsi(time_period=14)
.with_macd()
.with_bbands()
.as_pandas()
)
return df
# Example
analysis = get_technical_analysis("AAPL")
Task: Get Multiple Symbols (Batch)
def get_batch_quotes(symbols: list) -> dict:
"""Get quotes for multiple symbols efficiently."""
symbol_str = ",".join(symbols)
response = requests.get(
f"{BASE_URL}/quote",
params={
"symbol": symbol_str,
"apikey": API_KEY
}
)
return response.json()
# Example: Up to 120 symbols per request
quotes = get_batch_quotes(["AAPL", "MSFT", "GOOGL", "AMZN"])
Task: Get Fundamental Data
def get_fundamentals(symbol: str) -> dict:
"""Get comprehensive fundamental data."""
# Note: Each call costs 100 credits
profile = requests.get(
f"{BASE_URL}/profile",
params={"symbol": symbol, "apikey": API_KEY}
).json()
stats = requests.get(
f"{BASE_URL}/statistics",
p
...
Repository
adaptationio/skrillzParent repository
Repository Stats
Stars1
Forks0