Documentation

Contracts for

DataNo Auth

Get the contracts available for a symbol. Request parameters, market data, display and Snowball fields are removed, and display_number_of_contracts can be null.

Quick comparison

AspectLegacy APINew APIAction
Endpointcontracts_forcontracts_forNone
Auth RequiredNoNoNone
Request parameters8 parameters3 parametersRemove obsolete parameters
Response structureMarket data and contract metadataContract list onlyStop reading removed fields
display_number_of_contractsNumberNumber or nullHandle null

Breaking changes

1. Request parameters removed

The request no longer accepts currency, landing_company, landing_company_short, product_type or loginid.

Required change: Remove these parameters from your contracts_for requests.

2. Market data fields removed

The contracts_for object no longer returns spot, open, close, feed_license or non_available.

Required change: Use ticks for spot prices and trading_times for market hours.

3. Display fields removed

Contracts in available no longer return contract_display or contract_category_display.

Required change: Build display names from contract_type and contract_category instead.

4. Contract metadata removed

Contracts in available no longer return barrier_category, exchange_name, start_type, forward_starting_options or trading_period. The Legacy API always returned barrier_category, contract_category_display, exchange_name and start_type.

Required change: Stop reading these fields.

5. Snowball choices removed

Contracts in available no longer return duration_choices or trade_risk_profile_choices, which described Snowball contracts.

Required change: Stop reading these fields.

6. display_number_of_contracts can be null

display_number_of_contracts was always a number in the Legacy API. In the New API it can be null.

Required change: Handle a null value before you display or calculate with it.

Request structure

Legacy APIrequest example
{
  "contracts_for": "R_100",
  "currency": "USD",
  "landing_company": "svg",
  "product_type": "basic",
  "req_id": 1
}
New APIrequest example
{
  "contracts_for": "R_100",
  "req_id": 1
}

Response structure

Legacy APIresponse example
{
  "contracts_for": {
    "available": [
      {
        "barriers": 0,
        "contract_category": "callput",
        "contract_type": "CALL",
        "expiry_type": "intraday",
        "market": "synthetic_index",
        "max_contract_duration": "1d",
        "min_contract_duration": "15s",
        "sentiment": "up",
        "submarket": "random_index",
        "underlying_symbol": "R_100",
        "barrier_category": "euro_atm",
        "contract_category_display": "Up/Down",
        "contract_display": "Higher",
        "exchange_name": "RANDOM",
        "start_type": "spot"
      }
    ],
    "close": 1760054399,
    "feed_license": "realtime",
    "hit_count": 1,
    "open": 1759968000,
    "spot": 1234.56
  },
  "echo_req": {
    "contracts_for": "R_100",
    "currency": "USD",
    "landing_company": "svg",
    "product_type": "basic",
    "req_id": 1
  },
  "msg_type": "contracts_for",
  "req_id": 1
}
New APIresponse example
{
  "contracts_for": {
    "available": [
      {
        "barriers": 0,
        "contract_category": "callput",
        "contract_type": "CALL",
        "expiry_type": "intraday",
        "market": "synthetic_index",
        "max_contract_duration": "1d",
        "min_contract_duration": "15s",
        "sentiment": "up",
        "submarket": "random_index",
        "underlying_symbol": "R_100"
      }
    ],
    "hit_count": 1
  },
  "echo_req": {
    "contracts_for": "R_100",
    "req_id": 1
  },
  "msg_type": "contracts_for",
  "req_id": 1
}

Code examples

function getContracts(symbol) {
  ws.send(JSON.stringify({ contracts_for: symbol, currency: "USD", landing_company: "svg" }));

  ws.onmessage = (event) => {
    const response = JSON.parse(event.data);
    if (response.msg_type !== "contracts_for" || !response.contracts_for) return;

    console.log("Spot:", response.contracts_for.spot);
    response.contracts_for.available.forEach((contract) => {
      console.log(contract.contract_display, contract.exchange_name, contract.display_number_of_contracts);
    });
  };
}

Any other questions? Get in touch

Click to open live chat support. Get instant help from our support team.