getCompetitors API

The getCompetitors API provides a list of related stock symbols (competitors) for an underlying stock input.

All APIs

Contact Us to Get Access

Inputs

symbol 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
string (A sequence of characters. (example: GOOG)) 
Example
AAPL 

fields optional

The fields requested.

Type
list (A comma or semi-colon delimited string.) 
Example
fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate 

maxRecords optional

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

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 full name of the instrument.
string
A sequence of characters. (example: GOOG)
exchange
as requested
Exchange code for the marketplace where the financial instruments are listed.
string
A sequence of characters. (example: GOOG)
marketCap
always returned
The quantity of shares or contracts traded.
int
A numeric type defining a whole number. (example: 2)
fiftyTwoWkHigh
as requested
The highest price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkHighDate
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.
fiftyTwoWkLow
as requested
The low price over the past 52 weeks.
double
A numeric type defining a number with fractional parts. (example: 2.14)
fiftyTwoWkLowDate
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.

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": "Hewlett-Packard Company",
            "marketCap": 36027378906,
            "fiftyTwoWkHigh": 22.31,
            "fiftyTwoWkHighDate": "2017-10-23",
            "fiftyTwoWkLow": 14.4,
            "fiftyTwoWkLowDate": "2017-01-10"
        },
        {
            "symbol": "LNVGY",
            "name": "Lenovo Group Ltd ADR",
            "marketCap": 6281950195,
            "fiftyTwoWkHigh": 13.9,
            "fiftyTwoWkHighDate": "2017-04-07",
            "fiftyTwoWkLow": 10.51,
            "fiftyTwoWkLowDate": "2017-09-07"
        },
        {
            "symbol": "DDD",
            "name": "3D Systems Corp",
            "marketCap": 949609985,
            "fiftyTwoWkHigh": 23.7,
            "fiftyTwoWkHighDate": "2017-05-17",
            "fiftyTwoWkLow": 7.92,
            "fiftyTwoWkLowDate": "2017-11-15"
        }
    ]
}

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>Hewlett-Packard Company</name>
   <marketCap>36027378906</marketCap>
   <fiftyTwoWkHigh>22.31</fiftyTwoWkHigh>
   <fiftyTwoWkHighDate>2017-10-23</fiftyTwoWkHighDate>
   <fiftyTwoWkLow>14.4</fiftyTwoWkLow>
   <fiftyTwoWkLowDate>2017-01-10</fiftyTwoWkLowDate>
  </item>
  <item>
   <symbol>LNVGY</symbol>
   <name>Lenovo Group Ltd ADR</name>
   <marketCap>6281950195</marketCap>
   <fiftyTwoWkHigh>13.9</fiftyTwoWkHigh>
   <fiftyTwoWkHighDate>2017-04-07</fiftyTwoWkHighDate>
   <fiftyTwoWkLow>10.51</fiftyTwoWkLow>
   <fiftyTwoWkLowDate>2017-09-07</fiftyTwoWkLowDate>
  </item>
  <item>
   <symbol>DDD</symbol>
   <name>3D Systems Corp</name>
   <marketCap>949609985</marketCap>
   <fiftyTwoWkHigh>23.7</fiftyTwoWkHigh>
   <fiftyTwoWkHighDate>2017-05-17</fiftyTwoWkHighDate>
   <fiftyTwoWkLow>7.92</fiftyTwoWkLow>
   <fiftyTwoWkLowDate>2017-11-15</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","Hewlett-Packard Company","36027378906","22.31","2017-10-23","14.4","2017-01-10"
"LNVGY","Lenovo Group Ltd ADR","6281950195","13.9","2017-04-07","10.51","2017-09-07"
"DDD","3D Systems Corp","949609985","23.7","2017-05-17","7.92","2017-11-15"


PHP

<?php

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

$params = [
    '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("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('AAPL', 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate', '10');

print $result;

Python

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

result = client.service.getCompetitors('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: {
        symbol: 'AAPL',
        fields: 'fiftyTwoWkHigh,fiftyTwoWkHighDate,fiftyTwoWkLow,fiftyTwoWkLowDate',
        maxRecords: '10',
    }
)

response.body