CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 66 % of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

Impossible Acces to DarwinTradingAPI with my Acces Token

Every request I’ve made return the following message:
“status”: “Investor account provided does not belong to the user.”

It’s like my Access Token is not match to my acounts ids.

1 Like

Hi Toneti777,

Could you try to make a call to GET /investoraccountinfo/investoraccounts’ with your token?

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer accessToken' 'https://api.darwinex.com/investoraccountinfo/1.0/investoraccounts'

If the token is valid then this method should return the investor accounts allowed to use with the token. It should be an id starting with 20… in Sandbox (demo accounts).

1 Like

Yes, It was my error on writing request on Python. Now I’ve receive this message…
415 Client Error: for url: https://api.darwinex.com/trading/1.0/investoraccounts/xxxxxxxxx/orders/buy

Hi Toneti777,
We have received several orders for your investor account in the back without issues and they were processed. It’s weird that you received a “client error”. Didn’t you receive additional details?

The orders without errors was send from Darwinex Api web site. I see that error when I use my python application.

I just found the error…
In python Request needs to put the body json data to x “json” parameter instead of “data” parameter.
response = requests.request(method=method, url=url, params=params, json=data,headers=headers)

Thanks for help.

1 Like

Hi!

Just in case it helps, I do it a bit differently.
Note this is a defined method inside a class and there are some variables as arguments.

url = self.url_trading + "/investoraccounts/{}/orders/sell"\ .format(self.id) h = self.base_headers data = json.dumps({ "amount": amount, "productName": name, "thresholdParameters": { "quoteStopLoss": sl, "quoteTakeProfit": tp } }) resp = requests.post(url, data=data, headers=h) print(resp.text)

1 Like