JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 55
  • Score
    100M100P100Q55003F
  • License MIT

An ER:LC API wrapper for JS/TS

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

npm version License Downloads

πŸ‡ͺπŸ‡Έ VersiΓ³n en EspaΓ±ol

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.