Monitoring stock market activity is not only about observing price movements but also understanding trading activity and corporate actions. Broker transaction data can provide an overview of market participation, while corporate action schedules help investors identify important company events that may influence investment decisions.
Two datasets that are useful for this purpose are Top Brokers and Bonus Calendar. Top Brokers data shows the brokers with the highest trading activity during a selected period, while Bonus Calendar provides information about companies distributing bonus shares.
In this project, we build an IDX Broker and Bonus Calendar Dashboard using Python and the Indonesia Stock Exchange API. The notebook retrieves Top Brokers data and Bonus Calendar data, processes the responses, and displays the information through a simple dashboard interface.
The notebook is divided into five main sections. The first section imports the required libraries, followed by API configuration, helper functions, data retrieval, and dashboard generation.
What This Project Builds
This project creates an IDX Broker and Bonus Calendar Dashboard that combines:
Top Brokers data
Bonus Calendar data
Structured dataframe output
Broker activity monitoring
Corporate action monitoring dashboard
By combining both datasets into a single workflow, users can review broker activity together with bonus share information through one dashboard.
CELL 1 — Import Required Libraries
import requests
import pandas as pd
import time
from IPython.display import display, Markdown
pd.set_option("display.max_columns", None)
pd.set_option("display.width", 1000)Explanation
The project begins by importing the required libraries.
The requests library is used to communicate with the IDX API. The pandas library processes and displays structured data. The time library creates delays between API requests, while display and Markdown provide a cleaner presentation inside Google Colab.
The notebook also configures pandas display settings so that all available columns can be displayed more clearly.
CELL 2 — Configure API Connection
BASE_URL = "https://indonesia-stock-exchange-idx.p.rapidapi.com"
HEADERS = {
"Content-Type": "application/json",
"x-rapidapi-host": "indonesia-stock-exchange-idx.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY"
}Explanation
Cell 2 contains the API configuration used throughout the notebook.
The BASE_URL variable stores the IDX API endpoint, while HEADERS contains the request configuration required to communicate with the Indonesia Stock Exchange API.
These settings are reused whenever the notebook requests Top Brokers data and Bonus Calendar data.
CELL 3 — Create Helper Functions
def fetch_api(endpoint, retries=3, delay=5):
url = BASE_URL + endpoint
for attempt in range(retries):
try:
response = requests.get(
url,
headers=HEADERS,
timeout=30
)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
print(f"Rate limit reached. Waiting {delay} seconds...")
time.sleep(delay)
else:
print(f"Request failed: {response.status_code}")
print(response.text)
return None
except Exception as e:
print("Error:", e)
time.sleep(delay)
return None
def extract_list(data):
if data is None:
return []
if isinstance(data, list):
return data
if isinstance(data, dict):
for key in [
"data",
"result",
"results",
"items",
"brokers",
"bonus",
"bonus_calendar"
]:
if key in data and isinstance(data[key], list):
return data[key]
return [data]
return []Explanation
Cell 3 creates helper functions that are used throughout the project.
The fetch_api() function retrieves data from the IDX API. The function includes retry handling so the notebook can continue requesting data whenever temporary errors or rate limits occur.
The extract_list() function is designed to retrieve the primary list from different API response structures. This makes the notebook more flexible when processing Top Brokers data and Bonus Calendar data returned by the API.
CELL 4 — Retrieve Data from IDX API
display(Markdown("## 📥 Fetching Data from IDX API"))
top_brokers_raw = fetch_api(
"/api/market-detector/top-broker?marketType=MARKET_TYPE_ALL&period=TB_PERIOD_LAST_1_DAY&order=ORDER_BY_ASC&sort=TB_SORT_BY_TOTAL_VALUE"
)
time.sleep(5)
bonus_calendar_raw = fetch_api("/api/calendar/bonus")
display(Markdown("✅ Data retrieval completed"))Explanation
Cell 4 retrieves the datasets required to build the dashboard.
The notebook begins by displaying a message indicating that the data retrieval process has started. It then requests Top Brokers data from the IDX API using the market detector endpoint. The request specifies the market type, period, sorting method, and order directly through the endpoint parameters.
After retrieving the Top Brokers data, the notebook waits for five seconds using time.sleep(5) before sending another request. This delay helps reduce the possibility of encountering API rate limits.
The second request retrieves Bonus Calendar data from the Indonesia Stock Exchange API. The response is stored in bonus_calendar_raw and will later be processed inside the dashboard.
Finally, the notebook displays a confirmation message indicating that the data retrieval process has been completed successfully.
CELL 5 — Dashboard Output
display(Markdown("# 📊 IDX Broker and Bonus Calendar Dashboard"))
display(Markdown("Dashboard sederhana untuk membaca data Top Brokers dan Bonus Calendar dari Bursa Efek Indonesia."))
# =========================
# Top Brokers
# =========================
display(Markdown("## 🏆 Top Brokers by Trading Value"))
brokers = extract_list(top_brokers_raw)
if brokers:
df_brokers = pd.json_normalize(brokers)
numeric_cols = ["total_value", "totalValue", "value", "buy_value", "sell_value", "net_value"]
for col in numeric_cols:
if col in df_brokers.columns:
df_brokers[col] = pd.to_numeric(df_brokers[col], errors="coerce")
sort_candidates = ["total_value", "totalValue", "value"]
for col in sort_candidates:
if col in df_brokers.columns:
df_brokers = df_brokers.sort_values(by=col, ascending=False)
break
display(Markdown(f"Jumlah broker yang berhasil ditampilkan: **{len(df_brokers)} broker**"))
display(df_brokers.head(20))
else:
display(Markdown("Tidak ada data Top Brokers."))
# =========================
# Bonus Calendar
# =========================
display(Markdown("## 🎁 Bonus Calendar"))
bonus_data = extract_list(bonus_calendar_raw)
if bonus_data:
df_bonus = pd.json_normalize(bonus_data)
selected_cols = [
col for col in df_bonus.columns
if any(keyword in col.lower() for keyword in [
"symbol", "company", "date", "ratio", "bonus", "share", "cum", "ex", "record"
])
]
if selected_cols:
df_bonus = df_bonus[selected_cols]
display(Markdown(f"Jumlah data Bonus Calendar yang berhasil ditampilkan: **{len(df_bonus)} data**"))
display(df_bonus)
else:
display(Markdown("Tidak ada data Bonus Calendar."))
display(Markdown("✅ Dashboard berhasil dibuat."))Explanation
Cell 5 builds the final IDX Broker and Bonus Calendar Dashboard.
The dashboard begins by displaying the main title together with a short description explaining that the dashboard is designed to read Top Brokers data and Bonus Calendar data from the Indonesia Stock Exchange.
The first section focuses on Top Brokers by Trading Value. The notebook extracts the broker data using the extract_list() helper function. If broker data is available, the response is converted into a dataframe using pd.json_normalize().
Several trading value columns, including total_value, buy_value, sell_value, and net_value, are then converted into numeric values. This conversion allows the notebook to sort the data correctly.
The notebook checks several possible sorting columns and sorts the dataframe in descending order using the first available trading value column. After sorting, the dashboard displays the total number of brokers retrieved together with the first twenty broker records.
If broker data is unavailable, the dashboard displays a message indicating that no Top Brokers data is available.
The second section focuses on Bonus Calendar data. The notebook extracts the data using the same helper function and converts the response into a dataframe.
To make the output easier to read, the notebook filters important columns related to company symbols, company names, dates, ratios, bonus information, shares, cum dates, ex dates, and record dates.
The dashboard then displays the total number of Bonus Calendar records together with the resulting dataframe.
If Bonus Calendar data is unavailable, the notebook displays a message indicating that no Bonus Calendar data is available.
Finally, after both sections have been completed successfully, the notebook displays a confirmation message indicating that the dashboard has been successfully created.
Result:

