OHLC.dev editorialIDX

IDX Fundamental Analysis Dashboard Using Python and RapidAPI

Build an IDX fundamental analysis dashboard using Python and RapidAPI to evaluate stock metrics, compare company fundamentals, and analyze foreign ownership data.

September 2, 20265 min readRafatar
IDX Fundamental Analysis Dashboard Using Python and RapidAPI

This project develops an automated IDX Fundamental Analysis Dashboard using Python and RapidAPI. The system is designed to collect and analyze fundamental information from Indonesian stocks through three main components:

  1. Fundamental Chart Metrics Analysis

  2. Company Fundamental Chart Data

  3. Foreign Ownership Analysis

The objective of this project is to build a simple investor dashboard that can retrieve company fundamental information, compare stock metrics, and analyze foreign investor ownership structure.

The project uses Python libraries such as requests for API communication, pandas for data processing, json for handling API responses, and matplotlib for data visualization.

The workflow is organized into five main cells:

  • Cell 1: API connection setup

  • Cell 2: Retrieve fundamental metrics

  • Cell 3: Retrieve company fundamental chart data

  • Cell 4: Analyze foreign ownership

  • Cell 5: Generate fundamental investor dashboard

This system helps investors transform raw IDX API data into structured fundamental insights that are easier to understand.

Cell 1 - Setup API Connection

# =====================================
# CELL 1 : SETUP API CONNECTION
# =====================================

import requests
import pandas as pd
import json
import matplotlib.pyplot as plt


API_KEY = "YOUR_API_KEY"


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":
    API_KEY
}



def get_api(endpoint, params=None):

    url = BASE_URL + endpoint


    r = requests.get(
        url,
        headers=HEADERS,
        params=params
    )


    if r.status_code == 200:

        return r.json()


    print(
        "Error:",
        r.status_code
    )

    print(
        r.text
    )


    return None

Explanation

Cell 1 prepares the Python environment and creates the main API connection function.

The imported libraries include:

  • requests for sending HTTP requests.

  • pandas for processing structured datasets.

  • json for handling JSON responses.

  • matplotlib for visualization.

The API configuration defines the RapidAPI host, authentication key, and request headers required to retrieve IDX data.

The function:

get_api()

acts as a reusable API caller. It receives an endpoint and optional parameters, sends the request, checks the response status, and returns JSON data when the request succeeds.

Cell 2 - Get Fundamental Chart Metrics

# =====================================
# CELL 2 : FUNDAMENTAL METRICS
# =====================================


metrics = get_api(

    "/api/emiten/fundachart/metrics",

    {
        "metric_name":
        "fundachart"
    }

)



print(
    json.dumps(
        metrics,
        indent=2
    )
)



try:

    df_metrics = pd.DataFrame(
        metrics["data"]
    )


    display(
        df_metrics
    )


except:

    print(
        "Format metrics bukan dataframe"
    )

Explanation

Cell 2 retrieves fundamental chart metrics from the IDX API.

The endpoint used:

/api/emiten/fundachart/metrics

is called with the parameter:

metric_name = "fundachart"

to obtain available fundamental indicators.

The returned JSON response is converted into a pandas DataFrame:

df_metrics

if the API response contains structured data.

This process allows investors to organize fundamental metrics into a table format for easier comparison.

Cell 3 - Get Fundachart BBCA and TLKM

# =====================================
# CELL 3 : FUNDACHART ANALYSIS
# =====================================


fundachart = get_api(

    "/api/emiten/fundachart",

    {

        "companies":
        "BBCA,TLKM",

        "timeframe":
        "1y",

        "item":
        "2661"

    }

)



print(
    json.dumps(
        fundachart,
        indent=2
    )[:3000]
)



try:

    df_fundachart = pd.DataFrame(

        fundachart["data"]

    )


    display(
        df_fundachart
    )


except:

    print(
        "Tidak ditemukan data dataframe"
    )

Explanation

Cell 3 retrieves company fundamental chart data.

The analysis compares two companies:

