@korabi-dev/erlc-api
v1.0.0
Published
Unofficial ER:LC API wrapper for Node.js/TypeScript
Downloads
11
Readme
ERLC API
This project provides an ER:LC API Wrapper built with TypeScript. Below are the main details and usage instructions.
Getting Started
Prerequisites
Usage
TypeScript
import ErlcClient from '@korabi-dev/erlc-api';
const client = new ErlcClient({ serverKey: 'YOUR_SERVER_KEY' });
// Fetch server status
const status = await client.fetchServerStatus();
if (!status.error) {
console.log('Server status:', status.data);
}
// Fetch all players
const players = await client.fetchPlayers();
if (!players.error) {
console.log('Players:', players.data);
}
// Send a message to the server
const result = await client.sendMessage('Hello, ER:LC!');
if (result.error) {
console.error('Failed to send message:', result.message);
}JavaScript (CommonJS)
const ErlcClient = require('@korabi-dev/erlc-api').default;
const client = new ErlcClient({ serverKey: 'YOUR_SERVER_KEY' });
(async () => {
// Fetch server status
const status = await client.fetchServerStatus();
if (!status.error) {
console.log('Server status:', status.data);
}
// Fetch all players
const players = await client.fetchPlayers();
if (!players.error) {
console.log('Players:', players.data);
}
// Send a message to the server
const result = await client.sendMessage('Hello, ER:LC!');
if (result.error) {
console.error('Failed to send message:', result.message);
}
})();API Reference
All methods are asynchronous and return an object with at least:
error: booleanmessage: string (if error)data: varies by method
Methods
fetchServerStatus()
Returns server status info:
{
error: boolean,
message?: string,
data?: {
Name: string,
OwnerId: number,
CoOwnerIds: number[],
CurrentPlayers: number,
MaxPlayers: number,
JoinKey: string,
AccVerifiedReq: "Disabled" | "Email" | "Phone/ID",
TeamBalance: boolean
}
}fetchPlayers()
Returns array of players:
{
error: boolean,
message?: string,
data?: Array<{
UserId: number,
Username: string,
Permission: "Normal" | "Server Administrator" | "Server Owner" | "Server Moderator",
Callsign?: string,
Team: string
}>
}fetchJoinLogs()
Returns array of join logs:
{
error: boolean,
message?: string,
data?: Array<{
Join: boolean, // this indicates a join or leave event, Join=true means the user joined, Join=false means the user left
Timestamp: number,
Username: string,
UserId: number
}>
}fetchPlayerQueue()
Returns array of user IDs in queue:
{
error: boolean,
message?: string,
data?: Number[] // this is an array of roblox userIDs
}fetchKillLogs()
Returns array of kill logs:
{
error: boolean,
message?: string,
data?: Array<{
KillerUsername: string,
KillerUserId: number,
VictimUsername: string,
VictimUserId: number,
Timestamp: number
}>
}fetchCommandLogs()
Returns array of command logs:
{
error: boolean,
message?: string,
data?: Array<{
Username: string,
UserId: number,
Command: string,
Timestamp: number
}>
}fetchModCalls()
Returns array of mod calls:
{
error: boolean,
message?: string,
data?: Array<{
CallerUsername: string,
CallerUserId: number,
ModeratorUsername?: string,
ModeratorUserId?: number,
Timestamp: number
}>
}fetchBans()
Returns array of banned player IDs:
{
error: boolean,
message?: string,
data?: Array<{ PlayerId: string }>
}fetchSpawnedVehicles()
Returns array of vehicles:
{
error: boolean,
message?: string,
data?: Array<{ Name: string, Texture: string, Owner: string }>
}fetchStaff()
Returns array of staff players:
{
error: boolean,
message?: string,
data?: Array<{ UserId: number, Username: string, Permission: string }>
}fetchFilteredModCalls(options)
Returns filtered mod calls (see fetchModCalls for structure).
fetchFilteredKillLogs(options)
Returns filtered kill logs (see fetchKillLogs for structure).
fetchFilteredJoinLogs(options)
Returns filtered join logs (see fetchJoinLogs for structure).
fetchFilteredCommandLogs(options)
Returns filtered command logs (see fetchCommandLogs for structure).
fetchPlayer(options)
Returns a single player object (see fetchPlayers for structure).
isBanned(userId)
Returns banned status:
{
error: boolean,
message?: string,
data?: { banned: boolean }
}sendMessage(message)
Sends a message to the server. Returns error/message only.
sendHint(message)
Sends a hint to the server. Returns error/message only.
banPlayer(options)
Ban a player by userid or username. Returns error/message only.
kickPlayer(options)
Kick a player by userid or username. Returns error/message only.
Options Objects
Some methods accept an options object to filter or specify parameters. Here are the details for each:
fetchFilteredModCalls(options)
options can include:
timeframe(number, ms): Only calls within this time window (from now)modid(number): Moderator's user IDmodusername(string): Moderator's usernamecallerid(string): Caller user IDcallerusername(string): Caller username At least one must be provided.
fetchFilteredKillLogs(options)
options can include:
timeframe(number, ms): Only logs within this time windowkillerid(number): Killer's user IDkillerusername(string): Killer's usernamevictimid(number): Victim's user IDvictimusername(string): Victim's username At least one must be provided.
fetchFilteredJoinLogs(options)
options can include:
timeframe(number, ms): Only logs within this time windowuserid(number): User IDusername(string): Username At least one must be provided.
fetchFilteredCommandLogs(options)
options can include:
timeframe(number, ms): Only logs within this time windowuserid(number): User IDusername(string): Username At least one must be provided.
fetchPlayer(options)
options must include either:
userid(number): User IDusername(string): Username Only one should be provided.
banPlayer(options)
options must include:
userid(number): User ID, orusername(string): Username Only one should be provided.reason(string): Reason for ban (required)strict(boolean): If true, checks if ban succeeded (optional)
kickPlayer(options)
options must include:
userid(number): User ID, orusername(string): Username Only one should be provided.reason(string): Reason for kick (required)strict(boolean): If true, checks if kick succeeded (optional)
