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": 95531351562,
"fiftyTwoWkHigh": 179.7,
"fiftyTwoWkHighDate": "2024-05-29",
"fiftyTwoWkLow": 67.51,
"fiftyTwoWkLowDate": "2023-12-06"
},
{
"symbol": "HPQ",
"name": "HP Inc",
"marketCap": 36071960938,
"fiftyTwoWkHigh": 39.52,
"fiftyTwoWkHighDate": "2024-05-30",
"fiftyTwoWkLow": 27.42,
"fiftyTwoWkLowDate": "2024-04-24"
},
{
"symbol": "LNVGY",
"name": "Lenovo Group Ltd ADR",
"marketCap": 14451429688,
"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>95531351562</marketCap>
<fiftyTwoWkHigh>179.7</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2024-05-29</fiftyTwoWkHighDate>
<fiftyTwoWkLow>67.51</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2023-12-06</fiftyTwoWkLowDate>
</item>
<item>
<symbol>HPQ</symbol>
<name>HP Inc</name>
<marketCap>36071960938</marketCap>
<fiftyTwoWkHigh>39.52</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2024-05-30</fiftyTwoWkHighDate>
<fiftyTwoWkLow>27.42</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2024-04-24</fiftyTwoWkLowDate>
</item>
<item>
<symbol>LNVGY</symbol>
<name>Lenovo Group Ltd ADR</name>
<marketCap>14451429688</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","95531351562","179.7","2024-05-29","67.51","2023-12-06"
"HPQ","HP Inc","36071960938","39.52","2024-05-30","27.42","2024-04-24"
"LNVGY","Lenovo Group Ltd ADR","14451429688","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