Dashboard Output
Top Brokers by Trading Value
The dashboard displays Top Brokers information retrieved from the Indonesia Stock Exchange API.
If broker data is available, the notebook converts the response into a dataframe, converts trading value columns into numeric format, sorts the brokers based on trading value, and displays the first twenty records together with the total number of brokers retrieved.
Bonus Calendar
The dashboard also displays Bonus Calendar information returned by the IDX API.
If bonus calendar data is available, the notebook converts the response into a dataframe and filters important columns related to company symbols, company names, bonus information, ratios, shares, and important corporate action dates before displaying the result.
Overall Workflow
Import the required libraries.
Configure IDX API access.
Create helper functions for API communication and data extraction.
Retrieve Top Brokers data.
Retrieve Bonus Calendar data.
Convert API responses into pandas dataframes.
Convert trading value columns into numeric format.
Sort broker data by trading value.
Filter important Bonus Calendar columns.
Display both datasets through the dashboard.
Why This Project Matters
Broker activity and corporate action information are important components of market analysis.
Top Brokers data provides insight into trading activity based on transaction value, while Bonus Calendar data provides information about bonus share distributions announced by listed companies.
By combining both datasets into a single dashboard, users can monitor trading activity and corporate actions simultaneously through one workflow.
Conclusion
The IDX Broker and Bonus Calendar Dashboard demonstrates how Python can be used to retrieve, process, and display Top Brokers data together with Bonus Calendar data from the Indonesia Stock Exchange API.
The notebook combines broker activity information and bonus share schedules into a structured dashboard, making the information easier to review inside Google Colab.
