erlc-api 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -59
- package/README_ES.md +148 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,40 +4,42 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.npmjs.com/package/erlc-api)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[🇪🇸 Versión en Español](README_ES.md)
|
|
8
|
+
|
|
9
|
+
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.
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
11
|
-
## ✨
|
|
13
|
+
## ✨ Features
|
|
12
14
|
|
|
13
|
-
- 🎯 **
|
|
14
|
-
- 🛡️ **
|
|
15
|
-
- ⚡ **
|
|
16
|
-
- 🔒 **
|
|
17
|
-
- 🆕 **
|
|
15
|
+
- 🎯 **Full Coverage**: Support for 100% of the API v1 endpoints.
|
|
16
|
+
- 🛡️ **TypeScript Support**: Native type definitions included.
|
|
17
|
+
- ⚡ **Lightweight & Fast**: No unnecessary heavy dependencies.
|
|
18
|
+
- 🔒 **Secure**: Robust token validation and error handling.
|
|
19
|
+
- 🆕 **Up-to-date**: Support for optional `GlobalToken` (v3.2.0+).
|
|
18
20
|
|
|
19
|
-
## 📦
|
|
21
|
+
## 📦 Installation
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
npm install erlc-api
|
|
23
|
-
#
|
|
25
|
+
# or
|
|
24
26
|
bun add erlc-api
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
## 🚀
|
|
29
|
+
## 🚀 Quick Start
|
|
28
30
|
|
|
29
|
-
###
|
|
31
|
+
### Initialization
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
You can use the library with or without a `Global Token` (required only for large-scale applications).
|
|
32
34
|
|
|
33
35
|
**JavaScript**
|
|
34
36
|
```javascript
|
|
35
37
|
const erlc = require("erlc-api");
|
|
36
38
|
|
|
37
|
-
//
|
|
39
|
+
// Simple initialization (Recommended for most users)
|
|
38
40
|
const client = new erlc.Client();
|
|
39
41
|
|
|
40
|
-
//
|
|
42
|
+
// Or with Global Token (For Large Apps)
|
|
41
43
|
// const client = new erlc.Client({ globalToken: "..." });
|
|
42
44
|
```
|
|
43
45
|
|
|
@@ -50,97 +52,94 @@ const client = new Client();
|
|
|
50
52
|
|
|
51
53
|
---
|
|
52
54
|
|
|
53
|
-
## 📖
|
|
55
|
+
## 📖 Usage Examples
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
Make sure to have your `Server Key` ready (get it from your private server settings in ER:LC).
|
|
56
58
|
|
|
57
|
-
### 🖥️
|
|
59
|
+
### 🖥️ Server Information
|
|
58
60
|
|
|
59
61
|
```javascript
|
|
60
|
-
const serverToken = "
|
|
62
|
+
const serverToken = "your-server-key-here";
|
|
61
63
|
|
|
62
|
-
//
|
|
64
|
+
// Get server status
|
|
63
65
|
const server = await erlc.getServer(serverToken);
|
|
64
|
-
console.log(`
|
|
66
|
+
console.log(`Server: ${server.Name} | Players: ${server.CurrentPlayers}/${server.MaxPlayers}`);
|
|
65
67
|
|
|
66
|
-
//
|
|
68
|
+
// Get connected players
|
|
67
69
|
const players = await erlc.getPlayers(serverToken);
|
|
68
|
-
console.table(players); //
|
|
70
|
+
console.table(players); // Shows name, ID, permission, and team
|
|
69
71
|
|
|
70
|
-
//
|
|
72
|
+
// Get vehicles on the map
|
|
71
73
|
const vehicles = await erlc.getVehicles(serverToken);
|
|
72
74
|
```
|
|
73
75
|
|
|
74
|
-
### 📜
|
|
76
|
+
### 📜 Logs
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
Access your server's activity history:
|
|
77
79
|
|
|
78
80
|
```javascript
|
|
79
|
-
// Logs
|
|
81
|
+
// Join/Leave Logs
|
|
80
82
|
const joinLogs = await erlc.getJoinLogs(serverToken);
|
|
81
83
|
|
|
82
|
-
// Logs
|
|
84
|
+
// Kill Logs (Killfeed)
|
|
83
85
|
const killLogs = await erlc.getKillLogs(serverToken);
|
|
84
86
|
|
|
85
|
-
// Logs
|
|
87
|
+
// Command Logs
|
|
86
88
|
const commandLogs = await erlc.getCommandLogs(serverToken);
|
|
87
89
|
|
|
88
|
-
//
|
|
90
|
+
// Mod Call Logs
|
|
89
91
|
const modCalls = await erlc.getModcallLogs(serverToken);
|
|
90
92
|
```
|
|
91
93
|
|
|
92
|
-
### 🛠️
|
|
94
|
+
### 🛠️ Management & Administration
|
|
93
95
|
|
|
94
96
|
```javascript
|
|
95
|
-
//
|
|
97
|
+
// Get Ban List
|
|
96
98
|
const bans = await erlc.getBans(serverToken);
|
|
97
99
|
|
|
98
|
-
//
|
|
100
|
+
// Get Server Staff
|
|
99
101
|
const staff = await erlc.getStaff(serverToken);
|
|
100
102
|
|
|
101
|
-
//
|
|
102
|
-
await erlc.
|
|
103
|
+
// Get Queue
|
|
104
|
+
const queue = await erlc.getQueue(serverToken);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### ⚡ Run Command
|
|
108
|
+
|
|
109
|
+
Execute commands directly from your code:
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
```javascript
|
|
112
|
+
const command = await erlc.runCommand(serverToken, ":announce This is an API test!");
|
|
113
|
+
console.log(command); // Returns true if successful
|
|
106
114
|
```
|
|
107
115
|
|
|
108
116
|
---
|
|
109
117
|
|
|
110
|
-
##
|
|
118
|
+
## ⚠️ Error Handling
|
|
111
119
|
|
|
112
|
-
|
|
120
|
+
The library throws descriptive errors. You should wrap your calls in `try/catch` blocks.
|
|
113
121
|
|
|
114
122
|
```javascript
|
|
115
123
|
try {
|
|
116
|
-
await erlc.getServer(
|
|
124
|
+
const data = await erlc.getServer("invalid-token");
|
|
117
125
|
} catch (error) {
|
|
118
|
-
console.error(
|
|
119
|
-
|
|
120
|
-
if (error.code === 4001) console.log("⏳ Rate limit alcanzado, espera un momento.");
|
|
121
|
-
if (error.code === 2002) console.log("🔑 La Server Key es inválida o expiró.");
|
|
126
|
+
console.error(error.message); // e.g., "Forbidden: Access denied..."
|
|
122
127
|
}
|
|
123
128
|
```
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
|
128
|
-
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
| **4001** | Rate Limit | Estás enviando muchas peticiones muy rápido. |
|
|
132
|
-
| **403** | No Autorizado | Verifica tus permisos o tokens. |
|
|
130
|
+
| Error Code | Description |
|
|
131
|
+
|------------|-------------|
|
|
132
|
+
| `401` | Unauthorized (Invalid Token) |
|
|
133
|
+
| `403` | Forbidden (Permissions issue) |
|
|
134
|
+
| `429` | Rate Limit Exceeded |
|
|
135
|
+
| `500` | Internal Server Error |
|
|
133
136
|
|
|
134
137
|
---
|
|
135
138
|
|
|
136
|
-
##
|
|
139
|
+
## 🤝 Contributing
|
|
137
140
|
|
|
138
|
-
|
|
139
|
-
- [Discord de Soporte PRC](https://discord.gg/prc)
|
|
140
|
-
- [NPM Package](https://www.npmjs.com/package/erlc-api)
|
|
141
|
+
Contributions are welcome! Feel free to submit a Pull Request.
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
## 📄 License
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
<sub>Hecho con ❤️ para la comunidad de ER:LC</sub>
|
|
146
|
-
</div>
|
|
145
|
+
This project is licensed under the [MIT License](LICENSE).
|
package/README_ES.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# 🚔 ER:LC API Wrapper
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/erlc-api)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.npmjs.com/package/erlc-api)
|
|
6
|
+
|
|
7
|
+
[🇬🇧 English Version](README.md)
|
|
8
|
+
|
|
9
|
+
Una librería ligera, completa y **totalmente tipada** para interactuar con la API de *Emergency Response: Liberty County* (ER:LC). Diseñada para ofrecer la mejor experiencia de desarrollo tanto en JavaScript como en TypeScript.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ✨ Características
|
|
14
|
+
|
|
15
|
+
- 🎯 **Cobertura Total**: Soporte para el 100% de los endpoints de la API v1.
|
|
16
|
+
- 🛡️ **Tipado TypeScript**: Definiciones de tipos incluidas nativamente.
|
|
17
|
+
- ⚡ **Ligero y Rápido**: Sin dependencias pesadas innecesarias.
|
|
18
|
+
- 🔒 **Seguro**: Validación de tokens y manejo de errores robusto.
|
|
19
|
+
- 🆕 **Actualizado**: Soporte para `GlobalToken` opcional (v3.2.0+).
|
|
20
|
+
|
|
21
|
+
## 📦 Instalación
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install erlc-api
|
|
25
|
+
# o
|
|
26
|
+
bun add erlc-api
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🚀 Inicio Rápido
|
|
30
|
+
|
|
31
|
+
### Inicialización
|
|
32
|
+
|
|
33
|
+
Puedes usar la librería con o sin un `Global Token` (requerido solo para aplicaciones a gran escala).
|
|
34
|
+
|
|
35
|
+
**JavaScript**
|
|
36
|
+
```javascript
|
|
37
|
+
const erlc = require("erlc-api");
|
|
38
|
+
|
|
39
|
+
// Inicialización simple (Recomendada para la mayoría)
|
|
40
|
+
const client = new erlc.Client();
|
|
41
|
+
|
|
42
|
+
// O con Global Token (Para Large Apps)
|
|
43
|
+
// const client = new erlc.Client({ globalToken: "..." });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**TypeScript**
|
|
47
|
+
```typescript
|
|
48
|
+
import { Client, getServer } from "erlc-api";
|
|
49
|
+
|
|
50
|
+
const client = new Client();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📖 Ejemplos de Uso
|
|
56
|
+
|
|
57
|
+
Asegúrate de tener tu `Server Key` a mano (obtenla en los ajustes de tu servidor privado en ER:LC).
|
|
58
|
+
|
|
59
|
+
### 🖥️ Información del Servidor
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const serverToken = "tu-server-key-aqui";
|
|
63
|
+
|
|
64
|
+
// Obtener estado del servidor
|
|
65
|
+
const server = await erlc.getServer(serverToken);
|
|
66
|
+
console.log(`Servidor: ${server.Name} | Jugadores: ${server.CurrentPlayers}/${server.MaxPlayers}`);
|
|
67
|
+
|
|
68
|
+
// Obtener jugadores conectados
|
|
69
|
+
const players = await erlc.getPlayers(serverToken);
|
|
70
|
+
console.table(players); // Muestra nombre, ID, permisos y equipo
|
|
71
|
+
|
|
72
|
+
// Obtener vehículos en el mapa
|
|
73
|
+
const vehicles = await erlc.getVehicles(serverToken);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 📜 Registros (Logs)
|
|
77
|
+
|
|
78
|
+
Accede a los historiales de actividad de tu servidor:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
// Logs de Entradas/Salidas
|
|
82
|
+
const joinLogs = await erlc.getJoinLogs(serverToken);
|
|
83
|
+
|
|
84
|
+
// Logs de Muertes (Killfeed)
|
|
85
|
+
const killLogs = await erlc.getKillLogs(serverToken);
|
|
86
|
+
|
|
87
|
+
// Logs de Comandos ejecutados
|
|
88
|
+
const commandLogs = await erlc.getCommandLogs(serverToken);
|
|
89
|
+
|
|
90
|
+
// Logs de Llamadas a Moderadores
|
|
91
|
+
const modCalls = await erlc.getModcallLogs(serverToken);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 🛠️ Gestión y Administración
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Ver lista de Baneos
|
|
98
|
+
const bans = await erlc.getBans(serverToken);
|
|
99
|
+
|
|
100
|
+
// Obtener Staff del servidor
|
|
101
|
+
const staff = await erlc.getStaff(serverToken);
|
|
102
|
+
|
|
103
|
+
// Ejecutar comando remoto (Ej: Anuncio)
|
|
104
|
+
await erlc.runCommand(serverToken, ":h ¡Hola desde la API!");
|
|
105
|
+
|
|
106
|
+
// Resetear Global Key (Solo si tienes una configurada)
|
|
107
|
+
// await erlc.resetGlobalKey();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🚨 Manejo de Errores
|
|
113
|
+
|
|
114
|
+
La librería lanza errores descriptivos (`ErlcError`) que facilitan la depuración.
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
try {
|
|
118
|
+
await erlc.getServer(serverToken);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(`Error ${error.code}: ${error.message}`);
|
|
121
|
+
|
|
122
|
+
if (error.code === 4001) console.log("⏳ Rate limit alcanzado, espera un momento.");
|
|
123
|
+
if (error.code === 2002) console.log("🔑 La Server Key es inválida o expiró.");
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Códigos Comunes
|
|
128
|
+
|
|
129
|
+
| Código | Significado | Solución |
|
|
130
|
+
|:---:|---|---|
|
|
131
|
+
| **2002** | Key Inválida | Verifica tu `Server-Key` en el juego. |
|
|
132
|
+
| **3002** | Servidor Offline | El servidor no tiene jugadores o está apagado. |
|
|
133
|
+
| **4001** | Rate Limit | Estás enviando muchas peticiones muy rápido. |
|
|
134
|
+
| **403** | No Autorizado | Verifica tus permisos o tokens. |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🔗 Enlaces Útiles
|
|
139
|
+
|
|
140
|
+
- [Documentación Oficial de PRC](https://apidocs.policeroleplay.community/)
|
|
141
|
+
- [Discord de Soporte PRC](https://discord.gg/prc)
|
|
142
|
+
- [NPM Package](https://www.npmjs.com/package/erlc-api)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
<div align="center">
|
|
147
|
+
<sub>Hecho con ❤️ para la comunidad de ER:LC</sub>
|
|
148
|
+
</div>
|