[go: up one dir, main page]

Skip to content

JavaScript library to interact with the Cfx.re API (FiveM/RedM)

License

Notifications You must be signed in to change notification settings

pablo-1610/cfx-api

Repository files navigation

Cfx.re JavaScript API

A package that helps you interacting with the Cfx.re, FiveM & RedM API.


How to install

npm i cfx-api

Example usage:

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}`);
})();