Help getting started with OpenAPI Python

Created at 28 May 2023, 03:14
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!
AD

adrian.buzatu

Joined 28.05.2023

Help getting started with OpenAPI Python
28 May 2023, 03:14


Hello, 

I have two demo accounts in cTrader (IC Markets and ICM Capital). I would like to build a hello world that from Python on my computer sets an order to buy 0.01 lot of XAUUSD at market price, with a given target price and stop loss. I would like ot use Open API in Python. I read the documentation and I applied for an OpenAPI application a few days ago, but I do not have an answer yet.  I did not set any Redirect URI, as I did not know how to choose one. I am not sure why an approval is needed, as the documentation says it is a free API to use, to build applications. I do ont want to build a full application, but just locally to build some signals and then place and close the trades automatically. Would you please be able to help me get started?

Thank you very much,

Adrian


@adrian.buzatu
Replies

adrian.buzatu
02 Jun 2023, 13:05

Hello, does anyone have a hello world example how to get started to get the OpenAPI token approved?


@adrian.buzatu

adrian.buzatu
03 Jun 2023, 10:33 ( Updated at: 21 Dec 2023, 09:23 )

RE:

Hello, thank you. I know that page and I tried the code, but I am not sure what these credentials mean and how to get them.

```

request.clientId = "Your application Client ID"
request.clientSecret = "Your application Client secret"

```

By my application does it mean my cTrader demo account for the FixAPI?

I guess not and OpenAPI I need to get a key from cTrader? I read here 

That I need to

> After deciding the purpose of your application and its key functionality, you should be ready to register the service at the cTrader Open API Portal. You can read a detailed overview of this process in a separate guide.

I did that and I have an application for one week with no answer. Here is what I asked. I am not clear what they actually want. I do not build a formal app for others. Just for me to be able to place and close some trades. They ask for a redirect URI. What is a redirect URI and where it is needed? I could run my script from my computer, or from a VPS server, so the IP would change. 

After we set this up, the webside does not show an example how to actually place a buy market trade with a target price and stop loss. It just has an example of how to connect to the server. A complete hello world example would be very useful to me how to get started. After that I can develop in Python further. 

If there is a way I can have a short call with someone, or even a live chat, that would be very useful to me. Thank you, 

Adrian


@adrian.buzatu

raypang
23 May 2024, 08:50 ( Updated at: 23 May 2024, 09:42 )

redirect url is your server's api, for example yourhost.com/auth

in the  auth process, ctrader will send authcode to yourhost.com/auth, 

with that  authcode, you can request your token

so you have to deploy a simple server to get that authcode.

I done this using vercel's free host. 

I wrote a simple python server with flask, within 100 lines of code.


@raypang