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. Multiple symbols separated by a comma may be used. For futures, notation such as
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
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
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
Response
{
"status": {
"code": 200,
"message": "Success."
},
"results": [
{
"symbol": "HPQ",
"name": "HP Inc",
"marketCap": 29064980469,
"fiftyTwoWkHigh": 33.9,
"fiftyTwoWkHighDate": "2023-07-12",
"fiftyTwoWkLow": 25.22,
"fiftyTwoWkLowDate": "2023-09-28"
},
{
"symbol": "LNVGY",
"name": "Lenovo Group Ltd ADR",
"marketCap": 14850900391,
"fiftyTwoWkHigh": 25.49,
"fiftyTwoWkHighDate": "2023-11-20",
"fiftyTwoWkLow": 15.29,
"fiftyTwoWkLowDate": "2023-01-19"
},
{
"symbol": "DDD",
"name": "3D Systems Corp",
"marketCap": 791260010,
"fiftyTwoWkHigh": 12.67,
"fiftyTwoWkHighDate": "2023-02-03",
"fiftyTwoWkLow": 3.5,
"fiftyTwoWkLowDate": "2023-10-27"
}
]
}
XML
GET
GET https://ondemand.websol.barchart.com/getCompetitors.xml?apikey=YOUR_API_KEY&symbol=AAPL&fields=fiftyTwoWkHigh%2CfiftyTwoWkHighDate%2CfiftyTwoWkLow%2CfiftyTwoWkLowDate&maxRecords=10
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
Response
<?xml version="1.0" encoding="utf-8"?>
<getCompetitors>
<status>
<code>200</code>
<message>Success.</message>
</status>
<item>
<symbol>HPQ</symbol>
<name>HP Inc</name>
<marketCap>29064980469</marketCap>
<fiftyTwoWkHigh>33.9</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2023-07-12</fiftyTwoWkHighDate>
<fiftyTwoWkLow>25.22</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2023-09-28</fiftyTwoWkLowDate>
</item>
<item>
<symbol>LNVGY</symbol>
<name>Lenovo Group Ltd ADR</name>
<marketCap>14850900391</marketCap>
<fiftyTwoWkHigh>25.49</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2023-11-20</fiftyTwoWkHighDate>
<fiftyTwoWkLow>15.29</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2023-01-19</fiftyTwoWkLowDate>
</item>
<item>
<symbol>DDD</symbol>
<name>3D Systems Corp</name>
<marketCap>791260010</marketCap>
<fiftyTwoWkHigh>12.67</fiftyTwoWkHigh>
<fiftyTwoWkHighDate>2023-02-03</fiftyTwoWkHighDate>
<fiftyTwoWkLow>3.5</fiftyTwoWkLow>
<fiftyTwoWkLowDate>2023-10-27</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
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
Response
symbol,name,marketCap,fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate
"HPQ","HP Inc","29064980469","33.9","2023-07-12","25.22","2023-09-28"
"LNVGY","Lenovo Group Ltd ADR","14850900391","25.49","2023-11-20","15.29","2023-01-19"
"DDD","3D Systems Corp","791260010","12.67","2023-02-03","3.5","2023-10-27"
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',
];
$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")
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');
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')
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',
}
)
response.body