Web Query

New in Benchmark 1.1.0, from September 22 2014

The Web Query server allows retrieving up-to-date prices, and tick data with any application or programming language that supports HTTP and JSON.

WebQuery is for programmatically exporting price data from Benchmark, it cannot be used to import data.

API URL

Default URL

http://localhost:5000

The port number is configurable in the Preferences or Options dialog window. This documentation uses the default port number (5000) for the cURL examples. The port number must not be in use by another application when you launch Benchmark.

The example requests in this documentation can be run in the Terminal application.

DateTime Format

The Benchmark REST API uses a milliseconds since UNIX epoch timestamp (by default) to represent date time values. If you are connecting Microsoft Excel or LibreOffice to Benchmark, these values can be converted to a readable format with the following formula:
=B2/86400000+DATE(1970,1,1)
Where B2 is the cell containing the timestamp. The cell should also have a date time format applied.

Quote Streaming

GET /v1/stream/prices

Open a streaming connection to receive updating market quotes for all subscribed instruments.

Parameters

no parameters

Examples

Example Request:
curl http://localhost:5000/v1/stream/prices
Example Response:

{"tick":{"instrument":"USD_CAD","time":"1411417440889","bid":1.10285,"ask":1.10296}}
{"tick":{"instrument":"AUD_USD","time":"1411417449163","bid":0.88754,"ask":0.88767}}
{"tick":{"instrument":"GBP_JPY","time":"1411417448516","bid":178.002,"ask":178.026}}
{"heartbeat":{"time":"1411417450739"}}
{"tick":{"instrument":"EUR_USD","time":"1411417427581","bid":1.28489,"ask":1.285}}
{"tick":{"instrument":"USD_JPY","time":"1411417427042","bid":108.771,"ask":108.779}}

Quote Snapshots

GET /v1/prices

Fetch quotes for all subscribed instruments.

Parameters

f = format of the response; csv, tsv, html, xml, json (default).
    (optional)

instruments = comma separated list of symbols. 
    (optional)
    (introduced in 1.2.0)

since = ISO 8601 formatted or unix time (seconds), return prices that changed after the specified timestamp. 
    (optional, exclusive)
    ISO 8601 format available when used with `dtf=isodate`.
    (introduced in 1.2.0)

dtf = date time format of the request and response; unix (default), isodate.
    (optional)
    Requests (input) date times are ISO 8601 formatted or Unix time in seconds
    Responses (output) date times are ISO 8601 formatted or Unix time in milliseconds.
    (introduced in 1.3.0)

Examples

CSV Format

Example Request:
curl http://localhost:5000/v1/prices?f=csv
Example Response:

Instrument,Time,Bid,Ask,High,Low,Open
AUD_USD,1411417508175,0.88753,0.88766,0.89503,0.88522,0.89297
EUR_CHF,1411417508256,1.20768,1.20789,1.20800,1.20615,1.20730
EUR_GBP,1411417518330,0.78512,0.78530,0.78784,0.78437,0.78771
TSV Format

Example Request:
curl http://localhost:5000/v1/prices?f=tsv
Example Response:

Instrument	Time	Bid	Ask	High	Low	Open
AUD_USD	1411417540541	0.88753	0.88767	0.89503	0.88522	0.89297
EUR_CHF	1411417543330	1.20768	1.20786	1.20800	1.20615	1.20730
EUR_GBP	1411417548651	0.78512	0.78526	0.78784	0.78437	0.78771
HTML Format

Example Request:
curl http://localhost:5000/v1/prices?f=html
Example Response:

<html>
   <body>
      <table>
         <tr>
            <th>Instrument</th>
            <th>Time</th>
            <th>Bid</th>
            <th>Ask</th>
            <th>High</th>
            <th>Low</th>
            <th>Open</th>
         </tr>
         <tr>
            <td>AUD_USD</td>
            <td>1411417581875</td>
            <td>0.88751</td>
            <td>0.88769</td>
            <td>0.89503</td>
            <td>0.88522</td>
            <td>0.89297</td>
         </tr>
      </table>
   </body>
</html>
XML Format

Example Request:
curl http://localhost:5000/v1/prices?f=xml
Example Response:

<?xml version="1.0" encoding="UTF-8"?>
<Prices>
  <Price>
    <Instrument>AUD_USD</Instrument>
    <Time>1411417589243</Time>
    <Bid>0.88753</Bid>
    <Ask>0.88766</Ask>
    <High>0.89503</High>
    <Low>0.88522</Low>
    <Open>0.89297</Open>
  </Price>
</Prices>
JSON Format

Example Request:
curl http://localhost:5000/v1/prices?f=json
Example Response:

{
    "prices": [
        {
            "instrument": "AUD_USD",
            "time": "1411417660958",
            "bid": 0.88749,
            "ask": 0.88762,
            "high": 0.89503,
            "low": 0.88522,
            "open": 0.89297
        },
        {
            "instrument": "EUR_CHF",
            "time": "1411417660108",
            "bid": 1.20762,
            "ask": 1.20783,
            "high": 1.208,
            "low": 1.20615,
            "open": 1.2073
        }
    ]
}

Get Instruments

GET /v1/instruments

(introduced in 1.3.0)

Parameters

instruments = comma separated list of symbols.
	(optional)

columns = specify columns to be returned, default “instrument”,”displayName”,”pip”
	(optional)
	Valid column names:
	instruments – always returned
	displayName
	pip
	precision

Examples

Example Request:
http://localhost:5000/v1/instruments?instruments=AUD/USD,EUR/USD
Example Response:

{
    "instruments": [
        {
            "instrument": "EUR/USD",
            "displayName": "EUR/USD",
            "pip": "0.0001"
        },
        {
            "instrument": "AUD/USD",
            "displayName": "AUD/USD",
            "pip": "0.0001"
        }
    ]
}