Stock Competitors API
getCompetitors
The getCompetitors API provides a list of related stock symbols (competitors) for an underlying stock input. Users can return the competitors symbol, name, exchange, marketCap and fifty-two week high and low.
View All APIsContact Us to Get Access
Inputs
symbolrequired
A symbol or code that identifies a financial instrument.
Type
string (A sequence of characters. (example: GOOG))
Example
AAPL
fieldsoptional
The fields requested.
Type
list (A comma or semi-colon delimited string.)
Example
fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate
maxRecordsoptional
The maximum number of records to show in the return.
Type
int (A numeric type defining a whole number. (example: 2))
Example
10
Default
10
excludePriceAndVolumeFilteroptional
Pass this boolean parameter if you would like the API to exclude filter on volume and last price.
Type
boolean (A logical type representing the truth of a value as 'true' or 'false'.)
Example
true
Outputs
symbol
always returned
always returned
A symbol or code that identifies a financial instrument.
string
A sequence of characters. (example: GOOG)
A sequence of characters. (example: GOOG)
name
always returned
always returned
The full name of the instrument.
string
A sequence of characters. (example: GOOG)
A sequence of characters. (example: GOOG)
exchange
as requested
as requested
Exchange code for the marketplace where the financial instruments are listed.
string
A sequence of characters. (example: GOOG)
A sequence of characters. (example: GOOG)
marketCap
always returned
always returned
The quantity of shares or contracts traded.
int
A numeric type defining a whole number. (example: 2)
A numeric type defining a whole number. (example: 2)
fiftyTwoWkHigh
as requested
as requested
The highest price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkHighDate
as requested
as requested
The date in which the high price was reached over the past 52 weeks.
date
A date in the format of YYYY-MM-DD.
A date in the format of YYYY-MM-DD.
fiftyTwoWkLow
as requested
as requested
The low price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkLowDate
as requested
as requested
The date in which the low price was reached over the past 52 weeks.
date
A date in the format of YYYY-MM-DD.
A date in the format of YYYY-MM-DD.
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/getCompetitors.json?apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getCompetitors.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Response
{
"status": {
"code": 200,
"message": "Success."
},
"results": [
{
"symbol": "DELL",
"name": "Dell Technologies Inc",
"marketCap": 78423398438,
"fiftyTwoWkHigh": 179.7,
"fiftyTwoWkHighDate": "2024-05-29",
"fiftyTwoWkLow": 73.39,
"fiftyTwoWkLowDate": "2023-12-21"
},
{
"symbol": "HPQ",
"name": "HP Inc",
"marketCap": 30440910156,
"fiftyTwoWkHigh": 39.79,
"fiftyTwoWkHighDate": "2024-11-25",
"fiftyTwoWkLow": 27.42,
"fiftyTwoWkLowDate": "2024-04-24"
},
{
"symbol": "LNVGY",
"name": "Lenovo Group Ltd ADR",
"marketCap": 14801860352,
"fiftyTwoWkHigh": 31.82,
"fiftyTwoWkHighDate": "2024-06-20",
"fiftyTwoWkLow": 19.79,
"fiftyTwoWkLowDate": "2024-02-05"
}
]
}
XML
GET
GET https://ondemand.websol.barchart.com/getCompetitors.xml?apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getCompetitors.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Response
<?xml version="1.0" encoding="utf-8"?>
<getCompetitors>
<status>
<code>200</code>
<message>Success.</message>
</status>
<item>
<symbol>DELL</symbol>
<name>Dell Technologies Inc</name>
<marketCap>78423398438</marketCap>
<fiftyTwoWkHigh>179.7</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2024-05-29</fiftyTwoWkHighDate>
<fiftyTwoWkLow>73.39</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2023-12-21</fiftyTwoWkLowDate>
</item>
<item>
<symbol>HPQ</symbol>
<name>HP Inc</name>
<marketCap>30440910156</marketCap>
<fiftyTwoWkHigh>39.79</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2024-11-25</fiftyTwoWkHighDate>
<fiftyTwoWkLow>27.42</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2024-04-24</fiftyTwoWkLowDate>
</item>
<item>
<symbol>LNVGY</symbol>
<name>Lenovo Group Ltd ADR</name>
<marketCap>14801860352</marketCap>
<fiftyTwoWkHigh>31.82</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2024-06-20</fiftyTwoWkHighDate>
<fiftyTwoWkLow>19.79</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2024-02-05</fiftyTwoWkLowDate>
</item>
</getCompetitors>
CSV
GET
GET https://ondemand.websol.barchart.com/getCompetitors.csv?apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getCompetitors.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10&excludePriceAndVolumeFilter=true
Response
symbol,name,marketCap,fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate
"DELL","Dell Technologies Inc","78423398438","179.7","2024-05-29","73.39","2023-12-21"
"HPQ","HP Inc","30440910156","39.79","2024-11-25","27.42","2024-04-24"
"LNVGY","Lenovo Group Ltd ADR","14801860352","31.82","2024-06-20","19.79","2024-02-05"
PHP
<?php
$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');
$params = [
'apikey' => 'YOUR_API_KEY',
'symbol' => 'AAPL',
'fields' => 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate',
'maxRecords' => '10',
'excludePriceAndVolumeFilter' => 'true',
];
$result = $ondemand->getCompetitors($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.getCompetitors("YOUR_API_KEY", "AAPL", "fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate", "10", "true")
Perl
use SOAP::Lite;
use SOAP::WSDL;
my $ondemand = SOAP::Lite
-> service('https://ondemand.websol.barchart.com/service?wsdl');
my $result = $ondemand->getCompetitors('YOUR_API_KEY', 'AAPL', 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate', '10', 'true');
print $result;
Python
from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')
result = ondemand.service.getCompetitors('YOUR_API_KEY', 'AAPL', 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate', '10', 'true')
print(result)
Ruby
require 'savon'
ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')
response = ondemand.call(
:getCompetitors,
message: {
apikey: 'YOUR_API_KEY',
symbol: 'AAPL',
fields: 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate',
maxRecords: '10',
excludePriceAndVolumeFilter: 'true',
}
)
response.body