TradeLens provides a set of API endpoints that allow you to interact with the application programmatically. This document outlines all available endpoints, their parameters, and response formats.
All API endpoints are relative to the base URL of your TradeLens instance:
http://localhost:5000
Currently, the API does not require authentication as it's designed for local use. If deploying in a production environment, consider implementing proper authentication mechanisms.
Retrieves historical stock data for charting.
Parameters:
symbol(path parameter): Stock symbol (e.g., AAPL)start_date(query parameter, optional): Start date in YYYY-MM-DD formatend_date(query parameter, optional): End date in YYYY-MM-DD format
Response:
{
"dates": ["2023-01-01", "2023-01-02", ...],
"prices": [150.23, 152.45, ...],
"volumes": [28000000, 30000000, ...],
"transactions": [
{
"date": "2023-01-15",
"price": 155.50,
"qty": 10,
"side": "Buy"
},
...
]
}Sends a message to the AI assistant for analysis.
Request Body:
{
"message": "Analyze the risk in my portfolio",
"current_stock": "AAPL",
"perplexity_model": "sonar-deep-research"
}Response:
{
"response": "Based on your portfolio...",
"model_used": "sonar-deep-research"
}Analyzes tariff risks for stocks in the portfolio.
Parameters:
symbol(query parameter, optional): Stock symbol to analyze
Response:
{
"analysis": [
{
"symbol": "AAPL",
"risk_level": "Medium",
"risk_factors": ["Supply chain exposure to China", ...],
"recommendations": ["Consider hedging with...", ...]
},
...
]
}Retrieves the status and results of a thesis validation job.
Parameters:
job_id(path parameter): The ID of the thesis validation job
Response:
{
"job_id": "12345",
"thesis": "AI stocks will outperform in Q3 2025",
"status": "completed",
"result": {
"analysis": "Based on recent trends...",
"validation": "Partially supported",
"supporting_evidence": ["Recent AI chip demand", ...],
"counter_evidence": ["Regulatory concerns", ...]
}
}Retrieves the status and results of an earnings research job.
Parameters:
job_id(path parameter): The ID of the earnings research job
Response:
{
"job_id": "67890",
"symbol": "MSFT",
"earnings_date": "2023-10-25",
"status": "completed",
"result": {
"analysis": "Microsoft is expected to report...",
"key_metrics": ["Cloud revenue growth", ...],
"sentiment": "Positive",
"risks": ["Competition from AWS", ...]
}
}Triggers an update of the earnings calendar.
Response:
{
"status": "success",
"message": "Earnings calendar update initiated",
"job_id": "update-12345"
}Triggers an update of the market events calendar.
Response:
{
"status": "success",
"message": "Market events update initiated",
"job_id": "events-67890"
}Retrieves the logo for a company.
Parameters:
symbol(path parameter): Stock symbol
Response: Binary image data with the appropriate content type.
Checks the health of the OpenAI/Perplexity API connection.
Response:
{
"status": "healthy",
"provider": "perplexity",
"model": "sonar"
}All API endpoints return standard HTTP status codes:
- 200: Success
- 400: Bad request (missing or invalid parameters)
- 404: Resource not found
- 500: Server error
Error responses include a JSON body with additional information:
{
"error": "Invalid stock symbol",
"code": "INVALID_SYMBOL",
"status": 400
}The API does not currently implement rate limiting, but be mindful of the underlying service limits, especially for API calls to Perplexity or other external services.