¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

How do you test the IB Gateway REST API in demo account?


 

When I start the Gateway Java server locally I get this message saying demo app is available at

I tried sending REST API requests to ?and it doesn't work.

I want to test my algorithmic trading system against the demo account placing orders in real time and seeing it work before risking real money.

Could someone point me to an online documentation or anything I can read up on to learn how to do this?


 

No intent to be pedantic but when you say "doesn't work" , you can guess that some people are able to make it working, so why don't tell us a little bit more ?
what did you do ? what did you expect ? what happens ?, etc ...

Did you read this one ?
and this one ?
A clue, a typical area of concern for the REST API that need a work/trial? investment: The authentication method.
It require great care for very legit reason, this is the REST API I know which are able to handle potentially the biggest amount of money I ever seen


 

I have only limited hands-on experience with the Client Portal API (it does not yet add anything that we can't do via TWS API already), but I think you have mixed up a couple things. If you have not done so yet, take a look at the and the explorer.

Any request you send to a URL that starts with "https://localhost:5000/" is handled by the Client Portal API Java gateway that ships with the Client Portal API installation. The gateway handles two kinds of requests:
  • REST requests through one of several API endpoints. All endpoint URLs start with "https://localhost:5000/v1/api/"
  • Requests for WebApps that you develop and install in the folder "root/webapps". URLs for WebApps start with "https://localhost:5000" followed by the WebApp name. The gateway simply serves those files to your browser.

The API ships with one WebApp called "demo". It consists of two files and is, consequently, installed under "root/webapps/demo"
  • root/webapps/demo/index.html
  • root/webapps/demo/gateway.demo.js

The message you get indicates that the gateway is ready to server the WebApp "demo". You start it by pointing your browser to "https://localhost:5000/demo", but the gateway has to be logged into an IBKR account for it to work. In case you have a funded live account at IBKR, you can create a companion "paper" account to try out your strategies.

I do not think that it is possible to connect a WebApp through the Client Portal API gateway to what the TWS application calls a "demo" account. The kind off account you can reach through the TWS application login screen where it says "No username? Try the demo".

Hope that helps,

´³¨¹°ù²µ±ð²Ô




On Fri, Oct 27, 2023 at 11:02 AM, Jimin Park wrote:
When I start the Gateway Java server locally I get this message saying demo app is available at

I tried sending REST API requests to ?and it doesn't work.

I want to test my algorithmic trading system against the demo account placing orders in real time and seeing it work before risking real money.

Could someone point me to an online documentation or anything I can read up on to learn how to do this?


 

Hi Jurgen,

Thanks for the tip. You answered exactly what I wanted to know. I wanted to connect to a paper trading account so I can start placing orders to it and test my algorithmic trading system working.

I logged into my IB live account on their web app, went to Settings > Paper Trading Account and got this screen.



1. I reset my password there for my paper trading account.
2. I went to ?to try to log into the paper trading account for my Gateway server.

However the Gateway tells me "Invalid username password combination".

So how do I create a session to the paper trading account (not the live account) for my Gateway server to start placing orders? I've tested all the REST API endpoints with the live accounts such as fetching contract details and historical marketdata. Everything is working... and now I just want to test placing orders.


 

Glad this helped and you are getting closer.

Pointing a browser to and logging in with your paper account credentials should work. At least it does for me Have you tried to log into the Client Portal or TWS/IBW with the paper account credentials?

When did you try this? IBKR is doing some major system maintenance this weekend and we had some outages already during the Friday night maintenance window. I have seen the error message "Invalid username password combination" for legitimate credentials in the past during times when IBKR maintains or resets the main servers.

Whatever works for your live account should work for the paper account/

´³¨¹°ù²µ±ð²Ô



On Sat, Oct 28, 2023 at 01:10 AM, Jimin Park wrote:
Hi Jurgen,

Thanks for the tip. You answered exactly what I wanted to know. I wanted to connect to a paper trading account so I can start placing orders to it and test my algorithmic trading system working.

I logged into my IB live account on their web app, went to Settings > Paper Trading Account and got this screen.

1. I reset my password there for my paper trading account.
2. I went to ?to try to log into the paper trading account for my Gateway server.

However the Gateway tells me "Invalid username password combination".

So how do I create a session to the paper trading account (not the live account) for my Gateway server to start placing orders? I've tested all the REST API endpoints with the live accounts such as fetching contract details and historical marketdata. Everything is working... and now I just want to test placing orders.


 

Hi Jurgen,

Yes, you are right. The demo login wasn't working, but I tried it just now, and it worked. I think it was the server maintenance that stopped me from logging in.
Thanks for helping me out.