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": -21.83,
"lastTrade": -21.83,
"change": 0.55,
"percentChange": 2.46,
"stocks": "151",
"timestamp": "2024-12-20T20:31:08-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>-21.83</weightAlpha>
<lastTrade>-21.83</lastTrade>
<change>0.55</change>
<percentChange>2.46</percentChange>
<stocks>151</stocks>
<timestamp>2024-12-20T20:31:08-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","-21.83","-21.83","0.55","2.46","151","2024-12-20T20:31:08-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