getRatings API

The getRatings API provides analysts ratings on stocks (strong buy, moderate buy, hold, moderate sell or strong sell) based on a symbol.

All APIs

Contact Us to Get Access

Inputs

symbols required

A symbol or code that identifies a financial instrument. Multiple symbols separated by a comma may be used. For futures, notation such as <root_symbol*0> for the active contract or <root_symbol*1> for the first nearby is supported, as is <root_symbol^F> for all futures contracts for a given root symbol, as is <root_symbol^O> for all options contracts for a given underlying futures symbol.

Type
list (A comma or semi-colon delimited string.) 
Example
AAPL,GOOG 

fields optional

The fields requested.

Type
list (A comma or semi-colon delimited string.) 
Example
strongBuy,hold,strongSell 

Outputs

Name / Requirement
Description
Type
symbol
always returned
A symbol or code that identifies a financial instrument.
string
A sequence of characters. (example: GOOG)
name
always returned
The type of symbol used.
string
A sequence of characters. (example: GOOG)
averageRecommendation
always returned
The average of all ratings (Strong Buy = 1.0, Moderate Buy = 2.0, Hold = 3.0, Moderate Sell = 4.0, Strong Sell = 5.0).
array
A data structure that contains a group of elements.
strongBuy
as requested
The number of Strong Buy ratings.
array
A data structure that contains a group of elements.
moderateBuy
as requested
The number of Moderate Buy ratings.
array
A data structure that contains a group of elements.
hold
as requested
The number of Hold ratings.
array
A data structure that contains a group of elements.
moderateSell
as requested
The number of Moderate Sell ratings.
array
A data structure that contains a group of elements.
strongSell
as requested
The number of Strong Sell ratings.
array
A data structure that contains a group of elements.

Status Code Responses

200
OK
Success
400
Bad Request
The request was invalid, please see the message for more information.
500
Internal Server Error
Something is not working correctly, please contact support.


JSON

GET

GET https://ondemand.websol.barchart.com/getRatings.json?apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getRatings.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell

Response

{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "AAPL",
            "name": "Apple Inc",
            "averageRecommendation": {
                "current": "1.77",
                "one_month_ago": "1.72",
                "two_months_ago": "1.74",
                "three_months_ago": "1.74"
            },
            "strongBuy": {
                "current": "18",
                "one_month_ago": "18",
                "two_months_ago": "19",
                "three_months_ago": "19"
            },
            "hold": {
                "current": "5",
                "one_month_ago": "4",
                "two_months_ago": "5",
                "three_months_ago": "5"
            },
            "strongSell": {
                "current": "2",
                "one_month_ago": "2",
                "two_months_ago": "2",
                "three_months_ago": "2"
            }
        },
        {
            "symbol": "GOOG",
            "name": "Alphabet Class C",
            "averageRecommendation": {
                "current": "1",
                "one_month_ago": "1",
                "two_months_ago": "1.14",
                "three_months_ago": "1.25"
            },
            "strongBuy": {
                "current": "6",
                "one_month_ago": "6",
                "two_months_ago": "6",
                "three_months_ago": "6"
            },
            "hold": {
                "current": "0",
                "one_month_ago": "0",
                "two_months_ago": "0",
                "three_months_ago": "0"
            },
            "strongSell": {
                "current": "0",
                "one_month_ago": "0",
                "two_months_ago": "0",
                "three_months_ago": "0"
            }
        }
    ]
}

XML

GET

GET https://ondemand.websol.barchart.com/getRatings.xml?apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getRatings.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell

Response


