API Reference
Market Indicators Overview
Historical ITCH Specification
Historical Time&Sales Specification

API Overview

The www.tradingphysics.com web site is built over an API Server and allows both user and program interfaces to access the data.

The web GUI is a wrapper that creates a query to the API Server. It is the API Server that actually generates the requested object and returns it to the user.

You can obtain the following data objects via the interface:

  • Standalone data files, such as CSV, XML, and TXT files containing the data in the specified format
  • Charts in PNG format
  • Real-time streams in text format (such as CSV or XML)

The data objects are transferred using a TCP protocol based on HTTP request/response mechanism. For regular files, the interaction with the API Server comes down to a simple HTTP request/response transaction. The server will send all available data in the specified format to the client and close the connection at the end. For historical files, the resulting file will contain the entire session day, for real-time connections, the resulting file will contain information up to the last timestamp.

For real-time streams, however, there is an option (keepconnection=true) to keep the connection open event after the most recent data is sent to the client. In this case, the server keeps sending data as it comes in real time without closing the connection. If the data does not come within a specified timeout period (e.g. during extended hours), the server sends a hearbeat to signal that the connection is still alive. The server also sends a heartbeat as soon as the client catches up with real-time feed, i.e. right after the server sends all the ticks prior to client's connection timestamp. For example, if the client connected to a real-time session at 3:01:00 PM EST, the heartbeat will be sent before the message with a timestamp greater than 3:01:01 PM EST. Please refer to the underlying file formats for heartbeat specifications.

The API interface is driven by tickets as an authorization mechanism. You need to obtain a ticket prior to requesting the data. When generating a ticket for your query, the server will check the validity of the query and the existence of the appropriate subscription. It will issue a ticket or return an error with the a more detailed error description. Upon successful ticket retrieval, simply attach the ticket to your query and submit the query to server. You can reuse the obtained ticket to repeat the query, e.g. to reconnect to the real time feed.

Please check out sample programs and plugins that use the API Server request/response mechanism with an anonymous account.

API Request Format

Each API call to the www.tradingphysics.com API Server begins with an HTTP GET request sent to the API Server address. The server parses the received GET request and returns requested object with an HTTP 200 OK status code. In case of an error, the API Server returns an HTTP 400 Bad Request status code with more detailed error diagnostics in the body of the response.

Usage of the HTTP protocol enables to treat the client-server interaction by using standard internet interfaces and libraries, including a web browser for simple queries, such as charts.

The HTTP GET query is constructed the usual way:



URI Field Value
resource_type HTTP
domain api.tradingphysics.com
port 80
file_path_name API Method
query_string API Method Parameters

Please consult with our API Reference for more information on query string format and returned values.

API Request Examples