### Python: Get Options Screener Data Source: https://www.barchart.com/ondemand/api/getOptionsScreener This Python example uses the 'suds' library to connect to the Barchart OnDemand API. It creates a client instance with the WSDL URL and then calls the getOptionsScreener service method, printing the results. You'll need to install the suds library (`pip install suds`). ```python from suds.client import Client ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl') result = ondemand.service.getOptionsScreener('YOUR_API_KEY', 'stocks', 'both', '10000', '10000', '1.91', '1.91', '1.12', '1.21', '1.11', '1.13', '1.21', '1.24', '12.4', '1.24', 'delta,gamma', '100', '1') print(result) ``` -------------------------------- ### GET Request Example (XML) Source: https://www.barchart.com/ondemand/api/getChart An example showcasing a GET request to retrieve data using XML format, similar to the JSON GET request. ```http GET https://ondemand.websol.barchart.com/getChart.xml?apikey=YOUR_API_KEY&symbols=TSLA%2CMSFT&type=LINE&width=700&height=550&volume=false&period=1d&interval=DO&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29 Host: ondemand.websol.barchart.com ``` -------------------------------- ### POST Request Example (JSON) Source: https://www.barchart.com/ondemand/api/getChart Demonstrates a POST request to the Barchart OnDemand API for retrieving chart data in JSON format. This example utilizes the POST method to send parameters, similar to the GET example. Remember to replace YOUR_API_KEY with your actual API key. ```http POST https://ondemand.websol.barchart.com/getChart.json Host: ondemand.websol.barchart.com Content-Type: application/x-www-form-urlencoded Content-Length: length apikey=YOUR_API_KEY&symbols=TSLA%2CMSFT&type=LINE&width=700&height=550&volume=false&period=1d&interval=DO&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29 ``` -------------------------------- ### GET Request Example (JSON) Source: https://www.barchart.com/ondemand/api/getChart Demonstrates a GET request to the Barchart OnDemand API for retrieving chart data in JSON format. This example includes several parameters to customize the chart, such as width, height, volume, period and indicators. It's important to replace YOUR_API_KEY with your actual API key. ```http GET https://ondemand.websol.barchart.com/getChart.json?apikey=YOUR_API_KEY&symbols=TSLA%2CMSFT&type=LINE&width=700&height=550&volume=false&period=1d&interval=DO&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29 Host: ondemand.websol.barchart.com ``` -------------------------------- ### Get Sectors Endpoint Request Examples (XML) Source: https://www.barchart.com/ondemand/api/getSectors Illustrates how to make requests to the getSectors endpoint using both GET and POST methods for XML output. It shows the URL for GET requests and the form-urlencoded content for POST requests, specifying parameters like apikey, sector, and sectorPeriod. ```XML 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 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 ``` -------------------------------- ### Fetch Grain Instruments GET Request Example Source: https://www.barchart.com/ondemand/api/getGrainInstruments This example demonstrates how to make a GET request to the Barchart OnDemand API to retrieve grain instrument data. It requires an API key and specifies parameters like instrument type, root, delivery month, index group, country, and pagination. The host for the request is ondemand.websol.barchart.com. ```HTTP GET https://ondemand.websol.barchart.com/getGrainInstruments.json?apikey=YOUR_API_KEY&instrumentType=indexBasis&instrumentRoot=ZC&deliveryMonth=202511&indexGroup=nation&country=US&maxRecords=25&page=1&locationId=4435 Host: ondemand.websol.barchart.com ``` -------------------------------- ### Get Sectors Endpoint Request Examples (JSON) Source: https://www.barchart.com/ondemand/api/getSectors Demonstrates how to call the getSectors endpoint using both GET and POST methods with JSON output. It shows the URL structure for GET and the form-urlencoded body for POST, including required parameters like apikey and optional ones like sector, sectorPeriod, dailyData, components, and sortDir. ```JSON 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 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 ``` -------------------------------- ### Perl Example for getEquityOptions Source: https://www.barchart.com/ondemand/api/getEquityOptions Example of how to call the getEquityOptions method using Perl and SOAP::Lite. ```APIDOC ## Perl Example for getEquityOptions ### Description This code snippet demonstrates how to use the Barchart OnDemand SOAP API with Perl and the SOAP::Lite module to retrieve equity options data. ### Method SOAP Client (Perl) ### Endpoint `https://ondemand.websol.barchart.com/service?wsdl` ### Parameters #### Request Parameters (passed as arguments to the method) - **apikey** (string) - Required - Your Barchart API key. - **underlying_symbols** (string) - Required - Comma-separated list of underlying symbols (e.g., "AAPL,MSFT"). - **type** (string) - Optional - Type of option (e.g., "Call", "Put"). - **expirationMonth** (string) - Optional - Expiration month (MM format). - **optionType** (string) - Optional - Type of option expiration (e.g., "Monthly", "Weekly"). - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., "bid,bidSize,ask,askSize"). - **onlyStrikes** (string) - Optional - If set to "1", only returns strike prices. - **legacySymbols** (string) - Optional - If set to "0", uses new symbol format. - **returnActualLegacySymbol** (string) - Optional - If set to "0", returns new symbol format. ### Request Example ```perl use SOAP::Lite; use SOAP::WSDL; my $ondemand = SOAP::Lite -> service('https://ondemand.websol.barchart.com/service?wsdl'); # Note: The exact way to pass parameters might vary slightly based on the WSDL structure # and how SOAP::Lite interprets it. You might need to inspect the WSDL or the # generated stubs to confirm the exact parameter names and order. # Example of calling the method (parameters need to be correctly structured): # my $result = $ondemand->getEquityOptions( # SOAP::Map::type('apikey' => 'YOUR_API_KEY'), # SOAP::Map::type('underlying_symbols' => 'AAPL'), # SOAP::Map::type('type' => 'Call'), # SOAP::Map::type('expirationMonth' => '05'), # SOAP::Map::type('optionType' => 'Monthly'), # SOAP::Map::type('fields' => 'bid,bidSize,ask,askSize'), # SOAP::Map::type('onlyStrikes' => '1'), # SOAP::Map::type('legacySymbols' => '0'), # SOAP::Map::type('returnActualLegacySymbol' => '0') # ); # Or if parameters are passed directly as a hash ref (more common with some WSDLs): my $params = { 'apikey' => 'YOUR_API_KEY', 'underlying_symbols' => 'AAPL', 'type' => 'Call', 'expirationMonth' => '05', 'optionType' => 'Monthly', 'fields' => 'bid,bidSize,ask,askSize', 'onlyStrikes' => '1', 'legacySymbols' => '0', 'returnActualLegacySymbol' => '0', }; my $result = $ondemand->getEquityOptions($params); # Process the $result object # use Data::Dumper; # print Dumper($result); ``` ### Response #### Success Response - The `$result` variable will hold the data returned from the SOAP service. The structure will depend on the WSDL and how SOAP::Lite parses it. ``` -------------------------------- ### PHP Example for getEquityOptions Source: https://www.barchart.com/ondemand/api/getEquityOptions Example of how to call the getEquityOptions method using PHP and the SOAP client. ```APIDOC ## PHP Example for getEquityOptions ### Description This code snippet demonstrates how to use the Barchart OnDemand SOAP API with PHP to retrieve equity options data. ### Method SOAP Client (PHP) ### Endpoint `https://ondemand.websol.barchart.com/service?wsdl` ### Parameters #### Request Parameters (as an array) - **apikey** (string) - Required - Your Barchart API key. - **underlying_symbols** (string) - Required - Comma-separated list of underlying symbols (e.g., "AAPL,MSFT"). - **type** (string) - Optional - Type of option (e.g., "Call", "Put"). - **expirationMonth** (string) - Optional - Expiration month (MM format). - **optionType** (string) - Optional - Type of option expiration (e.g., "Monthly", "Weekly"). - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., "bid,bidSize,ask,askSize"). - **onlyStrikes** (string) - Optional - If set to "1", only returns strike prices. - **legacySymbols** (string) - Optional - If set to "0", uses new symbol format. - **returnActualLegacySymbol** (string) - Optional - If set to "0", returns new symbol format. ### Request Example ```php 'YOUR_API_KEY', 'underlying_symbols' => 'AAPL', 'type' => 'Call', 'expirationMonth' => '05', 'optionType' => 'Monthly', 'fields' => 'bid,bidSize,ask,askSize', 'onlyStrikes' => '1', 'legacySymbols' => '0', 'returnActualLegacySymbol' => '0', ]; $result = $ondemand->getEquityOptions($params); var_dump($result); ``` ### Response #### Success Response - The response will be a SOAP-compliant structure containing the equity options data, typically in an array of objects or similar structure, depending on the WSDL definition. #### Response Example (Output of var_dump($result) will vary based on the actual data returned.) ``` -------------------------------- ### XML Request Examples for getFuturesOptions API Source: https://www.barchart.com/ondemand/api/getFuturesOptions Examples of GET and POST HTTP requests for the getFuturesOptions API endpoint in XML format. GET uses URL query parameters, POST uses application/x-www-form-urlencoded body. Required inputs include API key, root, contract, symbols, exchange, type, and optional fields. Outputs are XML responses with option data. Limitations: Necessitates valid API key and may accrue rate limits. ```xml GET GET https://ondemand.websol.barchart.com/getFuturesOptions.xml?apikey=YOUR_API_KEY&root=ZC&contract=ZCN26&symbols=ZCK210C%2CZCK210P&exchange=CME&type=Call&fields=premium%2CopenInterest Host: ondemand.websol.barchart.com POST POST https://ondemand.websol.barchart.com/getFuturesOptions.xml Host: ondemand.websol.barchart.com Content-Type: application/x-www-form-urlencoded Content-Length: length apikey=YOUR_API_KEY&root=ZC&contract=ZCN26&symbols=ZCK210C%2CZCK210P&exchange=CME&type=Call&fields=premium%2CopenInterest ``` -------------------------------- ### GET Request Example for Corporate Actions (CSV) Source: https://www.barchart.com/ondemand/api/getCorporateActions Example of a GET request to retrieve corporate actions data in CSV format. The parameters are included in the URL query string. ```http GET https://ondemand.websol.barchart.com/getCorporateActions.csv?apikey=YOUR_API_KEY&symbols=AMZN%2CAAPL&startDate=2013-01-01&endDate=2013-06-30&eventType=dividend&maxRecords=5 Host: ondemand.websol.barchart.com ``` -------------------------------- ### GET Request Example for Corporate Actions (XML) Source: https://www.barchart.com/ondemand/api/getCorporateActions Example of a GET request to retrieve corporate actions data in XML format. Parameters are appended to the URL, similar to JSON requests. ```http GET https://ondemand.websol.barchart.com/getCorporateActions.xml?apikey=YOUR_API_KEY&symbols=AMZN%2CAAPL&startDate=2013-01-01&endDate=2013-06-30&eventType=dividend&maxRecords=5 Host: ondemand.websol.barchart.com ``` -------------------------------- ### Get Highs and Lows Data - Python Source: https://www.barchart.com/ondemand/api/getHighsLows This Python example uses the `suds` library to create a SOAP client and call the Barchart OnDemand API's `getHighsLows` method. It requires the `suds` library to be installed and takes the API key and parameters to fetch data. ```python from suds.client import Client ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl') result = ondemand.service.getHighsLows('YOUR_API_KEY', 'NYSE,NASDAQ', 'STK', 'low', '260d', '20', '5') print(result) ``` -------------------------------- ### JSON Response Example Source: https://www.barchart.com/ondemand/api/getEquityOptionsOverviewSummary Sample JSON response structure showing status, total results count, and array of equity options data with implied volatility metrics and trading volume for each symbol. ```json { "status": { "code": 200, "message": "Success." }, "totalResults": 2, "results": [ { "symbol": "AAPL", "weightedImpliedVolatility": 0.23281748972124, "weightedImpliedVolatilityChange": -0.0051256928538704, "impliedVolatilityRank1y": 14.855399165906, "totalVolume": 318436, "date": "2025-11-10" }, { "symbol": "GOOG", "weightedImpliedVolatility": 0.32153876401179, "weightedImpliedVolatilityChange": -0.0071806475831065, "impliedVolatilityRank1y": 31.678135037563, "totalVolume": 105640, "date": "2025-11-10" } ] } ``` -------------------------------- ### Get Index Members XML Response Example Source: https://www.barchart.com/ondemand/api/getIndexMembers Example response from the Get Index Members API in XML format. Contains status information and list of index members with symbol, name, and exchange details. ```xml 200 Success. $SPX A Agilent Technologies NYSE ``` -------------------------------- ### Classic ASP Example for getEquityOptions Source: https://www.barchart.com/ondemand/api/getEquityOptions Example of how to call the getEquityOptions method using Classic ASP and MSSOAP.SoapClient30. ```APIDOC ## Classic ASP Example for getEquityOptions ### Description This code snippet demonstrates how to use the Barchart OnDemand SOAP API with Classic ASP to retrieve equity options data. ### Method SOAP Client (Classic ASP) ### Endpoint `https://ondemand.websol.barchart.com/service?wsdl` ### Parameters #### Direct Parameters (in order) - **apikey** (string) - Required - Your Barchart API key. - **underlying_symbols** (string) - Required - Comma-separated list of underlying symbols (e.g., "AAPL,MSFT"). - **type** (string) - Optional - Type of option (e.g., "Call", "Put"). - **expirationMonth** (string) - Optional - Expiration month (MM format). - **optionType** (string) - Optional - Type of option expiration (e.g., "Monthly", "Weekly"). - **fields** (string) - Optional - Comma-separated list of fields to return (e.g., "bid,bidSize,ask,askSize"). - **onlyStrikes** (string) - Optional - If set to "1", only returns strike prices. - **legacySymbols** (string) - Optional - If set to "0", uses new symbol format. - **returnActualLegacySymbol** (string) - Optional - If set to "0", returns new symbol format. ### Request Example ```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.getEquityOptions("YOUR_API_KEY", "AAPL", "Call", "05", "Monthly", "bid,bidSize,ask,askSize", "1", "0", "0") ``` ### Response #### Success Response - The `result` object will contain the equity options data returned from the API. The exact structure depends on the WSDL and how Classic ASP handles SOAP responses. #### Response Example (The content of the `result` object needs to be inspected to determine its exact structure and how to access the data.) ``` -------------------------------- ### Get Index Members JSON Response Example Source: https://www.barchart.com/ondemand/api/getIndexMembers Example response from the Get Index Members API in JSON format. Contains status information and array of index members with symbol, name, and exchange details. ```json { "status": { "code": 200, "message": "Success." }, "results": [ { "index": "$SPX", "symbol": "A", "name": "Agilent Technologies", "exchange": "NYSE" }, { "index": "$SPX", "symbol": "AAPL", "name": "Apple Inc", "exchange": "NASDAQ" }, { "index": "$SPX", "symbol": "ABBV", "name": "Abbvie Inc", "exchange": "NYSE" } ] } ``` -------------------------------- ### GET Request Example for Corporate Actions (JSON) Source: https://www.barchart.com/ondemand/api/getCorporateActions Example of a GET request to retrieve corporate actions data in JSON format. It specifies the API key, symbols, date range, event type, and maximum number of records. ```http GET https://ondemand.websol.barchart.com/getCorporateActions.json?apikey=YOUR_API_KEY&symbols=AMZN%2CAAPL&startDate=2013-01-01&endDate=2013-06-30&eventType=dividend&maxRecords=5 Host: ondemand.websol.barchart.com ``` -------------------------------- ### Get News Response (JSON) Source: https://www.barchart.com/ondemand/api/getNews Provides an example of a JSON response from the getNews endpoint. This specific example indicates success but with no content to return. ```json { "status": { "code": 204, "message": "Success, but no content to return." }, "results": [] } ``` -------------------------------- ### Barchart OnDemand API - Classic ASP Example Source: https://www.barchart.com/ondemand/api/getCmdtyCalendar Example demonstrating how to use the Barchart OnDemand API with Classic ASP and SOAP. ```APIDOC ## Barchart OnDemand API - Classic ASP Example ### Description This example shows how to interact with the Barchart OnDemand API using Classic ASP and MSSOAP to retrieve commodity calendar data. ### Language Classic ASP ### Code Example ```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.getCmdtyCalendar("YOUR_API_KEY", "20241110", "20251231", "Ag,Energy", "USA,CHN", "2,1", "USCB-WHSLETRADE-SALES-CHG-SA-USA-13652.CM,USCB-WHSLETRADE-INV-CHG-SA-USA-13610.CM", "asc", "reference_ending,prior_reference_ending") ``` ``` -------------------------------- ### Barchart OnDemand API: Get News - CSV GET Request Source: https://www.barchart.com/ondemand/api/getNews This example shows the structure of a GET request to retrieve news data in CSV format from the Barchart OnDemand API. It includes the base URL and all necessary query parameters. ```http GET https://ondemand.websol.barchart.com/getNews.csv?apikey=YOUR_API_KEY&sources=AP%2CIF&symbols=AMZN%2CGOOG%2CAAPL&category=stocks&subCategory=private+companies&series=MORNCALL&keyword=tablet&maxRecords=10&startDate=2025-11-10T12%3A25%3A09&displayType=preview&images=true&storyId=259220&rss=false&fields=publishDate&barchartClassification=FUT.SFT&organization=Barchart&lang=en&sourceFeed=CONT2&exactCategoryMatch=false Host: ondemand.websol.barchart.com ``` -------------------------------- ### GET getETFConstituents (CSV) Source: https://www.barchart.com/ondemand/api/getETFConstituents Retrieve ETF constituent holdings as CSV by using the .csv path. This example shows GET; the same parameters can be sent via POST form-encoded. ```APIDOC ## GET getETFConstituents (CSV) ### Description Retrieve ETF constituent holdings in CSV format using HTTP GET. ### Method GET ### Endpoint https://ondemand.websol.barchart.com/getETFConstituents.csv ### Parameters #### Path Parameters None #### Query Parameters - **apikey** (string) - Required - Your API key - **symbol** (string) - Required - ETF symbol to retrieve constituents for (e.g., SPY) #### Request Body N/A (GET with query parameters) ### Request Example GET /getETFConstituents.csv?apikey=YOUR_API_KEY&symbol=SPY ### Response #### Success Response (200) - **CSV Columns**: - symbol (string) - name (string) - holdingsPercent (number) - sharesHeld (integer) - exchange (string) #### Response Example symbol,name,holdingsPercent,sharesHeld,exchange "NVDA","NVIDIA CORP","8","294702444","NASDAQ" "AAPL","APPLE INC","6.98","179242780","NASDAQ" "MSFT","MICROSOFT CORP","6.44","89778184","NASDAQ" "AMZN","AMAZON.COM INC","4.11","117220589","NASDAQ" ``` -------------------------------- ### Sample XML Response for getFuturesOptions API Source: https://www.barchart.com/ondemand/api/getFuturesOptions An XML example of the successful response from the getFuturesOptions endpoint, including status code and detailed options data with elements for symbol, strike, Greeks, prices, volume, and more. Inputs are query parameters sent via GET or POST; outputs are structured XML. Limitations: Requires authenticated API access and data availability. ```xml 200 Success. ZCN230D ZC ZCN26 Corn N CBOT Call 230 2026-06-26 2025-11-07 57.514839172363 0.937 0 -0.038 0.307 0 227.25 227.25 227.25 228.25 -1 -0.44 11362.5 0 0 ZCN26|230C ZCN240D ZC ZCN26 Corn N CBOT Call 240 2026-06-26 2025-11-07 53.704299926758 ``` -------------------------------- ### POST Request Example (XML) Source: https://www.barchart.com/ondemand/api/getChart Illustrates submitting a request using the POST method to the API endpoint, expecting an XML response. ```http POST https://ondemand.websol.barchart.com/getChart.xml Host: ondemand.websol.barchart.com Content-Type: application/x-www-form-urlencoded Content-Length: length apikey=YOUR_API_KEY&symbols=TSLA%2CMSFT&type=LINE&width=700&height=550&volume=false&period=1d&interval=DO&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29 ``` -------------------------------- ### JSON Response Example Source: https://www.barchart.com/ondemand/api/getChart Illustrates a sample JSON response from the Barchart OnDemand API, showing the structure of the data returned, including status codes and chart details for multiple symbols. ```json { "status": { "code": 200, "message": "Success." }, "results": [ { "symbol": "TSLA", "imageURL": "\\ondemand.websol.barchart.com\\chart.png?symbol=TSLA&barType=LINE&time=1d&width=700&height=550&volume=0&bgColor=1728053247&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29&period=DO&startDate=1762456852&endDate=1762797599&ondemandkey=ondemand" }, { "symbol": "MSFT", "imageURL": "\\ondemand.websol.barchart.com\\chart.png?symbol=MSFT&barType=LINE&time=1d&width=700&height=550&volume=0&bgColor=1728053247&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29&period=DO&startDate=1762456848&endDate=1762797599&ondemandkey=ondemand" } ] } ``` -------------------------------- ### Get Equity Options History (GET Request) Source: https://www.barchart.com/ondemand/api/getEquityOptionsHistory Example of making a GET request to the Barchart OnDemand API to retrieve equity options history. This method is suitable for simple data retrieval and can be easily used in various client-side or server-side applications. ```HTTP GET https://ondemand.websol.barchart.com/getEquityOptionsHistory.json?apikey=YOUR_API_KEY&symbol=AAPL%7C20200417%7C250.00C&country=US&askbid=&fields=settlement Host: ondemand.websol.barchart.com ``` -------------------------------- ### Sample JSON Response for Futures Options Data Source: https://www.barchart.com/ondemand/api/getFuturesOptions This JSON example demonstrates the response format from the getFuturesOptions API, containing an array of futures options objects with details such as implied volatility, delta, gamma, theta, vega, price metrics, and more. It requires API key authentication and parameters like root, contract, symbols, exchange, type, and fields. Outputs include structured data for analysis; limitations involve dependency on real-time market data and valid API credentials. ```json [ { "date": "2025-11-07", "impliedVolatility": 18.20041885375977, "delta": 0.929, "gamma": 0.001, "theta": -0.013, "vega": 0.355, "open": 92.875, "high": 92.875, "low": 92.875, "last": 92.875, "previousClose": 93.875, "change": -1, "percentChange": -1.07, "premium": 4643.75, "volume": "0", "openInterest": 0, "longSymbol": "ZCN26|365C" }, { "symbol": "ZCN370D", "root": "ZC", "contract": "ZCN26", "contractName": "Corn", "contractMonth": "N", "exchange": "CBOT", "type": "Call", "strike": 370, "expirationDate": "2026-06-26", "date": "2025-11-07", "impliedVolatility": 17.662009620666502, "delta": 0.924, "gamma": 0.002, "theta": -0.013, "vega": 0.386, "open": 88.125, "high": 88.125, "low": 88.125, "last": 88.125, "previousClose": 89.125, "change": -1, "percentChange": -1.12, "premium": 4406.25, "volume": "0", "openInterest": 0, "longSymbol": "ZCN26|370C" }, { "symbol": "ZCN375D", "root": "ZC", "contract": "ZCN26", "contractName": "Corn", "contractMonth": "N", "exchange": "CBOT", "type": "Call", "strike": 375, "expirationDate": "2026-06-26", "date": "2025-11-07", "impliedVolatility": 17.383221054077147, "delta": 0.915, "gamma": 0.002, "theta": -0.015, "vega": 0.434, "open": 83.5, "high": 84.75, "low": 83.375, "last": 83.5, "previousClose": 84.5, "change": -1, "percentChange": -1.18, "premium": 4175, "volume": "0", "openInterest": 0, "longSymbol": "ZCN26|375C" }, { "symbol": "ZCN380D", "root": "ZC", "contract": "ZCN26", "contractName": "Corn", "contractMonth": "N", "exchange": "CBOT", "type": "Call", "strike": 380, "expirationDate": "2026-06-26", "date": "2025-11-07", "impliedVolatility": 17.023320007324216, "delta": 0.907, "gamma": 0.002, "theta": -0.016, "vega": 0.481, "open": 78.875, "high": 78.875, "low": 78.875, "last": 78.875, "previousClose": 79.875, "change": -1, "percentChange": -1.25, "premium": 3943.75, "volume": "0", "openInterest": 0, "longSymbol": "ZCN26|380C" } ] ``` -------------------------------- ### Retrieve Futures Data via GET Request Source: https://www.barchart.com/ondemand/api/getFuturesByExchange Example of a GET request to fetch futures data by exchange in XML format. Requires API key and allows filtering by exchange and category. ```http GET https://ondemand.websol.barchart.com/getFuturesByExchange.xml?apikey=YOUR_API_KEY&exchange=BMF&category=Meats&fields=openInterest Host: ondemand.websol.barchart.com ``` -------------------------------- ### XML Response Example Source: https://www.barchart.com/ondemand/api/getChart Displays a sample XML response from the Barchart OnDemand API for chart data. ```xml 200 Success. TSLA //ondemand.websol.barchart.com/chart.png?symbol=TSLA&barType=LINE&time=1d&width=700&height=550&volume=0&bgColor=1728053247&indicators=BBANDS%2820%2C2%29%3BMACD%2812%2C26%2C9%29&period=DO&startDate=1762456852&endDate=1762797599&ondemandkey=ondemand MSFT ``` -------------------------------- ### Barchart OnDemand API - Ruby Example Source: https://www.barchart.com/ondemand/api/getCmdtyCalendar Example demonstrating how to use the Barchart OnDemand API with Ruby and Savon. ```APIDOC ## Barchart OnDemand API - Ruby Example ### Description This example shows how to interact with the Barchart OnDemand API using Ruby and the Savon gem to retrieve commodity calendar data. ### Language Ruby ### Code Example ```ruby require 'savon' ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl') response = ondemand.call( :getCmdtyCalendar, message: { apikey: 'YOUR_API_KEY', startDate: '20241110', endDate: '20251231', category: 'Ag,Energy', country: 'USA,CHN', importance: '2,1', symbol: 'USCB-WHSLETRADE-SALES-CHG-SA-USA-13652.CM,USCB-WHSLETRADE-INV-CHG-SA-USA-13610.CM', order: 'asc', fields: 'reference_ending,prior_reference_ending' } ) ``` ``` -------------------------------- ### Get Forex Forward Curves - GET Request Source: https://www.barchart.com/ondemand/api/getForexForwardCurves This example shows how to fetch Forex Forward Curves data using a GET request. Requires an API key and a symbol parameter. The response is a CSV file containing bid, ask, mid, and other market data points. ```http GET https://ondemand.websol.barchart.com/getForexForwardCurves.csv?apikey=YOUR_API_KEY&symbols=%5EEURUSD Host: ondemand.websol.barchart.com ``` -------------------------------- ### Get Grain Instruments using Perl SOAP::Lite Source: https://www.barchart.com/ondemand/api/getGrainInstruments Provides a Perl example using the SOAP::Lite module to interact with the Barchart OnDemand API. It sets up the service from the WSDL and calls the getGrainInstruments method. ```perl use SOAP::Lite; use SOAP::WSDL; my $ondemand = SOAP::Lite -> service('https://ondemand.websol.barchart.com/service?wsdl'); my $result = $ondemand->getGrainInstruments('YOUR_API_KEY', 'indexBasis', 'ZC', '202511', 'nation', 'US', '25', '1', '4435'); print $result; ``` -------------------------------- ### HTTP Requests for ETF Constituents (GET and POST) Source: https://www.barchart.com/ondemand/api/getETFConstituents Examples of GET and POST requests to the getETFConstituents endpoint. Requires an API key and ETF symbol as parameters. GET appends query parameters; POST uses form-urlencoded body. Returns JSON response with holdings data. ```http GET https://ondemand.websol.barchart.com/getETFConstituents.json?apikey=YOUR_API_KEY&symbol=SPY Host: ondemand.websol.barchart.com ``` ```http POST https://ondemand.websol.barchart.com/getETFConstituents.json Host: ondemand.websol.barchart.com Content-Type: application/x-www-form-urlencoded Content-Length: length apikey=YOUR_API_KEY&symbol=SPY ``` -------------------------------- ### Barchart OnDemand API - Python Example Source: https://www.barchart.com/ondemand/api/getCmdtyCalendar Example demonstrating how to use the Barchart OnDemand API with Python and SUDs. ```APIDOC ## Barchart OnDemand API - Python Example ### Description This example shows how to interact with the Barchart OnDemand API using Python and the SUDs library to retrieve commodity calendar data. ### Language Python ### Code Example ```python from suds.client import Client ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl') result = ondemand.service.getCmdtyCalendar('YOUR_API_KEY', '20241110', '20251231', 'Ag,Energy', 'USA,CHN', '2,1', 'USCB-WHSLETRADE-SALES-CHG-SA-USA-13652.CM,USCB-WHSLETRADE-INV-CHG-SA-USA-13610.CM', 'asc', 'reference_ending,prior_reference_ending') print(result) ``` ``` -------------------------------- ### Initialize PHP Script for Barchart OnDemand API Source: https://www.barchart.com/ondemand/api/getRestrictedSessionHistory A minimal PHP starter file that can be expanded to perform API calls to the Barchart OnDemand service. Insert your API key and request logic after the opening tag. ```php