gStockly API Documentation
Multi-source stock quote aggregation
Introduction
GStockly is a comprehensive RESTful API for stock market data aggregation, providing real-time quotes, historical data, and AI-powered technical analysis from multiple sources.
Key Features
✓ Multi-source quote providers (Yahoo Finance, Investing.com, TradingView)
✓ Real-time and historical data retrieval
✓ AI-powered ticker analysis (Claude + DeepSeek)
✓ Advanced caching with Redis
✓ Rate limiting and authentication
✓ Comprehensive logging and monitoring
API Architecture Overview
The API is built with PHP using a modular architecture with separate concerns for authentication, caching, database operations, and external service integrations. All endpoints return standardized JSON responses with proper HTTP status codes.
Authentication
All protected endpoints require API key authentication.
API Key Authentication
Send your API key using one of these methods:
user_id - Your user IDplan_name - Current subscription planmax_requests_per_day - Daily limitrequests_today - Requests used todaySystem Architecture
Core Components
| Component | Purpose | Technology |
|---|---|---|
| Database | Persistent data storage | MySQL/MariaDB |
| Cache Layer | In-memory caching for performance | Redis |
| Authentication | API key validation & rate limits | Custom Auth class |
| Logger | Request/error logging | File-based logging |
| Quote Providers | External data sources | Multiple APIs + Web Scraping |
| AI Services | Advanced analysis | Claude API + DeepSeek API |
Public Endpoints
No authentication required for these endpoints.
Health Check
Check API health status including database and cache connectivity.
API Status
Get API and database statistics.
Countries Statistics
Get statistics of tickers grouped by country.
Quote Endpoints
Retrieve stock quotes from multiple data sources.
Daily Quotes
Get the latest daily quote for a ticker.
ticker (required) - Stock symbol (AAPL, MSFT, ^GSPC)provider (optional) - Quote source: yahoo_finance, investing, tradingviewformat (optional) - Response format: json (default) or csvReal-time Quotes
Get real-time quote with automatic provider fallback.
ticker (required) - Stock symbolprovider (optional) - Preferred provider (auto-fallback if not specified)use_fallback (optional) - Enable automatic fallback (default: true)Historical Quotes
Retrieve historical quotes within a date range.
ticker (required) - Stock symbolfromdate (required) - Start date (YYYY-MM-DD)todate (required) - End date (YYYY-MM-DD)provider (optional) - Data source (default: yahoo_finance)format (optional) - json or csvAvailable Providers
List all available quote providers.
Ticker Endpoints
Manage and search stock information.
List All Tickers
Get paginated list of tickers with optional filtering.
sector (optional) - Filter by sectorlimit (optional) - Results per page (max 500)page (optional) - Page number (default: 1)enabled (optional) - Filter by status (default: 1)Search Tickers
Search tickers by symbol or name.
q (required) - Search query (min 2 characters)limit (optional) - Max results (default: 20, max: 100)Ticker Details
Get detailed information about a specific ticker.
AI Analysis Endpoints
AI-powered stock analysis powered by Claude and DeepSeek.
Claude Ticker Analysis
Get AI analysis for a ticker with custom request.
ticker (required) - Stock symbolrequest (required) - Analysis request (min 10 chars)Trading System Creation
Generate a custom trading system with entry/exit rules.
request (required) - System description (min 20 chars)user_req_id (optional) - Request identifierDeepSeek Analysis
Alternative AI analysis powered by DeepSeek.
Technical Architecture
Database Schema
The system uses MySQL/MariaDB with optimized tables for quotes, tickers, and analysis results.
| Table | Purpose | Key Fields |
|---|---|---|
| tickers | Stock information | ticker, name, sector, exchange, country |
| quotes_d | Daily quotes | ticker, date, open, high, low, close, volume |
| quotes_w | Weekly quotes | ticker, date, open, high, low, close, volume |
| quotes_m | Monthly quotes | ticker, date, open, high, low, close, volume |
| ai_ticker_analysis | AI analysis results | ticker, analysis, created_on |
| ai_trading_system | Trading system specs | user_req, prompt, answer, created_on |
| subscriptions | User subscriptions | user_id, api_key, plan_name, max_requests_per_day |
| api_logs | Request logging | user_id, endpoint, status_code, response_time_ms |
Caching System
Redis is used for high-performance caching with configurable TTLs:
Quote Data - 5 minutes TTLTicker Details - 30 minutes TTLAPI Key - 1 hour TTLAI Analysis - 24 hours TTLRate Limits - 1 second TTLRate Limiting
The API implements two-tier rate limiting:
| Tier | Per Second | Per Day |
|---|---|---|
| Standard | 100 req/s | 5,000 req/day |
| Premium | 500 req/s | 50,000 req/day |
| Enterprise | Unlimited | Unlimited |
FAQ
How do I get an API key?
Contact the API administrator or visit the customer portal to generate API keys for your account.
What's the difference between the quote providers?
Yahoo Finance: Most comprehensive, high reliability | Investing.com: Commodity and CFD data | TradingView: Advanced charting integration
How often is quote data updated?
Daily data is updated after market close. Real-time quotes are cached for 5 seconds to balance latency and performance.
Can I use the API for automated trading?
Yes, the API is designed for automated applications. Ensure you comply with exchange regulations and risk management best practices.
What happens if I exceed rate limits?
The API returns 429 (Too Many Requests) with remaining requests info. Implement exponential backoff in your client.