Today Corporate Actions & Trending Stocks is a workflow that combines daily corporate action data and trending stock data from the IDX API.
Every trading day brings new opportunities and market-moving events. Investors often monitor two important sources of information: corporate actions and trending stocks.
Corporate actions provide insight into company activities that may influence shareholder value, while trending stocks help investors identify securities currently attracting market attention. When combined, these datasets can offer a broader picture of market activity and investor sentiment.
This notebook demonstrates how to retrieve Today Corporate Actions and Trending Stocks data from the IDX API, display the raw responses, transform them into structured dataframes, and generate a simple summary for analysis.
CELL 1 — Import Libraries
import requests
import pandas as pd
import time
from IPython.display import display, MarkdownExplanation
Cell 1 imports the Python libraries required throughout the notebook.
The notebook uses:
requestsfor API communication.pandasfor dataframe creation and data processing.timefor delay handling.displayandMarkdownfor notebook presentation.
These libraries provide the foundation for retrieving, organizing, and displaying data from the IDX API.
CELL 2 — API Configuration
RAPIDAPI_KEY = "YOUR_API_KEU"
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": RAPIDAPI_KEY
}Explanation
Cell 2 defines the API configuration.
The notebook stores the API key, base URL, and request headers required to access the Indonesia Stock Exchange API.
By centralizing these settings, all API requests can use the same configuration throughout the project.
CELL 3 — Create API Fetch Function
def fetch_api(endpoint, params=None, retries=3, delay=3):
url = f"{BASE_URL}{endpoint}"
for attempt in range(retries):
try:
response = requests.get(url, headers=HEADERS, params=params)
if response.status_code == 200:
return response.json()
print(f"Percobaan {attempt+1} gagal. Status Code: {response.status_code}")
print(response.text)
except Exception as e:
print(f"Terjadi error: {e}")
time.sleep(delay)
return NoneExplanation
Cell 3 creates a reusable function for retrieving data from the IDX API.
The function sends a request to the selected endpoint and returns the response in JSON format when the request is successful.
If an error occurs or the API returns an unsuccessful response, the notebook displays diagnostic information and retries the request after a short delay.
This retry mechanism helps improve reliability when communicating with the API.
The main objective of this Today Corporate Actions & Trending Stocks project is to retrieve and display both datasets in a single notebook.
CELL 4 — Retrieve Today Corporate Actions and Trending Stocks
today_corporate_actions = fetch_api("/api/calendar/today")
trending_stocks = fetch_api("/api/main/trending")
display(Markdown("## Data Corporate Actions Hari Ini"))
display(today_corporate_actions)
display(Markdown("## Data Trending Stocks"))
display(trending_stocks)Explanation
Cell 4 retrieves data from two IDX API endpoints.
The first endpoint retrieves corporate actions scheduled for the current day.
The second endpoint retrieves trending stocks currently attracting market attention.
After both API calls are completed, the notebook displays the raw responses directly inside the notebook using Markdown headings.
This step allows users to inspect the original API output before any transformation or analysis is performed.
CELL 5 — Convert API Responses into DataFrames and Create Summary
def normalize_to_dataframe(data):
if data is None:
return pd.DataFrame()
if isinstance(data, list):
return pd.json_normalize(data)
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, list):
return pd.json_normalize(value)
return pd.json_normalize(data)
return pd.DataFrame()
df_corporate_actions = normalize_to_dataframe(today_corporate_actions)
df_trending_stocks = normalize_to_dataframe(trending_stocks)
display(Markdown("# Hasil Analisis API IDX"))
display(Markdown("## 1. Corporate Actions Hari Ini"))
if df_corporate_actions.empty:
display(Markdown("Tidak ada data corporate action hari ini atau data gagal diambil."))
else:
display(df_corporate_actions)
display(Markdown("## 2. Trending Stocks"))
if df_trending_stocks.empty:
display(Markdown("Tidak ada data trending stocks atau data gagal diambil."))
else:
display(df_trending_stocks)
display(Markdown("## Ringkasan Data"))
summary = {
"Jenis Data": [
"Corporate Actions Hari Ini",
"Trending Stocks"
],
"Jumlah Data": [
len(df_corporate_actions),
len(df_trending_stocks)
]
}
df_summary = pd.DataFrame(summary)
display(df_summary)Explanation
Cell 5 transforms the API responses into structured dataframes and generates a simple summary.
The normalize_to_dataframe() function handles different response structures and converts them into pandas dataframes.
The notebook then creates:
df_corporate_actionsdf_trending_stocks
After conversion, the notebook displays the processed datasets.
If no data is available, a notification message is shown instead.
Finally, the notebook creates a summary dataframe containing:
Corporate Actions Hari Ini
Trending Stocks
Jumlah Data
This provides a quick overview of the datasets retrieved from the API.
Result:

This Today Corporate Actions & Trending Stocks workflow helps investors monitor market activity through two important IDX datasets.
OVERALL WORKFLOW
This notebook follows a simple market monitoring workflow.
First, it imports the required Python libraries.
Second, it configures API authentication and request settings.
Third, it creates a reusable API request function.
Fourth, it retrieves Today Corporate Actions and Trending Stocks data from the IDX API.
Fifth, it displays the raw API responses.
Finally, it converts the responses into structured dataframes and generates a summary report.
WHY THIS CASE MATTERS
Investors often need access to both corporate event information and market momentum indicators.
Corporate actions can influence shareholder decisions, while trending stocks may indicate increased market interest and trading activity.
By combining both datasets in a single workflow, investors can monitor daily market developments more efficiently and gain additional context for investment research.
CONCLUSION
This tutorial demonstrates how to retrieve and analyze Today Corporate Actions and Trending Stocks data using Python and the IDX API.
The notebook retrieves data directly from the API, displays the original responses, converts them into structured dataframes, and generates a concise summary for analysis.
The final workflow provides:
Today Corporate Actions monitoring
Trending Stocks monitoring
API response inspection
Dataframe transformation
Summary reporting
For investors, analysts, and fintech developers, this project provides a practical foundation for building daily market monitoring tools.
