|
API Methods
Use this method to obtain a ticket for other methods that require a ticket, e.g. GetData.
These are the methods that require a valid subscription.
The GetTicket method will generate a ticket value (currently a GUID) that you will need to supply to queries that require a ticket.
You can use your account credentials or obtain a ticket anonymously (e.g. for testing purposes).
Anonymous tickets provide limited access to data.
The GetTicket method will validate your account credentials and issue a ticket if you have access to the requested data as per your subscription settings.
For example, if you are using Download Credits to get the data files, the ticket will be issued if you have enough download credits left for the requested transaction.
The GetTicket method will not charge any download credits. The download credits will be charged only once when you actually use the ticket in one of the queries.
Repeat usage of the ticket will not result in an additional charge.
Parameter |
Description |
Values |
C |
Your Customer Number |
Customer Number in the 000-000-000 format issued to your account OR an empty string for anonymous access
|
P |
Hash value of your Account Password |
The hash value will be generated automatically for your password. You can look it up on your account information page.
This parameter can also contain an empty string for anonymous access.
|
"?" |
Query for which the ticket is to be issued |
The exact query that needs to obtain a ticket, preceded by the "?" character.
You will attached the obtained ticket to this query prior to calling the API Server.
|
RETURNED VALUE |
The method returns the status using an HTTP status code,
with the ticket or an error message returned in the response body |
200 OK: the ticket is returned in the response body.
If the query does not require a ticket, the function will return an empty string (CR-LF).
400 Bad Request: there was an error while processing the request.
A more detailed error message is returned in the response body in plain text.
403 Forbidden: invalid credentials
|
Example 1
Request Anonymous Ticket for downloading order flow data
http://api.tradingphysics.com/getticket?C=&P=?getdata?type=orderflow&date=20090501&stock=QQQQ&format=CSV&compression=stream
Example 2
Request Ticket for Customer 000-000-000 with password hash ABCDEFGHIJKLMNOPQRSTUV for downloading order flow data.
Note: the system will return "Invalid Customer Number and/or Password" error message for these credentials.
Please substitute your own Customer Number and Password Hash for this example to work.
http://api.tradingphysics.com/getticket?C=000-000-000&P=ABCDEFGHIJKLMNOPQRSTUV?getdata?type=orderflow&date=20090501&stock=QQQQ&format=CSV&compression=stream
Use this method to obtain the list of available dates for the requested data type as a text file.
Parameter |
Description |
Values |
type |
Type of data for which the date availability is requested |
"orderflow" -- check dates for order flow
|
RETURNED VALUE |
The method returns the status using an HTTP status code,
with the list or an error message returned in the response body |
200 OK: the list is returned in the response body.
The generated list is a simple text file with line represending the date in YYYY-MM-DD format.
Each line is separated by CR-LF sequence (0x0D, 0x0A). A trailing CR-LF is added to the end of the list.
400 Bad Request: there was an error while processing the request.
A more detailed error message is returned in the response body in plain text.
|
Example
http://api.tradingphysics.com/getdates?type=orderflow
Use this method to obtain the data object in the specified format.
Please consult specifications for applicable data type and format.
Parameter |
Description |
Values |
t (required) |
Ticket (previously obtained by the
GetTicket method) |
Ticket value exactly as it was returned by the GetTicket method.
The current ticket values are GUIDs, however, this might change in the future.
|
type (required) |
Request the specified data types |
"orderflow" --
Order Flow data
"timesales" --
Time & Sales data
"indicators" --
Indicators data
"oscillators" --
Oscillators data
|
format (required) |
Retrieve data in the specified format |
The list of possible format values is below.
Please consult specifications of the requested data type what formats are supported.
"XML" -- XML
"CSV" -- CSV (comma separated values)
"TXT" -- TXT (formatted text with fixed-width columns)
"I40" -- TotalView-ITCH 4.0 native format.
Specifications
"BIN" -- binary format
|
compression (required) |
Compression data in the specified way |
"stream" -- compress HTTP response stream using GZIP content-enconding
"file" -- return file compressed in
.z8 format
"auto" -- compress HTTP response stream only if the browser accepts GZIP content-encoding ("stream"), otherwise compress the returned file ("file")
"none" -- do not use compression at all. This option must be used for streaming data (when keepconnection=true)
|
date (required) |
Target date for which the data is requested |
Date string in "YYYYMMDD" format. Use today's date for real-time streams.
|
stock (required) |
Stock ticker for which the data is requested |
Stock ticker with up to 6 characters in length
|
keepconnection (optional) |
true: streaming data
false: file data
Default: keepconnection=false
|
This option (keepconnection=true) can be used to retrieve data in real time when the requested date is equal to today's session.
This option instructs the server to keep the TCP connection open and keep sending the data or heartbeats if the data is not yet available.
The heartbeats (empty lines, 0x0D 0x0A) are sent every 1/2 second, so you can set the read timeout of your TCP client
at 1 second and reconnect if the timeout exception occurs due to a broken TCP session.
The server starts sending the heartbeats as soon as your client catches up with the realtime data, i.e. all prior ticks to the moment when the connection was established have been sent.
At the end of the session, the server will send a final heartbeat and will close the TCP connection.
Restrictions:
- Data stream is not compressed (compression=none)
- File formats other than CSV are currently not supported (format=csv)
Note: Please set KeepAlive property to true if you are using an HTTP request method in order
to ensure that your client will not close the connection after a certain period of time.
|
indicators (optional) |
Indicators to be retrieved |
List of indicators separated with "+".
If this parameter is not provided, the entire list of indicators will be returned.
The complete list of market indicators
|
oscillators (optional) |
Oscillators to be retrieved |
List of oscillators separated with "+".
If this parameter is not provided, the entire list of oscillators will be returned.
The complete list of oscillators
|
RETURNED VALUE |
The method returns the status using an HTTP status code,
with the data file or an error message returned in the response body |
200 OK: the data object is returned in the response body.
For historical files, the header will contain the fields that help save the file using a web browser in a user-friendly SAVE-AS fashion:
Content-Disposition: attachment; filename=FILENAME.EXT
Content-Type: application/octet-stream
For realtime streams, the Content-Type is set to text/plain, there is no Content-Disposition field,
and the connection is not immediately closed after the initial data is transferred. Instead, the server keeps the connection alive and
keeps sending data as it arrives in realtime from the exchanges. If no data arrives within 1 second, the server sends a hearbeat in the
form of an empty line (CR-LF) to signal that the connection is still alive. The client simply ignores all empty lines while parsing the incoming CSV or XML data in realtime.
400 Bad Request: there was an error while processing the request.
A more detailed error message is returned in the response body in plain text.
|
Example
Note: the ticket {00000000-0000-0000-0000-000000000000} used in this query is invalid. Please substitute your own valid ticket for this query to return data instead of an error message.
http://api.tradingphysics.com/getdata?type=orderflow&date=20090501&stock=QQQQ&format=CSV&compression=stream&t={00000000-0000-0000-0000-000000000000}
Use this method to obtain a picture of a chart.
Parameter |
Description |
Values |
type |
Chart type |
"PI" -- Price & Indicators Chart
|
indicators |
Indicators on the chart |
List of indicators separated with "+". This parameter can be skipped if no additional indicators requested.
Note: since the chart prints both Buy and Sell side indicators, the .Buy. and .Sell. part of the indicator name
must be replaced with .$. The system will automatically replace $ with "Buy" and "Sell" and thus create the view
for both sides of the book. Please consult
Market Indicators Overview for further details.
|
date |
Target date for which the chart is requested |
Date string in "YYYYMMDD" format. Use today's date for real-time streams
|
stock |
Stock ticker for which the data is requested |
Stock ticker with up to 6 characters in length
|
days |
The number of days to show on the chart |
The number of days in numerical format
|
RETURNED VALUE |
The method returns the status using an HTTP status code,
with the chart or an error message returned in the response body |
200 OK: the data object is returned in the response body as a PNG image.
The response header will contain the Content-Type field set to image/png to allow proper display by a web browser:
Content-Type: image/png
If an error occured while generating the chart, the chart will contain an error message.
400 Bad Request: there was an error while parsing the request.
A more detailed error message is returned in the response body in plain text.
|
Example
http://api.tradingphysics.com/getchart?type=pi&date=20090501&indicators=MarketIndicator.$.Executed.VolumeA&stock=SPY&days=1
|