riot-bridge
v1.0.2
Published
A secure and expandable wrapper for Valorant Riot Client APIs
Readme
riot-bridge
TypeScript client for Valorant local and remote APIs with built‑in auth, rate limiting, retries, and WebSocket helpers. Designed for Bun and Node 18+.
Installation
bun add riot-bridgeQuick start
import { RiotClient } from "riot-bridge";
const client = new RiotClient();
await client.init();
const me = await client.user.getRSOUser();
if (me.error) throw new Error(me.error);
console.log(me.data);API overview
- RiotClient: Initializes local auth (lockfile), derives remote tokens, and exposes endpoints.
- Response shape (
ApiResponse<T>):{ error: string | null; status: number; data: T | null; rateLimitInfo?: { remaining: number; resetTime: number; retryAfter?: number } } - Request options (
RequestOptions):{ method, params, body, headers, isRemote, timeoutMs, retries }
Constructor
new RiotClient(lockFilePath?: string, logger?: Logger, interceptors?: Interceptors, tls?: TLSOptions)lockFilePath: override lockfile path if needed.logger:{ debug, info, warn, error }optional.interceptors:{ beforeRequest, afterResponse, onError }optional hooks.tls:{ rejectUnauthorized?: boolean }for local HTTPS/WebSocket calls.
Endpoints quick reference
| Endpoint | Key on client | Highlights |
| ------------------- | -------------------- | -------------------------------------------------- |
| AuthEndpoint | client.auth | Auth flows, geo, PAS token, client config |
| UserEndpoint | client.user | RSO user, sessions, region, entitlements, presence |
| FriendsEndpoint | client.friends | Friends list and requests |
| ChatEndpoint | client.chat | Conversations, history, send message |
| PartyEndpoint | client.party | Party lifecycle, matchmaking, custom games |
| PreGameEndpoint | client.pregame | Agent select/lock before match |
| CurrentGameEndpoint | client.currentgame | Live match info and loadouts |
| PvpEndpoint | client.pvp | MMR, matches, leaderboard, content meta |
| StoreEndpoint | client.store | Wallet, storefront, owned items, prices |
| ContentEndpoint | client.content | Public content (agents, maps, skins, etc.) |
| PremierEndpoint | client.premier | Premier player profile |
| WebSocketEndpoint | client.websocket | Connect and subscribe to events |
Example:
const mmr = await client.pvp.getPlayerMMR("your-puuid");
const wallet = await client.store.getWallet("your-puuid");
const chat = await client.chat.getChatSession();Requests, timeouts, retries
const res = await client.get("/some/endpoint", {
timeoutMs: 10_000,
retries: 2, // retries 5xx and 429 with exponential backoff
});External APIs (no Riot auth)
const external = client.createRequester({
baseUrl: "https://api.example.com",
skipAuth: true,
remote: true,
});
const r = await external<{ ok: boolean }>("/objects", { method: "GET" });You can wrap this into a custom endpoint and register it:
class CustomEndpoint {
constructor(
private doRequest: <T>(
url: string,
opts?: RequestOptions
) => Promise<ApiResponse<T>>
) {}
getCustomData() {
return this.doRequest<unknown>("/objects", { method: "GET" });
}
}
const custom = new CustomEndpoint(external);
client.registerEndpoint("customProducts", custom);
const retrieved = client.getEndpoint("customProducts")
?.instance as CustomEndpoint;
const resp = await retrieved.getCustomData();WebSocket
Use the dedicated websocket endpoint for auto‑reconnect helpers, or create a raw socket bound to the local client:
// Auto‑reconnect utilities
const ws = await client.websocket.connectAndSubscribeToAll({
onMessage: (evt) => console.log(evt.uri, evt.eventType),
});
// Or a raw socket to a specific path
const raw = client.createWebSocket("/socket", {
onMessage: (msg) => console.log(msg),
});Rate limiting
Token‑bucket limiter with request scheduling and rateLimitInfo on responses. Helpers:
client.isRateLimited();
client.getRateLimitInfo();
client.getTimeUntilReset();Build
bun x tsc -p tsconfig.build.jsonThe package publishes CommonJS (dist/index.js) with type declarations (dist/index.d.ts). See the exports map in package.json.
Notes
- The Valorant client must be running for local endpoints; TLS validation is relaxed for local self‑signed certs by default and can be controlled via
tls.rejectUnauthorized. - Remote requests use tokens derived from local session where possible.
License
MIT