BBCA
TLKM

using:

timeframe = "1y"

with the selected fundamental item.

The API response is converted into:

df_fundachart

which can be used for company comparison and fundamental trend analysis.

This allows investors to observe company-level fundamental information based on historical data.

Cell 4 - Foreign Ownership Analysis

# =====================================
# CELL 4 : FOREIGN OWNERSHIP
# =====================================


foreign = get_api(

    "/api/emiten/BBCA/foreign-ownership"

)



print(
    json.dumps(
        foreign,
        indent=2
    )[:3000]
)



try:

    df_foreign = pd.DataFrame(

        foreign["data"]

    )


    display(
        df_foreign
    )


except:

    print(
        "Tidak ditemukan data foreign ownership"
    )

Explanation

Cell 4 analyzes foreign ownership information for BBCA.

The API endpoint:

/api/emiten/BBCA/foreign-ownership

retrieves ownership data from foreign investors.

The response is converted into:

df_foreign

which contains foreign ownership information.

Foreign ownership analysis helps investors understand institutional participation and identify major foreign shareholders.

Cell 5 - Fundamental Investor Dashboard

# ==========================================
# CELL 5 : SIMPLE INVESTOR DASHBOARD
# ==========================================


print("""
========================================
IDX FUNDAMENTAL SUMMARY
========================================
""")


# Company Profile

print("\nCOMPANY PROFILE")


try:

    companies = fundachart["data"]


    for c in companies:


        print(

            f"""
Company Name :
{c.get('company_name')}

Company ID :
{c.get('company_id')}

"""

        )


except:

    print(
        "Data perusahaan tidak tersedia"
    )



# Foreign Ownership


print("\nFOREIGN OWNERSHIP")


try:

    foreign_data = foreign["data"]


    symbol = foreign_data.get(
        "symbol",
        "BBCA"
    )


    total = foreign_data.get(
        "totalForeignOwnership",
        "-"
    )


    print(
        f"""

Stock :
{symbol}

Foreign Ownership :
{total} %

"""
    )


    holders = foreign_data.get(
        "holders",
        []
    )


    if holders:


        print(
            "Largest Foreign Investors:"
        )


        for i,h in enumerate(
            holders[:5],
            start=1
        ):


            print(

                f"""

{i}. {h.get('organization')}

Ownership :
{h.get('pctHeld')} %

"""

            )


except:

    print(
        "Foreign data unavailable"
    )



print("""
========================================

CONCLUSION:

✓ Fundamental data retrieved
✓ Foreign ownership analyzed
✓ Major shareholders identified

Note:
This analysis is not a buy/sell recommendation.

========================================
""")

Explanation

Cell 5 creates a simple investor dashboard combining company fundamentals and foreign ownership analysis.

The dashboard displays:

  • Company name.

  • Company ID.

  • Stock symbol.

  • Total foreign ownership percentage.

  • Largest foreign shareholders.

The system retrieves company information from the fundachart response and displays foreign ownership data from the API response.

For foreign ownership analysis, the dashboard extracts:

  • Stock symbol.

  • Total foreign ownership.

  • Foreign investor holders.

The final summary provides a simple interpretation:

  • Fundamental data successfully collected.

  • Foreign ownership successfully analyzed.

  • Major shareholders identified.

However, the analysis is not intended as a direct investment recommendation.

Conclusion

This project demonstrates how Python and RapidAPI can be used to build an automated IDX Fundamental Analysis Dashboard.

The system integrates three important analysis components:

  1. Fundamental Metrics Analysis

    To retrieve and organize stock fundamental indicators.

  2. Fundachart Company Analysis

    To compare company fundamental data across selected stocks.

  3. Foreign Ownership Analysis

    To identify foreign investor participation and major shareholders.

The dashboard provides investors with a structured overview of company fundamentals and ownership composition.

However, fundamental data and foreign ownership information should not be used as a single investment decision factor. Investors should combine this analysis with financial statements, valuation analysis, technical indicators, market conditions, and risk management before making investment decisions.