Get Query ID (Activity Flex Query ID)
The Query ID is a unique identifier that tells the IBKR system exactly which data points to retrieve—such as trades, cash transactions, or account balances—via the Flex Web Service.
1. Log in to the Client Portal:
Start by logging into your Interactive Brokers Client Portal.
2. Navigate to Flex Queries:
Go to the main menu and select "Performance & Reports" > "Flex Queries".
3. Add a Flex Query:
Click the plus "+" icon located next to Activity Flex Query.
4. Create "Activity Flex Query":
Name your query in the Query Name (e.g., "trades_report").
Under the Sections menu, choose the data you require, such as Trades.
Ensure you click Select all for the necessary fields within each section.
In "Delivery Configuration",
"Format" field, choose "CSV".
"Include column headers", choose "Yes".
"Period", select the time range you want to cover (e.g., Last 365 Calendar Days or Year to Date).
In "General Configuration",
"Date Format" choose "yyyyMMdd".
"Time Format" choose "HHmmss".
"Date/Time Separator" choose "; (semi-colon)".
Click "Continue", to final review the setting.
Click "Create" to confirm the setting.
5. Locate the Created Query:
You should able to see the complete page, click "Ok" to finish.
You will return to the main Flex Queries page. Your new report will now be listed under the "Activity Flex Query" section.
6. Retrieve the "Query ID":
Click the information ("i" icon) icon located to the left of your query's name.
A pop-up will appear. Copy the "Query ID" number displayed at the top.