Analyst Ratings
Get analyst institution ratings and consensus data for a security.
SDK Links
Parameters
SDK method parameters.
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | YES | Security symbol, e.g. AAPL.US |
Request Example
python
from longbridge.openapi import FundamentalContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = FundamentalContext(config)
resp = ctx.ratings("AAPL.US")
print(resp)python
import asyncio
from longbridge.openapi import AsyncFundamentalContext, Config, OAuthBuilder
async def main() -> None:
oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = AsyncFundamentalContext.create(config)
resp = await ctx.ratings("AAPL.US")
print(resp)
if __name__ == "__main__":
asyncio.run(main())javascript
const { Config, FundamentalContext, OAuth } = require('longbridge')
async function main() {
const oauth = await OAuth.build('your-client-id', (_, url) => {
console.log('Open this URL to authorize: ' + url)
})
const config = Config.fromOAuth(oauth)
const ctx = FundamentalContext.new(config)
const resp = await ctx.ratings('AAPL.US')
console.log(resp)
}
main().catch(console.error)java
import com.longbridge.*;
import com.longbridge.fundamental.*;
class Main {
public static void main(String[] args) throws Exception {
try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
Config config = Config.fromOAuth(oauth);
FundamentalContext ctx = FundamentalContext.create(config)) {
var resp = ctx.getRatings("AAPL.US").get();
System.out.println(resp);
}
}
}rust
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
let config = Arc::new(Config::from_oauth(oauth));
let ctx = FundamentalContext::new(config);
let resp = ctx.ratings("AAPL.US").await?;
println!("{:?}", resp);
Ok(())
}cpp
#include <iostream>
#include <longbridge.hpp>
using namespace longbridge;
using namespace longbridge::fundamental;
int main() {
OAuthBuilder("your-client-id").build(
[](const std::string& url) { std::cout << "Open: " << url << std::endl; },
[](auto res) {
if (!res) return;
Config config = Config::from_oauth(*res);
FundamentalContext ctx = FundamentalContext::create(config);
ctx.ratings("AAPL.US", [](auto resp) {
if (resp) std::cout << "OK" << std::endl;
});
});
std::cin.get();
}go
package main
import (
"context"
"fmt"
"log"
"github.com/longbridge/openapi-go/config"
"github.com/longbridge/openapi-go/oauth"
"github.com/longbridge/openapi-go/fundamental"
)
func main() {
o := oauth.New("your-client-id").
OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
if err := o.Build(context.Background()); err != nil {
log.Fatal(err)
}
conf, err := config.New(config.WithOAuthClient(o))
if err != nil {
log.Fatal(err)
}
c, err := fundamental.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer c.Close()
resp, err := c.Ratings(context.Background(), "AAPL.US")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}Response
Response Example
json
{
"code": 0,
"message": "success",
"data": {
"industry_name": "Technology Hardware, Storage and Peripherals",
"industry_rank": 2,
"multi_letter": "B",
"multi_score": "0.32",
"multi_score_change": -1,
"scale_txt_name": "Large",
"style_txt_name": "Blend",
"report_period_txt": "Rating based on Fiscal Year 2026 s.a.",
"ratings_json": "[]"
}
}Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | Success | StockRatingsResponse |
| 400 | Bad request | None |
Schemas
StockRatingsResponse
| Name | Type | Required | Description |
|---|---|---|---|
| industry_name | string | false | Industry name |
| industry_rank | integer | false | Rank within industry |
| multi_letter | string | false | Rating letter grade |
| multi_score | string | false | Composite score |
| multi_score_change | integer | false | Score change vs previous period |
| report_period_txt | string | false | Report period description |
| scale_txt_name | string | false | Rating scale name |
| style_txt_name | string | false | Rating style name |
| ratings_json | string | false | Raw rating detail JSON |