Jump to content

Recommended Posts

Hello, 

Based on the GainCapital Authentication API documention  I am trying to test the Logon API with Python which I'm expecting to receive ApiLogOnResponseDTO however, I am getting the 400 HTTP response. 

Just to troubleshoot this issue I used Postman to see if I get the same error but it appears everything works just fine. Please see the attached screenshot. 

Here is my Python code. 

import requests
 
url = 'https://ciapi.cityindex.com/TradingAPI/session'
login_request_body = {'Password''xxxxxxxxxx''UserName''xxxxxxxxxx''AppKey''xxxxxxxxx' }
login_response = requests.post(url, data = login_request_body)

and here is the response I get 

PS C:\Code> python3.8.exe .\authapi.py

                               <Response [400]>

That being said I would like to know if there is any documentation that can provide us the sample codes in Python. I have seen such documentation for other Forex brokers such as OANDA . 

 

 

 

Postman request.png

Share this post


Link to post

Hello,

We do not have an official Python library to use with the API and we cannot troubleshoot Python coding. 

Another user in the past was working with the API with Python and very kindly shared their unofficial library on the forum: 

 

The library might be helpful to get you started.

Kind Regards, PM

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×