Client
The client holds the SDK configuration and groups methods by resource.
Shared client
Use mcsrranked when the defaults fit your application:
import { mcsrranked } from "mcsrranked-sdk";
const user = await mcsrranked.users.get("NotAva1able");
The shared client uses the public MCSR Ranked API, a 10 second timeout for each attempt, two retries, and warning-level response validation.
Create a client
Create RankedClient when you need to change a default:
import { RankedClient } from "mcsrranked-sdk";
const ranked = new RankedClient({
timeout: 5_000,
retries: 1,
});
Options
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl |
string |
https://api.mcsrranked.com/ |
Replaces the base URL for API requests |
fetch |
typeof globalThis.fetch |
globalThis.fetch |
Replaces the fetch implementation |
privateKey |
string |
None | Authenticates endpoints that require a private key |
retries |
number |
2 |
Retries network failures and timeouts |
timeout |
number |
10000 |
Limits each request attempt in milliseconds |
validation |
ValidationConfiguration |
"warn" |
Controls response-shape validation |
timeout must be a finite positive number. retries must be a finite,
non-negative integer. The constructor throws TypeError when either value is
invalid.
baseUrl must be an absolute URL. End it with / when it contains a path
prefix, such as https://ranked.example/api/. Without the final slash, URL
resolution replaces the last path segment.
Resources
| Property | What it accesses |
|---|---|
users |
Player profiles, histories, matches, and private live state |
matches |
Global match lists and match details |
versus |
Results and matches between two players |
leaderboards |
Elo, phase, and record leaderboards |
live |
Public live overview |
weeklyRaces |
Current and earlier weekly races |
status |
Public service heartbeats and uptime |
Low-level methods
request<T>() sends a request through the normal response and retry pipeline
without resource validation. fetch() returns a raw Response and leaves
response handling to you.
Most applications should use the resource methods. See custom fetch and raw requests when the API adds an endpoint that the installed SDK version does not expose yet.