News Category API
getNewsCategories
The getNewsCategories API provides access to news source category and sub-category data. Sources include Associated Press, Canadian Press, and Dow Jones
View All APIsContact Us to Get Access
Inputs
sourcesoptional
An id or code that identifies a news source. Multiple sources separated by a comma may be used.
Type
list (A comma or semi-colon delimited string.)
Example
AP,CMTX,USDA
depthoptional
An integer that will limit how many levels of the category tree to show. By default all levels are returned.
Type
int (A numeric type defining a whole number. (example: 2))
Example
2
Outputs
category
always returned
always returned
The category symbol.
string
A sequence of characters. (example: GOOG)
A sequence of characters. (example: GOOG)
subcategories
as requested
as requested
The sub-categories.
array
A data structure that contains a group of elements.
A data structure that contains a group of elements.
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/getNewsCategories.json?apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getNewsCategories.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Response
{
"status": {
"code": 200,
"message": "Success."
},
"results": [
{
"category": {
"name": "Stocks",
"symbol": "STK",
"subcategories": [
{
"category": {
"name": "Aerospace",
"symbol": "AERO"
}
},
{
"category": {
"name": "Agriculture",
"symbol": "AG"
}
},
{
"category": {
"name": "Automobile",
"symbol": "AUTO"
}
},
{
"category": {
"name": "Business Services",
"symbol": "BUSS"
}
},
{
"category": {
"name": "Construction",
"symbol": "BLD"
}
},
{
"category": {
"name": "Consumer Products",
"symbol": "CONP"
}
},
{
"category": {
"name": "Corporate",
"symbol": "CORP"
}
},
{
"category": {
"name": "Defense",
"symbol": "DEFN"
}
},
{
"category": {
"name": "Energy & Oil",
"symbol": "ENER"
}
},
{
"category": {
"name": "Finance \/ Banking",
"symbol": "FIN"
}
},
{
"category": {
"name": "Indices",
"symbol": "IDX"
}
},
{
"category": {
"name": "Industrial Products",
"symbol": "INDU"
}
},
{
"category": {
"name": "Leisure & Recreation",
"symbol": "LEIS"
}
},
{
"category": {
"name": "Media",
"symbol": "MDIA"
}
},
{
"category": {
"name": "Medical",
"symbol": "MED"
}
},
{
"category": {
"name": "Retail Sales",
"symbol": "RET"
}
},
{
"category": {
"name": "Technology",
"symbol": "TECH"
}
},
{
"category": {
"name": "Transportation",
"symbol": "TRNS"
}
},
{
"category": {
"name": "Utilities",
"symbol": "UTIL"
}
}
]
}
},
{
"category": {
"name": "Futures",
"symbol": "FUT",
"subcategories": [
{
"category": {
"name": "Weather",
"symbol": "WTH"
}
},
{
"category": {
"name": "Livestock",
"symbol": "SFT"
}
},
{
"category": {
"name": "Medical",
"symbol": "MEAT"
}
},
{
"category": {
"name": "Grains",
"symbol": "GRN"
}
},
{
"category": {
"name": "Fruits and Vegetables",
"symbol": "FVT"
}
}
]
}
}
]
}
XML
GET
GET https://ondemand.websol.barchart.com/getNewsCategories.xml?apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getNewsCategories.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Response
<?xml version="1.0" encoding="utf-8"?>
<getNewsCategories>
<status>
<code>200</code>
<message>Success.</message>
</status>
<item>
<category>
<name>Stocks</name>
<symbol>STK</symbol>
<subcategories>
<category>
<name>Aerospace</name>
<symbol>AERO</symbol>
</category>
<category>
<name>Agriculture</name>
<symbol>AG</symbol>
</category>
<category>
<name>Automobile</name>
<symbol>AUTO</symbol>
</category>
<category>
<name>Business Services</name>
<symbol>BUSS</symbol>
</category>
<category>
<name>Construction</name>
<symbol>BLD</symbol>
</category>
<category>
<name>Consumer Products</name>
<symbol>CONP</symbol>
</category>
<category>
<name>Corporate</name>
<symbol>CORP</symbol>
</category>
<category>
<name>Defense</name>
<symbol>DEFN</symbol>
</category>
<category>
<name>Energy & Oil</name>
<symbol>ENER</symbol>
</category>
<category>
<name>Finance / Banking</name>
<symbol>FIN</symbol>
</category>
<category>
<name>Indices</name>
<symbol>IDX</symbol>
</category>
<category>
<name>Industrial Products</name>
<symbol>INDU</symbol>
</category>
<category>
<name>Leisure & Recreation</name>
<symbol>LEIS</symbol>
</category>
<category>
<name>Media</name>
<symbol>MDIA</symbol>
</category>
<category>
<name>Medical</name>
<symbol>MED</symbol>
</category>
<category>
<name>Retail Sales</name>
<symbol>RET</symbol>
</category>
<category>
<name>Technology</name>
<symbol>TECH</symbol>
</category>
<category>
<name>Transportation</name>
<symbol>TRNS</symbol>
</category>
<category>
<name>Utilities</name>
<symbol>UTIL</symbol>
</category>
</subcategories>
</category>
</item>
<item>
<category>
<name>Futures</name>
<symbol>FUT</symbol>
<subcategories>
<category>
<name>Weather</name>
<symbol>WTH</symbol>
</category>
<category>
<name>Livestock</name>
<symbol>SFT</symbol>
</category>
<category>
<name>Medical</name>
<symbol>MEAT</symbol>
</category>
<category>
<name>Grains</name>
<symbol>GRN</symbol>
</category>
<category>
<name>Fruits and Vegetables</name>
<symbol>FVT</symbol>
</category>
</subcategories>
</category>
</item>
</getNewsCategories>
CSV
GET
GET https://ondemand.websol.barchart.com/getNewsCategories.csv?apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Host: ondemand.websol.barchart.com
POST
POST https://ondemand.websol.barchart.com/getNewsCategories.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
apikey=YOUR_API_KEY&sources=AP%2CCMTX%2CUSDA&depth=2
Response
name,symbol,parent
"Futures","FUT"
"Fruits and Vegetables","FVT","FUT"
"Grains","GRN","FUT"
"Medical","MEAT","FUT"
"Livestock","SFT","FUT"
"Weather","WTH","FUT"
"Stocks","STK"
"Utilities","UTIL","STK"
"Transportation","TRNS","STK"
"Technology","TECH","STK"
"Retail Sales","RET","STK"
"Medical","MED","STK"
"Media","MDIA","STK"
"Leisure & Recreation","LEIS","STK"
"Industrial Products","INDU","STK"
"Indices","IDX","STK"
"Finance / Banking","FIN","STK"
"Energy & Oil","ENER","STK"
"Defense","DEFN","STK"
"Corporate","CORP","STK"
"Consumer Products","CONP","STK"
"Construction","BLD","STK"
"Business Services","BUSS","STK"
"Automobile","AUTO","STK"
"Agriculture","AG","STK"
"Aerospace","AERO","STK"
PHP
<?php
$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');
$params = [
'apikey' => 'YOUR_API_KEY',
'sources' => 'AP,CMTX,USDA',
'depth' => '2',
];
$result = $ondemand->getNewsCategories($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.getNewsCategories("YOUR_API_KEY", "AP,CMTX,USDA", "2")
Perl
use SOAP::Lite;
use SOAP::WSDL;
my $ondemand = SOAP::Lite
-> service('https://ondemand.websol.barchart.com/service?wsdl');
my $result = $ondemand->getNewsCategories('YOUR_API_KEY', 'AP,CMTX,USDA', '2');
print $result;
Python
from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')
result = ondemand.service.getNewsCategories('YOUR_API_KEY', 'AP,CMTX,USDA', '2')
print(result)
Ruby
require 'savon'
ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')
response = ondemand.call(
:getNewsCategories,
message: {
apikey: 'YOUR_API_KEY',
sources: 'AP,CMTX,USDA',
depth: '2',
}
)
response.body