Real-time market data and technical analysis API service based on TradingView
- ✅ Real-time market data (K-line/Candlestick data)
- ✅ Multi-market support (Crypto, Stocks, Forex, Futures)
- ✅ Flexible timeframes (1 minute to monthly)
- ✅ Technical analysis indicators
- ✅ Market and indicator search
- ✅ Interactive Swagger documentation
- ✅ Unlimited indicators support
- ✅ Custom/Private indicators retrieval
- ✅ Chart drawings data
- ✅ Invitation-only indicators
- ✅ Backtesting mode
- ✅ Date range data retrieval
- Docker 20.10+ & Docker Compose 2.0+
- Or: Python 3.11+ and Node.js 18+
# 1. Clone the repository
git clone https://github.com/Mathieu2301/TradingView-API.git
cd TradingView-API/tradingview-api-python
# 2. Create .env file (optional, for advanced features)
cp .env.example .env
# Edit .env and add your SESSION and SIGNATURE
# 3. Start services
docker-compose up -d
# 4. Access services
# - Swagger Docs: http://localhost:6688/docs
# - Token Manager: http://localhost:6688/# Install Python dependencies
pip install -r requirements.txt
# Install Node.js dependencies
npm install
# Start Node.js service (Terminal 1)
npm run server
# Start Python service (Terminal 2)
python3 main.py- Full Documentation (Chinese Simplified)
- API Documentation (Swagger UI)
- Quick Start Guide
- Project Structure
GET /api/search?q={query}- Search marketsGET /api/market/{symbol}?timeframe={tf}&bars={n}- Get K-line dataGET /api/ta/{symbol}- Get technical analysis
GET /api/indicators?q={query}- Search indicatorsGET /api/indicators/{id}- Get indicator detailsGET /api/indicators/private- Get private indicators (requires auth)POST /api/indicators/values- Get indicator values (requires auth)
POST /api/token/verify- Verify tokenPOST /api/token/update- Update tokenGET /api/token/current- Get current token
┌─────────────────────────────────────┐
│ Python FastAPI (Port 6688) │
│ - Main API Service │
│ - Swagger Documentation │
└──────────────┬──────────────────────┘
│ HTTP
▼
┌─────────────────────────────────────┐
│ Node.js Express (Port 3000) │
│ - WebSocket Data Source │
│ - TradingView Connection │
└─────────────────────────────────────┘
tradingview-api-python/
├── main.py # FastAPI application entry
├── server.js # Node.js Express server
├── docker-compose.yml # Docker orchestration
├── requirements.txt # Python dependencies
├── package.json # Node.js dependencies
├── src/ # Source code
│ ├── api/ # API routes
│ ├── core/ # Core business logic
│ └── utils/ # Utilities
└── token_manager.html # Token management UI
- Login to TradingView
- Open Developer Tools (F12)
- Go to Application/Storage → Cookies
- Copy
sessionid→SESSION - Copy
sessionid_sign→SIGNATURE
Option 1: Environment Variables
# .env file
SESSION=your_sessionid
SIGNATURE=your_sessionid_signOption 2: Web Interface
Visit http://localhost:6688/ for token management UI.
import requests
# Search markets
response = requests.get("http://localhost:6688/api/search", params={"q": "BTCUSDT"})
data = response.json()
print(data)
# Get K-line data
response = requests.get(
"http://localhost:6688/api/market/BINANCE:BTCUSDT",
params={"timeframe": "D", "bars": 100}
)
kline_data = response.json()
print(f"Retrieved {len(kline_data['data']['periods'])} candles")# Search market
curl "http://localhost:6688/api/search?q=BTCUSDT"
# Get K-line data
curl "http://localhost:6688/api/market/BINANCE:BTCUSDT?timeframe=D&bars=100"- Never commit
.envfile to Git (already in.gitignore) - Don't hardcode tokens or secrets in code
- Don't expose real tokens in README, Issues, or PRs
- Use environment variables or secret management services
- Regularly rotate tokens and keys
See Security Documentation for more details.
Q: How to verify services are running?
docker-compose ps
curl http://localhost:6688/api/search?q=BTCUSDTQ: Token verification failed?
- Check
.envfile contains correctSESSIONandSIGNATURE - Verify token hasn't expired at
http://localhost:6688/ - Re-fetch token from browser
Q: Can't get private indicators?
- Ensure valid token is set in
.env - Verify token at
http://localhost:6688/ - Check Node.js service:
docker-compose logs tradingview-nodejs
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to Mathieu2301 for creating the original TradingView-API project
- Thanks to all contributors and the community
- GitHub Issues: Create an issue
- Telegram Group: Join us
- Swagger Docs: http://localhost:6688/docs
Made with ❤️ by the community