Package Exports
- erlc-api
- erlc-api/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (erlc-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
π ER:LC API Wrapper
A lightweight, complete, and fully typed library for interacting with the Emergency Response: Liberty County (ER:LC) API. Designed to provide the best development experience in both JavaScript and TypeScript.
β¨ Features
- π― Full Coverage: Support for 100% of the API v1 endpoints.
- π‘οΈ TypeScript Support: Native type definitions included.
- β‘ Lightweight & Fast: No unnecessary heavy dependencies.
- π Secure: Robust token validation and error handling.
- π Up-to-date: Support for optional
GlobalToken(v3.2.0+).
π¦ Installation
npm install erlc-api
# or
bun add erlc-apiπ Quick Start
Initialization
You can use the library with or without a Global Token (required only for large-scale applications).
JavaScript
const erlc = require("erlc-api");
// Simple initialization (Recommended for most users)
const client = new erlc.Client();
// Or with Global Token (For Large Apps)
// const client = new erlc.Client({ globalToken: "..." });TypeScript
import { Client, getServer } from "erlc-api";
const client = new Client();π Usage Examples
Make sure to have your Server Key ready (get it from your private server settings in ER:LC).
π₯οΈ Server Information
const serverToken = "your-server-key-here";
// Get server status
const server = await erlc.getServer(serverToken);
console.log(`Server: ${server.Name} | Players: ${server.CurrentPlayers}/${server.MaxPlayers}`);
// Get connected players
const players = await erlc.getPlayers(serverToken);
console.table(players); // Shows name, ID, permission, and team
// Get vehicles on the map
const vehicles = await erlc.getVehicles(serverToken);π Logs
Access your server's activity history:
// Join/Leave Logs
const joinLogs = await erlc.getJoinLogs(serverToken);
// Kill Logs (Killfeed)
const killLogs = await erlc.getKillLogs(serverToken);
// Command Logs
const commandLogs = await erlc.getCommandLogs(serverToken);
// Mod Call Logs
const modCalls = await erlc.getModcallLogs(serverToken);π οΈ Management & Administration
// Get Ban List
const bans = await erlc.getBans(serverToken);
// Get Server Staff
const staff = await erlc.getStaff(serverToken);
// Get Queue
const queue = await erlc.getQueue(serverToken);β‘ Run Command
Execute commands directly from your code:
const command = await erlc.runCommand(serverToken, ":announce This is an API test!");
console.log(command); // Returns true if successfulβ οΈ Error Handling
The library throws descriptive errors. You should wrap your calls in try/catch blocks.
try {
const data = await erlc.getServer("invalid-token");
} catch (error) {
console.error(error.message); // e.g., "Forbidden: Access denied..."
}| Error Code | Description |
|---|---|
401 |
Unauthorized (Invalid Token) |
403 |
Forbidden (Permissions issue) |
429 |
Rate Limit Exceeded |
500 |
Internal Server Error |
π€ Contributing
Contributions are welcome! Feel free to submit a Pull Request.
π License
This project is licensed under the MIT License.