A Python application to test and interact with the Twelve Data (12data) API.
- Twelve Data API: Retrieve time series data, real-time prices, and forex quotes
- Easy-to-use class for API interactions
- Support for multiple symbols and intervals
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp .env.example .env
Then edit
.envand add your Twelve Data API key:TWELVE_DATA_API_KEY=your_actual_api_key_hereGet your free API key from: https://twelvedata.com/
python app.pyfrom app import TwelveDataTester
import os
# Twelve Data
td = TwelveDataTester(api_key=os.getenv("TWELVE_DATA_API_KEY"))
price_data = td.get_real_time_price("AAPL")
print(price_data)
# Forex quote
forex = td.get_forex_quote("EUR", "USD")
print(forex)
# Time series data
ts_data = td.get_time_series("AAPL", interval="1day", outputsize=10)
print(ts_data)- Official API client
- Requires API key (free tier available)
- Supports time series data, real-time prices, and forex quotes
- Multiple intervals: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 1day, 1week, 1month
- Python 3.7+
- twelvedata
- python-dotenv
- requests
- Be aware of rate limits for Twelve Data API
- Always verify data accuracy before making trading decisions