The Intrade API consists of two parts:
Users of the API must agree to the terms of usage which are available online at the following location: http://www.intrade.com/v4/misc/help/api-tacs/
If a user fails to abide by the Terms and Conditions or contravenes the Acceptable usage policy in this document, Intrade reserves the right to restrict access to the API at any time and without notice.
Retrieving market data for intrade is a two step process.
This is a list of all active contract and contracts that have expired(settled) within the last 24hrs.
http://api.intrade.com/jsp/XML/MarketData/xml.jsp
The xml document is arranged in a hierarchical structure as follows:
To find the contract you are interested in, move down the tree searching for the relevant branch. Once you find a contract, you can find its ID and use this get market data using the market data interface.
Note: If you only need a list of contracts in a single class (e.g. Financials) then a subset of the contracts can be requested using the XMLForClass.jsp (see below).
Example response:
To get a list of contracts in a specific class use the following url: A subset of this data based on EventClass(e.g. Politics, Financial etc.) can be requested with the following url:
http://api.intrade.com/jsp/XML/MarketData/XMLForClass.jsp?classID=X
where X is the id of the EventClass. E.g.:
http://api.intrade.com/jsp/XML/MarketData/XMLForClass.jsp?classID=19
This will bring back a document containing Political contracts only.
Current price information is retrieved using the ContractBookXML.jsp.
http://api.intrade.com/jsp/XML/MarketData/ContractBookXML.jsp
Parameters:
Example:
http://api.intrade.com/jsp/XML/MarketData/ContractBookXML.jsp?id=743474&id=749429×tamp=0
Example response:
Other contract data can be retrieved using ConInfo.jsp.
http://api.intrade.com/jsp/XML/MarketData/ConInfo.jsp
Parameters:
Example:
http://api.intrade.com/jsp/XML/MarketData/ConInfo.jsp?id=743474
Example response:
Historical closing price and session hi/lo data can be retrieved using the following ClosingPrice.jsp page.
http://api.intrade.com/jsp/XML/MarketData/ClosingPrice.jsp
Parameters:
Example:
http://api.intrade.com/jsp/XML/MarketData/ClosingPrice.jsp?conID=743474
Example response:
Time and Sales data information is retrieved using the TimeAndSales.jsp. You can get data for the last 24 hours only.
https://api.intrade.com/jsp/XML/TradeData/TimeAndSales.jsp?conID=XXX
Parameters:
Output:
The data is returned in CSV format.
The format is:
Timestamp in ms, GMT Data/Time, Trade Price, Trade Quantity.
Example:
https://api.intrade.com/jsp/XML/TradeData/TimeAndSales.jsp?conID=749429
Example response:
This document explains the usage of the xml interface to the intrade system. It does not explain the working of intrade exchange, so users should be familiar with normal usage (using html interface) before attempting to use this interface.
Requests should be posted over http using SSL.
The url that will handle requests on LIVE system is:
https://api.intrade.com/xml/handler.jsp
Requests are posted to the intrade site as xml with the following format:
The response is an XML document with the following format.
In a case of error during the following error response is generated.
Use to login to get valid sessionData and username.
Request format:
Response Example:
Use to get frozen and available cash balances.
Request format:
Response Example:
Use to enter new orders into the exchange.
Request format:
Request Example:
The response contain information about all new orders entered.
Response Example:
Use to cancel open orders.
Request format:
Request Example:
Used to cancel all orders, bids or offers in the specified contract.
Request format:
Request Example:
Used to cancel all orders in an event. The eventID can be retrieved from the all contracts xml tree.
Request Example:
Used to cancel all orders for a user. This cancels all open orders in all contracts.
Request Example:
Used to get all positions for a user or positions for the specified contract IDs.
Request Example:
Response Example:
Used to get open orders.
Request Example:
Response Example:
Used to get orders for a user by order ID.
Request Example:
Response is the same as for getOpenOrders operation.
Used to get trading notifications for a user. This will return the last 50 messages on a users account.
Request format:
Response Example:
Used to delete trading notifications for a user.
Request format:
Request Example:
Used to get information on trades that have happened on user account This can take either a timestamp or a contract id. If a timestamp is passed in, then all trades on this account after the timestamp on all contracts are given. If a contract is given then all trades on this contract are returned regardless of time.
Request format:
Response Example:
Used to as a dummy request to check if the user has any trading messages. If the "checkMessage" element is set to "true" the response will contain the attribute "hasMessages" IF the user has unread messages.
Request format:
Response Example:
Misuse of the API provided by Intrade could result in performance problem on the exchange due to flooding the exchange’s web-servers and/or database with unnecessary requests. Therefore the rules outlined in this document should be followed by anyone intending to use the API. Applications that do not conform to these rules will be blocked by the exchange, possibly without warning. Access to the exchange will only be re-allowed after the application has been demonstrated to conform using the Intrade test exchange. This will be a lengthy process, so it is in the interests of application writers to make sure their systems comply from the beginning. If there is any doubt, please contact the exchange before running code on the live system.
This document outlines the basic rules. However, if at any point an application is deemed to be putting unnecessary load on the Intrade servers then it may be blocked without notice.
There are many users of the API putting many millions of requests through the Intrade systems every day. No reasonable use of the API should result in loss of access.
As this is a large file, this should only be retrieved at start-up and not more than one time per 15 minutes.
Applications should be designed to cache information regarding an account. Information on an account (i.e. balance, positions, orders, trades) will only change when an order is entered, cancelled, expired or a trade occurs. Therefore this information should only be requested at start-up or when either orders have been entered or when a user message is detected. Continuous unnecessary requests for positions, orders or trades will result in the client being blocked.
In order to detect that a trade has occurred on an account, the user’s messages should be checked.
N.B. Orders are permitted via automated order entry practices [through the Exchanges application programmable interface (API) or otherwise]. The Exchange reserves the right to prohibit small-automated orders (9 lots and less) immediately ahead of non-automated orders.
We also have a test system available http://testexternal.intrade.com. Please feel free to open as many accounts as you need on this system. Your test account will be credited with $10,000 for testing.
The url that will handle requests on TEST system is:
http://testexternal.intrade.com/xml/handler.jsp
Requests to test system cannot use SSL.
Note: Markets on test system use different IDs.