getBLSIndexes API

The getBLSIndexes API provides historical price data for our cmdty BLS Commodity Price Index Family. The cmdty BLS Commodity Price Indexes measure price movements of 22 basic commodities whose markets are among the first to be influenced by changes in economic conditions. Sub-indices for six major asset classes are calculated.

All APIs

Contact Us to Get Access

Inputs

type required

The type of historical data to return, including tick data, minute data, and end-of-day data.

Type
enum (A type which includes a list of valid possible values.) 
Example
minutes 
Default
daily 

Valid Values:
ticks, minutes, nearbyMinutes, formTMinutes, daily, dailyNearest, dailyContinue, weekly, weeklyNearest, weeklyContinue, monthly, monthlyNearest, monthlyContinue, quarterly, quarterlyNearest, quarterlyContinue, yearly, yearlyNearest, yearlyContinue

startDate optional

The start date of the historical data query. This parameter should be set to the desired start date/time for the query (the result set will include records back to, and including, this value). If not set, the value will default to the date 6 months back from present day. The value should conform to the format yyyymmdd[hhmm[ss]], where fields in brackets are optional (Do not include the brackets themselves). Any optional fields that are not explicitly set will default to 0 (i.e. 20090203 will default to 20090203000000 or February 3, 2009 at 00:00:00).

Type
dateTime (A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.) 
Example
20100101 
Default
20180817000000 

endDate optional

The end data of the historical data query. This parameter should be set to the desired end date/time for the query (the result set will include records up to, but not including, this value). If not set, the value will default to the end of the current day. The value should conform to the format yyyymmdd[hhmm[ss]], where fields in brackets are optional (Do not include the brackets themselves). Any optional fields that are not explicitly set will default to 0 (i.e. 20090203 will default to 20090203000000 or February 3, 2009 at 00:00:00).

Type
dateTime (A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.) 
Example
20130101 

maxRecords optional

The maximum amount of records returned. This parameter should be set to the maximum number of records desired. If not specified, there number of records returned will be determined by the date/time parameters specified as well as any defaults that apply to the query.

Type
int (A numeric type defining a whole number. (example: 2)) 
Example
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 name/description for the instrument.
string
A sequence of characters. (example: GOOG)
history
always returned
An object with the date and close price for the provided date range.
enum
A type which includes a list of valid possible values.

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/getBLSIndexes.json?apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getBLSIndexes.json
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10

Response

{
    "status": {
        "code": 200,
        "message": "Success."
    },
    "results": [
        {
            "symbol": "BZY00",
            "name": "cmdty BLS Commodity Price Index",
            "history": []
        },
        {
            "symbol": "B7Y00",
            "name": "cmdty BLS Metals Price Index",
            "history": []
        },
        {
            "symbol": "BUY00",
            "name": "cmdty BLS Textiles Price Index",
            "history": []
        },
        {
            "symbol": "BVY00",
            "name": "cmdty BLS Industrials Price Index",
            "history": []
        },
        {
            "symbol": "BWY00",
            "name": "cmdty BLS Foodstuffs Price Index",
            "history": []
        },
        {
            "symbol": "BXY00",
            "name": "cmdty BLS Fats and Oils Price Index",
            "history": []
        },
        {
            "symbol": "BYY00",
            "name": "cmdty BLS Livestock Price Index",
            "history": []
        }
    ]
}

XML

GET

GET https://ondemand.websol.barchart.com/getBLSIndexes.xml?apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getBLSIndexes.xml
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10

Response


<?xml version="1.0" encoding="utf-8"?>
 <getBLSIndexes>
  <status>
   <code>200</code>
   <message>Success.</message>
  </status>
  <item>
   <symbol>BZY00</symbol>
   <name>cmdty BLS Commodity Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>B7Y00</symbol>
   <name>cmdty BLS Metals Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>BUY00</symbol>
   <name>cmdty BLS Textiles Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>BVY00</symbol>
   <name>cmdty BLS Industrials Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>BWY00</symbol>
   <name>cmdty BLS Foodstuffs Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>BXY00</symbol>
   <name>cmdty BLS Fats and Oils Price Index</name>
   <history></history>
  </item>
  <item>
   <symbol>BYY00</symbol>
   <name>cmdty BLS Livestock Price Index</name>
   <history></history>
  </item>
 </getBLSIndexes>

CSV

GET

GET https://ondemand.websol.barchart.com/getBLSIndexes.csv?apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10
Host: ondemand.websol.barchart.com

POST

POST https://ondemand.websol.barchart.com/getBLSIndexes.csv
Host: ondemand.websol.barchart.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

apikey=YOUR_API_KEY&type=minutes&startDate=20100101&endDate=20130101&maxRecords=10

Response

symbol,name
"BYY00","cmdty BLS Livestock Price Index"
"BXY00","cmdty BLS Fats and Oils Price Index"
"BWY00","cmdty BLS Foodstuffs Price Index"
"BVY00","cmdty BLS Industrials Price Index"
"BUY00","cmdty BLS Textiles Price Index"
"B7Y00","cmdty BLS Metals Price Index"
"BZY00","cmdty BLS Commodity Price Index"


PHP

<?php

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

$params = [
    'apikey' => 'YOUR_API_KEY',
    'type' => 'minutes',
    'startDate' => '20100101',
    'endDate' => '20130101',
    'maxRecords' => '10',
];

$result = $ondemand->getBLSIndexes($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.getBLSIndexes("YOUR_API_KEY", "minutes", "20100101", "20130101", "10")

Perl

use SOAP::Lite;
use SOAP::WSDL;

my $ondemand = SOAP::Lite
    -> service('https://ondemand.websol.barchart.com/service?wsdl');

my $result = $ondemand->getBLSIndexes('YOUR_API_KEY', 'minutes', '20100101', '20130101', '10');

print $result;

Python

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

result = client.service.getBLSIndexes('YOUR_API_KEY', 'minutes', '20100101', '20130101', '10')

print result

Ruby

require 'savon'

ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')

response = ondemand.call(
    :getBLSIndexes,
    message: {
        apikey: 'YOUR_API_KEY',
        type: 'minutes',
        startDate: '20100101',
        endDate: '20130101',
        maxRecords: '10',
    }
)

response.body