Analyst Ratings API
Retrieve Wall Street analyst ratings, price targets, and recommendation changes. Get consensus ratings and track upgrades/downgrades.
Endpoint
Section titled “Endpoint”GET /v1/analystratings/{market}/{ticker}Authentication
Section titled “Authentication”Requires API key via token query parameter.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
market | string | Yes | Market identifier (e.g., S&P 500, NASDAQ) |
ticker | string | Yes | Stock ticker symbol (e.g., AAPL, MSFT) |
Query Parameters
Section titled “Query Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Your API key |
dateFrom | string | No | Start date (YYYY-MM-DD) |
dateTo | string | No | End date (YYYY-MM-DD) |
Request
Section titled “Request”curl "https://api.finbrain.tech/v1/analystratings/S%26P%20500/AAPL?token=YOUR_API_KEY"from finbrain import FinBrainClient
fb = FinBrainClient(api_key="YOUR_API_KEY")
# Get as DataFrame (recommended)df = fb.analyst_ratings.ticker("S&P 500", "AAPL", as_dataframe=True)print(df.head())# institution type signal targetPrice# date# 2024-02-02 Piper Sandler Reiterated Neutral $205 → $190
# Get raw JSON responseratings = fb.analyst_ratings.ticker("S&P 500", "AAPL")print(ratings)#include <iostream>#include <string>#include <curl/curl.h>#include <nlohmann/json.hpp>
using json = nlohmann::json;
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp) { userp->append((char*)contents, size * nmemb); return size * nmemb;}
json get_analyst_ratings(const std::string& market, const std::string& ticker, const std::string& api_key) { CURL* curl = curl_easy_init(); std::string response;
if (curl) { char* encoded_market = curl_easy_escape(curl, market.c_str(), 0); std::string url = "https://api.finbrain.tech/v1/analystratings/" + std::string(encoded_market) + "/" + ticker + "?token=" + api_key; curl_free(encoded_market);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_perform(curl); curl_easy_cleanup(curl); }
return json::parse(response);}
int main() { auto data = get_analyst_ratings("S&P 500", "AMZN", "YOUR_API_KEY");
for (auto& r : data["analystRatings"]) { std::cout << r["date"].get<std::string>() << " - " << r["institution"].get<std::string>() << ": " << r["signal"].get<std::string>() << " (Target: " << r["targetPrice"].get<std::string>() << ")" << std::endl; }
return 0;}use reqwest::blocking::Client;use serde::Deserialize;use std::error::Error;
#[derive(Debug, Deserialize)]struct AnalystRating { date: String, #[serde(rename = "type")] rating_type: String, institution: String, signal: String, #[serde(rename = "targetPrice")] target_price: String,}
#[derive(Debug, Deserialize)]struct AnalystRatingsResponse { ticker: String, name: String, #[serde(rename = "analystRatings")] analyst_ratings: Vec<AnalystRating>,}
fn get_analyst_ratings(market: &str, ticker: &str, api_key: &str) -> Result<AnalystRatingsResponse, Box<dyn Error>> { let url = format!( "https://api.finbrain.tech/v1/analystratings/{}/{}?token={}", urlencoding::encode(market), ticker, api_key );
let client = Client::new(); let response: AnalystRatingsResponse = client.get(&url).send()?.json()?;
Ok(response)}
fn main() -> Result<(), Box<dyn Error>> { let data = get_analyst_ratings("S&P 500", "AMZN", "YOUR_API_KEY")?;
for r in &data.analyst_ratings { println!("{} - {}: {} (Target: {})", r.date, r.institution, r.signal, r.target_price); }
Ok(())}const market = encodeURIComponent("S&P 500");const response = await fetch( `https://api.finbrain.tech/v1/analystratings/${market}/AAPL?token=YOUR_API_KEY`);const data = await response.json();Response
Section titled “Response”Success Response (200 OK)
Section titled “Success Response (200 OK)”{ "ticker": "AMZN", "name": "Amazon.com Inc.", "analystRatings": [ { "date": "2024-02-02", "type": "Reiterated", "institution": "Piper Sandler", "signal": "Neutral", "targetPrice": "$205 → $190" }, { "date": "2024-02-02", "type": "Reiterated", "institution": "Monness Crespi & Hardt", "signal": "Buy", "targetPrice": "$189 → $200" } ]}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
ticker | string | Stock ticker symbol |
name | string | Company name |
analystRatings | array | Array of analyst ratings |
Rating Object Fields
Section titled “Rating Object Fields”| Field | Type | Description |
|---|---|---|
date | string | Rating date (YYYY-MM-DD) |
type | string | Type of action (Upgrade, Downgrade, Reiterated, Initiated) |
institution | string | Research firm name |
signal | string | Rating signal (Buy, Sell, Hold, Neutral, etc.) |
targetPrice | string | Price target change (e.g., “$205 → $190”) |
Rating Categories
Section titled “Rating Categories”| Rating | Signal |
|---|---|
| Strong Buy | Very Bullish |
| Buy / Outperform | Bullish |
| Hold / Neutral | Neutral |
| Underperform | Bearish |
| Sell | Very Bearish |
Errors
Section titled “Errors”| Code | Error | Description |
|---|---|---|
| 400 | Bad Request | Invalid market or ticker |
| 401 | Unauthorized | Invalid or missing API key |
| 404 | Not Found | Ticker not found |
| 500 | Internal Server Error | Server-side error |
Related
Section titled “Related”- Analyst Ratings Dataset - Use cases and analysis examples
- Sentiments - News sentiment data
- Ticker Predictions - AI predictions