Skip to content

The Node.js library for interacting with the mcstatus.io API.

License

Notifications You must be signed in to change notification settings

mcstatus-io/node-mcstatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e647d37 · May 31, 2024

History

22 Commits
Mar 19, 2023
Apr 7, 2024
Jul 24, 2023
Jul 24, 2023
Mar 19, 2023
Feb 17, 2023
Jun 8, 2023
May 31, 2024
May 31, 2024
Mar 19, 2023

Repository files navigation

node-mcstatus

The official Node.js library for interacting with the mcstatus.io API.

Getting Started

Firstly, you will need to install the library. Open your terminal/command line in your workspace where your package.json file is located, and run the following command.

npm install node-mcstatus

Usage

Java Status

const mcs = require('node-mcstatus');

// ...

const host = 'demo.mcstatus.io';
const port = 25565;
const options = { query: true };

// The `port` argument is optional and defaults
// to 25565. The `options` argument is optional.
mcs.statusJava(host, port, options)
    .then((result) => {
        // `result` will be the same shape and
        // properties as what is documented on
        // our website.
        // https://mcstatus.io/docs#java-status
    })
    .catch((error) => {
        // If the server is offline, then
        // you will NOT receive an error here.
        // Instead, you will use the `result.online`
        // boolean values in `.then()`.
        // Receiving an error here means that there
        // was an error with the service itself.
    })

Bedrock Status

const mcs = require('node-mcstatus');

// ...

const host = 'demo.mcstatus.io';
const port = 19132;

// The `port` argument is optional and defaults
// to 19132.
mcs.statusBedrock(host, port)
    .then((result) => {
        // ...
        // `result` will be the same shape and
        // properties as what is documented on
        // our website.
        // https://mcstatus.io/docs#bedrock-status
    })
    .catch((error) => {
        // If the server is offline, then
        // you will NOT receive an error here.
        // Instead, you will use the `result.online`
        // boolean values in `.then()`.
        // Receiving an error here means that there
        // was an error with the service itself.
    })

License

MIT License