Stockbit Research research Playground @hansputera

Stockbit API — Unofficial Python Wrapper

Reverse-engineered API wrapper for Stockbit (stockbit.com). Covers REST, WebSocket, and trading protocols.

Installation

pip install -r requirements.txt

Or install protobuf compilation tools:

pip install grpcio-tools protobuf

Usage

from stockbit_api import StockbitClient

client = StockbitClient(main_token="eyJ...", trading_pin="YOUR_TRADING_PIN")

# Get profile
profile = client.exodus.get_profile()
print(f"Hello, {profile['username']}!")

# Get trading balance
client.carina.login()
balance = client.carina.get_balance()
print(f"Cash: Rp {balance['cash_balance']:,}")

# Place order
order = client.carina.buy("BBRI", 4900, 100)
print(f"Order: {order['order_key']}")

WebSocket Streaming

import asyncio
from stockbit_api import StockbitClient

async def main():
    client = StockbitClient(main_token="eyJ...")

    async def on_price(data):
        if data.get("event") == "liveprice":
            print(f"{data['stock']}: {data['lastprice']}")

    ws = client.websocket
    ws.on_message(on_price)
    ws.subscribe_dict(liveprice=["BBCA", "BBRI"], running_trade_batch=["BBCA"])
    await ws.run()

asyncio.run(main())

The WebSocket sends these event types: - liveprice (field 9) — Real-time price ticks via LivePrice protobuf - running_trade (field 8) — Executed trades via RunningTradeBatch - orderbook (field 10) — Orderbook snapshot via OrderbookFeed (pipe-delimited text) - iepiev (fallback decode) — Indicative equilibrium price/volume via IEPIEV protobuf

Chart WebSocket — connect to wss://wss-trading.stockbit.com/ws?type=chart:

async def chart_ws_example():
    client = StockbitClient(main_token="eyJ...")

    async def on_data(data):
        event = data.get("event")
        if event == "liveprice":
            print(f"{data['stock']}: {data['lastprice']}")
        elif event == "iepiev":
            print(f"IEP/IEV {data['stock']}: {data['iep']}/{data['iev']}")

    ws = client.websocket.for_chart(client.auth, ["BBCA"])
    ws.on_message(on_data)
    await ws.run()

New REST Endpoints (Exodus):

client.exodus.get_company_profile("BBCA")     # /emitten/{symbol}/profile
client.exodus.get_major_holder("BBCA")         # /insider/company/majorholder
client.exodus.get_seasonality("BBCA")          # /company-price-feed/seasonality/{symbol}
client.exodus.get_corporate_action("BBCA")     # /corpaction/{symbol}
client.exodus.get_chartbit_price("BBCA")       # /chartbit/{symbol}/price/daily

Documentation

See docs/ directory for the full API reference: