Terminology and disconnect events.
Terminology and disconnect events.
31 Jan 2022, 10:49
Hello, I am responsible to integrate my company with Open API and I am a bit confused with terminology used in cTrader.
As well as I understand we have:
1) accounts
2) applications
I asume that correlation between them is as follow:
Account 1 <----------> N Applications
Application 1 <----------> N Connections (max 25 according to limitations in docs).
Am I right?
Assuming that I have 1 account, 2 applications and 3 connections per application when and on which connection should I send ProtoOAApplicationAuthReq and/or ProtoOAAccountAuthReq and when I should drop and create new connection if below events has been send:
- ProtoOAAccountDisconnectEvent (Event that is sent when the established session for an account is dropped on the server side. A new session must be authorized for the account.)
- ProtoOAClientDisconnectEvent (Event that is sent when the connection with the client application is cancelled by the server. All the sessions for the traders' accounts will be terminated.)
- ProtoOAAccountsTokenInvalidatedEvent (Event that is sent when a session to a specific trader's account is terminated by the server but the existing connections with the other trader's accounts are maintained.)
And based on the above I have one additional question if client and application are synonims?
Thank you in advance.
amusleh
01 Feb 2022, 08:46
Hi,
To use Open API you need an API application, there is no relation between an API application and cTrader trading accounts.
You can use an API application to access as many cTrader trading accounts you want to from different or same cTrader IDs.
Now, the first thing you do after opening a connection with Open API endpoints is to authorize an API application, for each connection you can only use one API application.
The authorization of your API application will tell the API server that your connection will use that application for it's life time, you can't send any other request to API server unless you first authorize an API application, to authorize your app you have to send a ProtoOAApplicationAuthReq, and once you received back a ProtoOAApplicationAuthRes it means your app is authorized and you can start interacting with API.
That was the first step, and as I said before there is no relation between a trading account and an API application.
After API application authentication you can start getting cTrader trading accounts data or execute trade operations on them, to do that you need an access token, the token will be given to your API application if a user authorized your app to access his cTrader trading accounts, for that check the documentation account authentication page.
After you got the token, you can start to use those authorized trading accounts, the first step is to send an account authentication request with account ID and access token,
You can send account auth request to any number of accounts, there is no limit, but your connection environment must match with account type, if your connected to live endpoint then you can only work with live accounts and if you are connected to demo endpoint then you can only work with demo accounts.
Once you received account auth response then you can start sending other requests related to that account, like getting account data or executing trades.
Now, regarding events:
Hopefully now it's much more clear for you.
If you had any other question let me know.
@amusleh