Stock Sectors API
getSectors
The getSectors API provides returns using weighted alpha on sectors covering multiple periods, including 1-day, 1-month, 3-month, 6-month, 9-month, 12-month and year-to-date.
View All APIssectoroptional
The symbol of the sector. Multiple sectors separated by a comma may be used.
-MEDR
sectorPeriodoptional
The period used to calculate the weighted alpha return by the sector, includes: 1-day ("1DA"), 1-month ("1MO"), 3-month ("3MO"), 6-month ("6MO"), 9-month ("9MO"), 12-month ("12MO") and year-to-date ("YTD").
1DA
dailyDataoptional
Whether to include daily data: Open, High, Low, Close, Previous Close, 52-week high and 52-week low
componentsoptional
Whether to include components of the sector.
sortDiroptional
Sorting method that should be applied.
ASC
always returned
A sequence of characters. (example: GOOG)
always returned
A sequence of characters. (example: GOOG)
always returned
A numeric type defining a number with fractional parts. (example: 2.14)
always returned
A numeric type defining a number with fractional parts. (example: 2.14)
always returned
A numeric type defining a number with fractional parts. (example: 2.14)
always returned
A numeric type defining a number with fractional parts. (example: 2.14)
always returned
A numeric type defining a whole number. (example: 2)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A numeric type defining a number with fractional parts. (example: 2.14)
as requested
A type which includes a list of valid possible values.
as requested
A type which includes a list of valid possible values.
as requested
A type which includes a list of valid possible values.
always returned
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
GET
GET https://ondemand.websol.barchart.com/getSectors.json?apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getSectors.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Response
{
"status": {
"code": 200,
"message": "Success."
},
"results": [
{
"symbol": "-MEDR",
"sector": "Medical - Drugs",
"weightAlpha": -9.19,
"lastTrade": -9.19,
"change": -0.3,
"percentChange": -3.37,
"stocks": "156",
"timestamp": "2024-11-20T20:37:52-06:00"
}
]
}
GET
GET https://ondemand.websol.barchart.com/getSectors.xml?apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getSectors.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Response
<?xml version="1.0" encoding="utf-8"?>
<getSectors>
<status>
<code>200</code>
<message>Success.</message>
</status>
<item>
<symbol>-MEDR</symbol>
<sector>Medical - Drugs</sector>
<weightAlpha>-9.19</weightAlpha>
<lastTrade>-9.19</lastTrade>
<change>-0.3</change>
<percentChange>-3.37</percentChange>
<stocks>156</stocks>
<timestamp>2024-11-20T20:37:52-06:00</timestamp>
</item>
</getSectors>
GET
GET https://ondemand.websol.barchart.com/getSectors.csv?apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getSectors.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY§or=-MEDR§orPeriod=1DA&dailyData=0&components=0&sortDir=ASC
Response
symbol,sector,weightAlpha,lastTrade,change,percentChange,stocks,timestamp
"-MEDR","Medical - Drugs","-9.19","-9.19","-0.3","-3.37","156","2024-11-20T20:37:52-06:00"
<?php
$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');
$params = [
'apikey' => 'YOUR_API_KEY',
'sector' => '-MEDR',
'sectorPeriod' => '1DA',
'dailyData' => '0',
'components' => '0',
'sortDir' => 'ASC',
];
$result = $ondemand->getSectors($params);
var_dump($result);
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.getSectors("YOUR_API_KEY", "-MEDR", "1DA", "0", "0", "ASC")
use SOAP::Lite;
use SOAP::WSDL;
my $ondemand = SOAP::Lite
-> service('https://ondemand.websol.barchart.com/service?wsdl');
my $result = $ondemand->getSectors('YOUR_API_KEY', '-MEDR', '1DA', '0', '0', 'ASC');
print $result;
from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')
result = ondemand.service.getSectors('YOUR_API_KEY', '-MEDR', '1DA', '0', '0', 'ASC')
print(result)
require 'savon'
ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')
response = ondemand.call(
:getSectors,
message: {
apikey: 'YOUR_API_KEY',
sector: '-MEDR',
sectorPeriod: '1DA',
dailyData: '0',
components: '0',
sortDir: 'ASC',
}
)
response.body