Do I have to re-authenticate for each request?

Created at 08 Aug 2023, 01:15
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TH

the.innovative214

Joined 06.04.2022

Do I have to re-authenticate for each request?
08 Aug 2023, 01:15


Hello… I am very new at this and I have been able to authenticate and pull open/close/low/high data in a ctrader-open-api python script. Problem is lag because I authenticate each and every time I ask for candle data for a forex pair. Is there a way to somehow not have to reauthenticate each time once I have authenticated once?

 

Plus, how long is a connection allowed to stay open for to process other requests?


@the.innovative214
Replies

PanagiotisChar
08 Aug 2023, 05:41

Hi there,

You only need to authenticate once. Then make sure the connection stays open by sending heartbeats.

Aieden Technologies

Need help? Join us on Telegram


 


@PanagiotisChar

the.innovative214
08 Aug 2023, 15:57

RE: Do I have to re-authenticate for each request?

PanagiotisChar said: 

Hi there,

You only need to authenticate once. Then make sure the connection stays open by sending heartbeats.

Aieden Technologies

Need help? Join us on Telegram


 

That's great. Can you direct me into the direction on how to do that? I was thinking to have it run with a cron job on my server on certain intervals and for it to run my python script. It could be frequent so I want to avoid having to log in each time but I have not figured out how to keep the connection persistent especially if I am running a python script on certain time intervals to pull data. Again I am very new at this sort of thing.


@the.innovative214

PanagiotisChar
09 Aug 2023, 05:30

Hi there,

Check the Python sample below. It should be helpful

https://github.com/spotware/OpenApiPy

Aieden Technologies

Need help? Join us on Telegram


@PanagiotisChar

the.innovative214
14 Aug 2023, 20:44

RE: RE: Do I have to re-authenticate for each request?

the.innovative214 said: 

PanagiotisChar said: 

Hi there,

You only need to authenticate once. Then make sure the connection stays open by sending heartbeats.

Aieden Technologies

Need help? Join us on Telegram


 

That's great. Can you direct me into the direction on how to do that? I was thinking to have it run with a cron job on my server on certain intervals and for it to run my python script. It could be frequent so I want to avoid having to log in each time but I have not figured out how to keep the connection persistent especially if I am running a python script on certain time intervals to pull data. Again I am very new at this sort of thing.

Still looking for an answer to this if anyone has any ideas…


@the.innovative214

PanagiotisChar
15 Aug 2023, 05:29

RE: RE: RE: Do I have to re-authenticate for each request?

the.innovative214 said: 

the.innovative214 said: 

PanagiotisChar said: 

Hi there,

You only need to authenticate once. Then make sure the connection stays open by sending heartbeats.

Aieden Technologies

Need help? Join us on Telegram


 

That's great. Can you direct me into the direction on how to do that? I was thinking to have it run with a cron job on my server on certain intervals and for it to run my python script. It could be frequent so I want to avoid having to log in each time but I have not figured out how to keep the connection persistent especially if I am running a python script on certain time intervals to pull data. Again I am very new at this sort of thing.

Still looking for an answer to this if anyone has any ideas…

Hi there,

Did you check the Python samples on GitHub? They should contain an implementation for heartbeats. In any case, it should not be complicated. You just need to send the heartbeat message every 10 seconds. 

Aieden Technologies

Need help? Join us on Telegram


 


@PanagiotisChar