TradingView REST API Specification for Brokers
This API specification lets brokers build a bridge & connect their backend systems to TradingView, which acts as a frontend. The bridge built using this API specification can be used in 2 products — TradingView Web Platform & Trading Terminal. Check the info page for more info & email email@example.com with any questions.
This specification has been generated using outstanding Swagger technology. Swagger will do most of the work for you. Download TradingView Swagger specification, Copy-Paste it into Online Swagger Editor and generate a server using 1 of 26 frameworks.
Data & Order support vs Orders Only
When TradingView already has data that your customers will need (i.e. certain stocks, FX), you can do Orders Only option. This way you avoid having to supply your own data and about half the work. For the Trading Terminal you will always need to supply both data & order support, since it’s a standalone product that you host.
Trading Panel Bridge
1. Types of Requests
All requests can be divided into two groups — client and server.
Client requests are executed from the browser, server requests are initiated from the TradingView servers. There will be no server requests if the integration does not imply the addition of brokerage data to the TradingView website.
2. Client Requests
TradingView website sends out requests to the broker’s server from the browser to get a list of orders and positions, information about the balance, etc. The requests are sent out periodically and the intervals can be set using “/config”. After that, TradingView compares the new data with the previous answer and calculates the difference. If the status of the order / position changes or new data appears, then the user will see a notification and the changes made will display in the Account Manager on the website.
Requests for placing / modifying orders, cancellation of positions, etc. occur only after the user's actions.
Also, from the browser there is a request called “/quotes” which displays the current bid / ask from the broker and the request called “/depth” which retrieves the data from DOM Level 2.
3. Server requests (in the case of data integration)
Typically, a broker needs to connect its data to TradingView, if there are Forex or CFD among the symbols. In this case, you need to implement three additional endpoints: “/symbol_info”, “/history” and “/streaming”.
TradingView will send requests for data from its servers. Usually, at least 4 servers are used. The history is cached on TradingView servers and given to the client browser from our servers. The connection to “/streaming” is carried out continuously and resumes in case of a disconnection. The broker must remove unnecessary restrictions (firewall, rate limits, etc.) for the set of IP addresses of our servers.
4. Restricting access to data (in the case of data integration)
By default, broker symbols are visible to all TradingView users without any restrictions - you can view the ideas on them and they are available in the search for symbols. If there is a need to restrict access to them, then you need to further divide the entire set of symbols into groups. A group is a set of symbols that share a common access level. Any user can have access to any number of such groups. To do this, you need to implement “/groups” and “/permissions” requests. The “/groups” query allows you to specify a list of groups, and “/permissions” specifies which groups are available for a specific user. The same symbol cannot be in 2 different groups. At the request “/symbol_info” TradingView will add the GET argument “group“ with the name of the group, the list of which is provided by the request “/groups”. Thus, TradingView will receive information about which group each symbol belongs to. Each TradingView user logging into his broker account will gain access to one or more groups, depending on “/permissions”. It is important to note that groups cannot be deleted, you can only remove all the symbols from there, so grouping should be carefully planned. The number of groups for a specific integration is limited to 10. Maximum amount of symbols in a group is 10K.
How to use
Select your preferred integration option and click the appropriate sections to see the list of requests that need to be implemented. You will be able to see the parameters along with the responses by clicking on any available request.
Try It Out
You can send a request to our demo server and see a response as an example. Click the Try it out button, complete the required fields and click Execute afterwards. You should be able to see our server’s response to your request.
Please use 'test' as both the login and password in order to send the authorize request. Please use '0' as the numeric value for the accountId parameter in requests.