<?xml version="1.0" encoding="utf-8"?>
 <getRatings>
  <status>
   <code>200</code>
   <message>Success.</message>
  </status>
  <item>
   <symbol>AAPL</symbol>
   <name>Apple Inc</name>
   <averageRecommendation>
    <current>1.77</current>
    <one_month_ago>1.72</one_month_ago>
    <two_months_ago>1.74</two_months_ago>
    <three_months_ago>1.74</three_months_ago>
   </averageRecommendation>
   <strongBuy>
    <current>18</current>
    <one_month_ago>18</one_month_ago>
    <two_months_ago>19</two_months_ago>
    <three_months_ago>19</three_months_ago>
   </strongBuy>
   <hold>
    <current>5</current>
    <one_month_ago>4</one_month_ago>
    <two_months_ago>5</two_months_ago>
    <three_months_ago>5</three_months_ago>
   </hold>
   <strongSell>
    <current>2</current>
    <one_month_ago>2</one_month_ago>
    <two_months_ago>2</two_months_ago>
    <three_months_ago>2</three_months_ago>
   </strongSell>
  </item>
  <item>
   <symbol>GOOG</symbol>
   <name>Alphabet Class C</name>
   <averageRecommendation>
    <current>1</current>
    <one_month_ago>1</one_month_ago>
    <two_months_ago>1.14</two_months_ago>
    <three_months_ago>1.25</three_months_ago>
   </averageRecommendation>
   <strongBuy>
    <current>6</current>
    <one_month_ago>6</one_month_ago>
    <two_months_ago>6</two_months_ago>
    <three_months_ago>6</three_months_ago>
   </strongBuy>
   <hold>
    <current>0</current>
    <one_month_ago>0</one_month_ago>
    <two_months_ago>0</two_months_ago>
    <three_months_ago>0</three_months_ago>
   </hold>
   <strongSell>
    <current>0</current>
    <one_month_ago>0</one_month_ago>
    <two_months_ago>0</two_months_ago>
    <three_months_ago>0</three_months_ago>
   </strongSell>
  </item>
 </getRatings>

CSV

GET

GET https://ondemand.websol.barchart.com/getRatings.csv?apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getRatings.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=<YOUR API KEY>&symbols=AAPL%2CGOOG&fields=strongBuy%2Chold%2CstrongSell

Response

symbol,name,averageRecommendation_current,averageRecommendation_one_month_ago,averageRecommendation_two_months_ago,averageRecommendation_three_months_ago,strongBuy_current,strongBuy_one_month_ago,strongBuy_two_months_ago,strongBuy_three_months_ago,hold_current,hold_one_month_ago,hold_two_months_ago,hold_three_months_ago,strongSell_current,strongSell_one_month_ago,strongSell_two_months_ago,strongSell_three_months_ago,averageRecommendation_current,averageRecommendation_one_month_ago,averageRecommendation_two_months_ago,averageRecommendation_three_months_ago,strongBuy_current,strongBuy_one_month_ago,strongBuy_two_months_ago,strongBuy_three_months_ago,hold_current,hold_one_month_ago,hold_two_months_ago,hold_three_months_ago,strongSell_current,strongSell_one_month_ago,strongSell_two_months_ago,strongSell_three_months_ago
"AAPL","Apple Inc","1.77","1.72","1.74","1.74","18","18","19","19","5","4","5","5","2","2","2","2"
"GOOG","Alphabet Class C","1","1","1.14","1.25","6","6","6","6","0","0","0","0","0","0","0","0"


PHP

<?php

$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');

$params = [
    'symbols' => 'AAPL,GOOG',
    'fields' => 'strongBuy,hold,strongSell',
];

$result = $ondemand->getRatings($params);
var_dump($result);

Classic ASP

Dim ondemand
Dim result

Set ondemand = Server.CreateObject("MSSOAP.SoapClient30")
ondemand.ClientProperty("ServerHTTPRequest") = True
ondemand.MSSoapInit("https://ondemand.websol.barchart.com/service?wsdl")

Set result = ondemand.getRatings("AAPL,GOOG", "strongBuy,hold,strongSell")

Perl

use SOAP::Lite;
use SOAP::WSDL;

my $ondemand = SOAP::Lite
    -> service('https://ondemand.websol.barchart.com/service?wsdl');

my $result = $ondemand->getRatings('AAPL,GOOG', 'strongBuy,hold,strongSell');

print $result;

Python

from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')

result = client.service.getRatings('AAPL,GOOG', 'strongBuy,hold,strongSell')

print result

Ruby

require 'savon'

ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')

response = ondemand.call(
    :getRatings,
    message: {
        symbols: 'AAPL,GOOG',
        fields: 'strongBuy,hold,strongSell',
    }
)

response.body