An unofficial TypeScript/JavaScript SDK for the Trade Republic API.
- 🔐 Two-step authentication (phone + PIN + SMS OTP)
- 📡 REST API methods for account data, trending stocks, documents, etc.
- 🔌 WebSocket subscriptions for real-time data
- 🍪 Automatic session cookie management
- 📘 Full TypeScript support
- 🎯 Simple, intuitive API
npm install trade-republic-sdk
import { TradeRepublicClient } from "trade-republic-sdk";
const client = new TradeRepublicClient();
try {
// Step 1: Initiate login (sends OTP to your device)
await client.initiateLogin("+491xxxxxxxxxx", "1234");
// Step 2: Complete login with OTP received via SMS
await client.completeLogin("5678");
// Step 3: Use REST API methods
const accountInfo = await client.getAccountInfo();
const trendingStocks = await client.getTrendingStocks();
console.log(accountInfo, trendingStocks);
} catch (error) {
console.error("Error:", error);
}
// After authentication, use WebSocket for real-time data
const ws = client.ws;
// Subscribe to portfolio updates
ws.subscribe("portfolio", {}, (data) => {
console.log("Portfolio update:", data);
});
// Subscribe to instrument price updates
ws.subscribe("ticker", { id: "US88160R1014" }, (data) => {
console.log("Price update:", data);
});
// Some subscriptions auto-unsubscribe after sending all data
ws.subscribe("instrument", { id: "US88160R1014" }, (data) => {
console.log("Instrument details:", data);
// This subscription will automatically close after receiving the data
});
-
initiateLogin(phoneNumber, pin)
- Start login process -
completeLogin(otpCode)
- Complete with SMS OTP -
loginWithCookies(cookies)
- Use existing session cookies -
isAuthenticated()
- Check auth status -
logout()
- Clear session
-
getAccountInfo()
- Account details and balances -
getTrendingStocks()
- Popular stocks -
getPersonalDetails()
- Customer information -
getPaymentMethods()
- Payment options -
getTaxInformation()
- Tax details -
getAllDocuments()
- Account documents
The WebSocket API allows real-time subscriptions to various data streams. Some subscriptions automatically unsubscribe after delivering the requested data, while others provide continuous updates.
// Portfolio and account data
ws.subscribe("portfolio", {}, callback);
ws.subscribe("cash", {}, callback);
// Instrument data
ws.subscribe("ticker", { id: "instrumentId" }, callback);
ws.subscribe("instrument", { id: "instrumentId" }, callback);
// Market data
ws.subscribe("neonSearch", { query: "Tesla" }, callback);
Important: The WebSocket functionality is incomplete. Many subscription types and parameters are not yet implemented.
- Incomplete: Many API endpoints are missing
- WebSocket: Limited subscription types implemented
- Unofficial: Not supported by Trade Republic
- Rate Limits: Be mindful of API usage
- Security: Handle credentials and session data carefully
git clone https://github.com/nilsfischer/trade-republic-sdk.git
cd trade-republic-sdk
npm install
npm run build
npm test
This SDK is far from complete. Contributions are welcome.
MIT - See LICENSE file.
This SDK is not officially supported by Trade Republic. Use responsibly and in accordance with Trade Republic's terms of service.