Contoh Klien

Contoh kode siap pakai untuk curl, Python, JavaScript/TypeScript, dan Pandas.

Semua contoh menggunakan https://api.indexalpha.id dengan Bearer token. Ganti <YOUR_API_KEY> dengan key dari dashboard Anda. Perlu diingat bahwa rentang tanggal bersifat agregat - lihat Quick Start dan referensi Endpoints.

curl

curl -X 'GET' \
  'https://api.indexalpha.id/stocks/broker-summary?ticker=BBCA&from=2026-03-26&to=2026-03-26&investor=all' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <YOUR_API_KEY>'

Python

import requests

API_KEY = "<YOUR_API_KEY>"
BASE_URL = "https://api.indexalpha.id"

headers = {"Authorization": f"Bearer {API_KEY}"}
params = {"ticker": "BBCA", "from": "2026-03-26", "to": "2026-03-26", "investor": "all"}

resp = requests.get(f"{BASE_URL}/stocks/broker-summary", headers=headers, params=params)
resp.raise_for_status()
data = resp.json()["data"]

for row in data:
    print(row["code"], row["buy_value"], row["sell_value"])

JavaScript / TypeScript

const API_KEY = "<YOUR_API_KEY>";
const BASE_URL = "https://api.indexalpha.id";

const headers = {
  Authorization: `Bearer ${API_KEY}`,
  Accept: "application/json",
};

interface BrokerSummaryRow {
  code: string;
  buy_freq: number;
  buy_volume: number;
  buy_value: number;
  sell_freq: number;
  sell_volume: number;
  sell_value: number;
  buy_avg: number;
  sell_avg: number;
}

async function getBrokerSummary(ticker: string, from: string, to: string, investor = "all") {
  const params = new URLSearchParams({ ticker, from, to, investor });
  const res = await fetch(`${BASE_URL}/stocks/broker-summary?${params}`, { headers });
  if (!res.ok) throw new Error(`Request failed: ${res.status}`);
  const body = await res.json();
  return body.data as BrokerSummaryRow[];
}

Pandas

import pandas as pd
import requests

API_KEY = "<YOUR_API_KEY>"
BASE_URL = "https://api.indexalpha.id"

headers = {"Authorization": f"Bearer {API_KEY}"}
params = {"ticker": "BBCA", "from": "2026-03-26", "to": "2026-03-26", "investor": "all"}

resp = requests.get(f"{BASE_URL}/stocks/broker-summary", headers=headers, params=params)
resp.raise_for_status()

df = pd.DataFrame(resp.json()["data"])
print(df.head())

Untuk memuat sekumpulan ticker ke dalam satu DataFrame:

import pandas as pd
import requests

API_KEY = "<YOUR_API_KEY>"
BASE_URL = "https://api.indexalpha.id"
headers = {"Authorization": f"Bearer {API_KEY}"}

payload = {
    "tickers": ["BBCA", "BBRI", "TLKM"],
    "from": "2026-03-26",
    "to": "2026-03-26",
    "investor": "all",
    "market": "RG",
}
resp = requests.post(f"{BASE_URL}/stocks/broker-summary/batch", json=payload, headers=headers)
resp.raise_for_status()

frames = []
for ticker, rows in resp.json()["data"].items():
    frame = pd.DataFrame(rows)
    frame.insert(0, "ticker", ticker)
    frames.append(frame)

df = pd.concat(frames, ignore_index=True)
print(df.head())

Kuota dan error

Respons menyertakan header X-Monthly-Remaining dan X-RateLimit-*. Jika Anda melebihi rate limit per menit Anda menerima 429; jika kuota bulanan habis Anda menerima 403. Mengecek penggunaan dengan GET /usage selalu gratis. Lihat Error dan Limit & Kuota.

Di halaman ini