Stockbit Research research Playground @hansputera

Authentication

Complete reference for authentication flows across the Stockbit API ecosystem.


1. Main Token (Login)

The main token is a JWT valid for ~90 days, used to authenticate against most Exodus endpoints and as a gateway to obtain other tokens.

Authorization: Bearer <main_token>

Login Endpoints (Exodus)

Method Path Description
POST /login/v3/username/browser Browser username login
POST /login/v4/facebook Facebook login
POST /login/v4/google Google login
POST /login/refresh Refresh main JWT

Token Refresh

POST /login/refresh
Authorization: Bearer <main_token>

2. Sekuritas Token

Short-lived token bridging main auth and the trading system. Required (with trading PIN) to obtain the trading JWT.

Endpoint

GET https://exodus.stockbit.com/sekuritas/auth/token
Authorization: Bearer <main_token>

Response

{ "data": { "token": "sekuritas_token_string" } }

Usage

import requests
sekuritas_token = requests.get(
    "https://exodus.stockbit.com/sekuritas/auth/token",
    headers={"Authorization": f"Bearer {main_token}"}
).json()["data"]["token"]

3. Trading JWT

Separate JWT for Carina (carina.stockbit.com). Obtained by exchanging sekuritas token + 6-digit PIN. Valid ~24h, refreshable.

Login

POST https://carina.stockbit.com/auth/v2/login
Content-Type: application/json

{ "login_token": "sekuritas_token", "pin": "YOUR_TRADING_PIN" }

Response

{
  "data": {
    "access_token": "trading_jwt",
    "refresh_token": "refresh_jwt",
    "account": { "number": "2778867", "type": "ACCOUNT_TYPE_EQUITY" }
  }
}

Refresh

POST https://carina.stockbit.com/auth/refresh
Authorization: Bearer <trading_token>

Token Lifecycle

main_token (JWT, ~90d)
  → GET /sekuritas/auth/token → sekuritas_token
  → POST /auth/v2/login { login_token, pin } → trading_token (~24h)
  → POST /auth/refresh → new trading_token (~24h)

4. WebSocket Key

Required to authenticate trading WebSocket connections.

Endpoint

GET https://exodus.stockbit.com/auth/websocket/key
Authorization: Bearer <main_token>

Response

{ "data": { "key": "websocket_key_string" } }

WebSocket Auth Handshake

Two sequential protobuf messages on connect to wss://wss-trading.stockbit.com/ws:

  1. Auth-only: user_id + key + access_token (no channel)
  2. Subscription: user_id + key + access_token + channel with stocks
from stockbit_api.proto.stockbit_pb2 import WebsocketRequest

auth = WebsocketRequest()
auth.user_id = "3468390"; auth.key = wskey; auth.access_token = "<main_token>"

sub = WebsocketRequest()
sub.user_id = "3468390"; sub.key = wskey; sub.access_token = "<main_token>"
sub.channel.liveprice.extend(["BBRI", "BBCA"])

await ws.send(auth.SerializeToString())
await ws.send(sub.SerializeToString())

Chart WS (?type=chart) additionally sends periodic ping every ~30s:

ping = WebsocketRequest()
ping.ping.message = "ping"

5. PIN Operations

6-digit numeric PIN securing trading operations.

Set / Authenticate / Reset (Exodus)

Method Path Description
POST /user/setting/pin Set trading PIN
POST /auth/pin Authenticate PIN
POST /auth/pin/reset Reset PIN

PIN Management (Carina)

Method Path Description
POST /auth/pin/validate Validate PIN
POST /auth/pin/change Change PIN
POST /auth/v2/pin/change/new New PIN (v2)
POST /auth/v2/pin/change/confirm Confirm PIN change
POST /auth/v2/pin/change/otp/send Send OTP
POST /auth/v2/pin/change/otp/verify Verify OTP
POST /auth/v2/pin/reset/validate Start reset
POST /auth/v2/pin/reset/new Set new PIN
POST /auth/v2/pin/reset/confirm Confirm reset
POST /auth/v2/pin/reset/otp/send Send OTP
POST /auth/v2/pin/reset/otp/verify Verify OTP

Error Reference

Status Error Type Meaning
401 INVALID_AUTH Token expired or invalid
401 INVALID_TOKEN Token expired or invalid
400 INVALID_PARAMETER Missing/invalid fields
500 Server error

Python Exceptions

StockbitError
├── AuthenticationError
│   ├── InvalidPINError
│   └── TokenExpiredError
├── InsufficientBalanceError
├── OrderRejectedError
├── RateLimitError
└── WebSocketDisconnectError

Service Auth Summary

Service Base URL Auth
Exodus (Main) https://exodus.stockbit.com Bearer <main_token>
Carina (Trading) https://carina.stockbit.com Bearer <trading_token>
Trading WS wss://wss-trading.stockbit.com/ws Protobuf (user_id + key + token)
General WS wss://ws-gen.stockbit.com/v1 Securities token
Social WS wss://wssocial.stockbit.com (see social WS docs)