- Solve real problems with our hands-on interface
- Progress from basic puts and calls to advanced strategies
Lesson 1 of 11
Hello, and welcome to this lesson the Interactive Brokers Client Portal API. In this lesson, we will be discussing what the Client Portal API is, why an individual may use it, and more.
To begin, the Client Portal API is a RESTful API which allows you to make requests to the Interactive Brokers’ systems using standard http requests over the internet as opposed to using a local TCP socket. This system allows for a lightweight application with minimal installation required. The only required prerequisites to run and operate the API is a modern Java installation to run the gateway along with a command prompt. However, in the case of this course’s examples, you will also need to have Python 3 installed, along with the ‘requests’ library. We will also make frequent references to the Python’s JSON standard library; however, this is not required other than general formatting.
I would like to note that we will be proceeding through this series using Python and the ‘requests’ module. Because these requests are referring to standard web requests like a URL, body, or other common fields, these calls are not unique to Python. The same calls can be performed using CURL requests directly, through Javascript, C#, or any other language that supports web requests. If you are more experienced with another, feel free to follow along in your preferred language.
With that said, I would like to provide a few details regarding the use of the Client Portal API rather than the Trader Workstation API. As stated previously, a particular benefit to the Client Portal API, or CPAPI, is the lightweight nature. Without the need to operate the Trader Workstation, we can run a range of code with less demanding hardware requirements. However, it is important to note that the system is much younger than the Trader Workstation API, and while it does have many of the same features, it may not have full parity quite yet. We are adding new data and endpoints all the time, so while something may not exist yet, that does not mean it will not be coming soon.
Thank you for watching this Introduction to the Interactive Brokers Client Portal API. If you found this lesson helpful, please check out our other lessons in the Client Portal API tutorial series.
https://www.interactivebrokers.com/en/trading/ib-api.php
https://download2.interactivebrokers.com/portal/clientportal.gw.zip
https://interactivebrokers.github.io/cpwebapi/
https://www.interactivebrokers.com/api/doc.html
For specific platform feedback and suggestions, please submit it directly to our team using these instructions.
If you have an account-specific question or concern, please reach out to Client Services.
We encourage you to look through our FAQs before posting. Your question may already be covered!
The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
The views and opinions expressed herein are those of the author and do not necessarily reflect the views of Interactive Brokers, its affiliates, or its employees.
Please keep in mind that the examples discussed in this material are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.
It help a lot. I understand the content
We’re glad to hear that, Vusumuzi.
It help a lot. I understand the content
This was helpful
This was helpful and insightful to me
Thank you, Mohamed. We are glad you found the content helpful! Be sure to check out other lessons on IBKR Campus.
I’m a rookie on this things. I hope I’ll come alright.
Hello Walter, thank you for reaching out. Feel free to review the IBKR Campus. Here you can learn about trading, financial markets and Interactive Brokers trading tools. This could be a great resource for you!
https://www.interactivebrokers.com/campus/
Please reach back out if you have more questions. We are here to help!
The strikes endpoint does not return call and put values
Running the following code:
base_url = “https://localhost:5001/v1/api/”
endpoint = “iserver/secdef/strikes”
conid = “conid=44652000”
# conid = “conid=669788897”
secType = “secType=OPT”
month = “month=JAN24”
exchange = “exchange=NSE”
params = “&”.join([conid, secType, month, exchange])
request_url = “”.join([base_url, endpoint, “?”, params])
strikes_req = requests.get(url=request_url, verify=False)
print(strikes_req)
Returns:
{‘call’: [], ‘put’: []}
For the conid I tried passing the underlying conid(44652000) as well as the options(669788897) conid but I got empty response for both.
And on trying exchange as HK.NSE, I get a server error 503.
Hello, thank you for reaching out. Calls to the /iserver/secdef/strikes endpoints requires that users first call the /iserver/secdef/search endpoint for the underlying beforehand. This process is explained further in lesson 3, Contract Search, available here: https://www.interactivebrokers.com/campus/trading-lessons/contract-search/ We hope this helps!
Might be nice to mention that you can not place orders against a Lite account.
Hello Tom, we appreciate your feedback. At this time, APIs are not available for IBKR Lite accounts. Please view the link below to determine which plan is best for you:
https://www.interactivebrokers.com/en/index.php?f=45500
We hope this helps.
Great comment! Terrible to see after hour spend why API doesn’t work!
It will be probably yet another reason for get request: base_url = “https://localhost:5000/v1/api/” endpoint = “iserver/auth/status” Resource not found
Is it possible to test the APIs on the client portal? Could you please provide the URL? Specifically looking to try out order APIs.
Hello, thank you for reaching out. Please view this link to download Client Portal API: https://www.interactivebrokers.com/en/trading/ib-api.php. We hope this helps!
Hi, do you have a regular REST API available without a gateway? That is, I would like to connect to your server, authenticate and perform requests – regular REST, without installing Java, gateways and similar. I assume this gateway connects somewhere anyway – is that endpoint publicly available? If not, is there some other API that can be used without installing additional software locally? (mainly interested in easier account management and asset monitoring, not placing trades). Thank you!
Hello, thank you for reaching out. Customers affiliated with an Institution can sign up for OAuth access with the REST API. While the endpoints are identical for both systems, the two differ in the authentication method of access tokens or the gateway. You can read more about this in our OAuth documentation on IBKR Campus.
For individuals unaffiliated with an organization, users would need to use either the Trader Workstation API or Client Portal API for real-time position updates. If you are planning to calculate positions locally, and simply need to verify data at market open or close, you may be interested in the Flex Web Service, which utilizes our Flex Queries from the Client Portal as web requests. You can read more in our Flex Web Service documentation. If this does not answer your question, please create a web ticket for this inquiry; we have a category specifically for “API.” One of our API experts will be happy to guide you! https://ndcdyn.interactivebrokers.com/AccountManagement/AmAuthentication?loginType=1&action=CS_WEB_TICKET&loginType=1
Hello, thank you for your response! Since I don’t want to install anything locally, I have in the end decided to work with CSV exports instead and just parse data from there. It’s not auomatic, unfortunately, but will suffice for my use case. Thank you!
Hello, I have a question i am trying to write named httpclient in c# but for all Session endpoints request i got 403 response even if i disable certificate validation in httphandler. (This question is not related to named client but generally to HttpClient). Now i really don’t know i can login i can send 200 request through Postman/Insomnia also in python but i can’t do that in .Net. Do you have any recommendation for .Net setup? I read that i should provide UserAgent header but even if i do it doesn’t solve issue. I really cannot find anything useful on web only python but i would like to avoid using python since most of other project libs are c# and c++ and using python would bring other issues later on in project. Thanks a lot
Hello, we appreciate your question. The cause of this error can vary. Given the 403 error, it could be connected to the request causing the issue. We recommend creating a web ticket for this inquiry; we have a category specifically for “API.” One of our API experts will be happy to guide you! https://www.interactivebrokers.com/sso/resolver?action=NEW_TICKET
Does graphQL is required for creating this APIs for the client portal API??
Hello Aritrya, the Client Portal API does not require GraphQL. Please reach back out with any more questions. We are here to help!
Hii…iam new to api, but i need to fetch live streaming data through web api, kindly help me in authenticating and fetching real time data, thanku.
Sorry, I did not understand anything. Not being a software engineer I am at a loss what I am to understand or to do. If this is the introduction I am really curious what comes next … I just tried to start a watchlist. But even that was not possible. It said: Add a symbol. Without mentioning what kind of symbol is possible or what it is for. Where can I really start from scratch???
Hello, thank you for asking. For hands on assistance, please create a web ticket for this inquiry; we have a category specifically for “API.” One of our API experts will be happy to guide you! https://spr.ly/IBKR_ClientServicesCampus
We would like to help you get started!
You may try to use a Gpt client as your software engineer I think.
Hello. One question: Can I input my own scan criteria directly into IBKR Desktop Platform to scan a market, similar to the way a StockCharts.com provide on their platform? Here is one example of a custom criteria that I’m referring to: [type = stock] and [Country is US] and [SMA(14, Volume) > 1,000.000.00] and [Close > 10.00] and [ATR(14) / Close > MV]. Can this be done? Thanks in advance. (Note: MV stands for Min Volatility for SPX.)
Hello Jovan, thank you for reaching out. IBKR Desktop supports Market Screeners, which can filter market data. Please view this IBKR Campus course for instructions: https://www.interactivebrokers.com/campus/trading-lessons/ibkr-desktop-market-screeners/
We hope this helps!
Hi, pls what data subscription do I need for API access? Just got an error Error 10089, reqId 3: Requested market data requires additional subscription for API. See link in ‘Market Data Connections’ dialog for more details.Delayed market data is available.VALE NYSE/TOP/ALL, contract: Stock(symbol=’VALE’, exchange=’SMART’, currency=’USD’) I already have paid data on my account. thx
Hello, thank you for asking. US Stock Market Data will require a Network market data subscription when direct routing. Please be aware that SMART routing will include market data form all Network exchanges, and as a result will need a market data subscription for the other networks if you have not already subscribed. For further assistance, please call in to our Customer Service desk for sensitive account and user related inquiries: https://spr.ly/IBKR_ClientServicesCampus