Presentation
Hello ! I created a npm package to interact with the Cfx.re API and fetching some data from it and the status page.
Here are some of the things you can do :
- Retrieving a FiveM/RedM server data:
- Hostname
- Connected players
- Active resources
- Public variables (tags, oneSync enabled etc.)
- Owner data (id, cfx username, avatar)
- Upvote power
- … And much more !
- Retrieving Cfx.re services status from the status page:
- Check if all services are ok
- Check every components individually
This project will be maintained and I will update it as I am able to add new features.
JavaScript developers are welcome to contribute to the project and improve it and/or add new features!
Download / Using
The project is available on GitHub: GitHub - PABLO-1610/cfx-api: JavaScript library to interact with the Cfx.re API (FiveM/RedM)
Or if you just want to add it to an existing node project:
npm i cfx-api
Usage example
const cfx = require("cfx-api");
(async () => {
// Retrieve a CitizenFX server (could be a FiveM or a RedM server)
const server = await cfx.fetchServer("qrbm5v") // Replace "qrpm7v" with a server id
console.log(`Server: ${server.hostname} has ${server.players.length} players online`);
// Retrieve Cfx.re status
const status = await cfx.fetchStatus()
console.log(status.everythingOk ? "All Cfx.re systems are operational" : "Cfx.re is experiencing issues");
// And get status of all individual components
const components = await status.fetchComponents()
for (let component of components) {
console.log(`${component.name}: ${component.status}`);
}
})();
Some projets to do with
Here some ideas:
- Discord bot to retrieve server data
- Fetching a server to display its logo on a website
- A status alert when FiveM is encountering an issue