# mcsrvstat-wrapper

> A Javascript Wrapper for the MCSRVSTAT Web API -- fetch Minecraft server status

Latest version **1.0.4** (published 2023-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install mcsrvstat-wrapper
pnpm add mcsrvstat-wrapper
yarn add mcsrvstat-wrapper
bun add mcsrvstat-wrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-04-08 |
| First published | 2021-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alex / azpha |
| Maintainers | awexx |
| Keywords | mcsrvstat, minecraft, status, server, javascript |

## Links

- npm: https://www.npmjs.com/package/mcsrvstat-wrapper
- Repository: https://github.com/azpha/mcsrvstat-js
- Homepage: https://github.com/azpha/mcsrvstat-js#readme
- Issues: https://github.com/azpha/mcsrvstat-js/issues
- npm.io page: https://npm.io/package/mcsrvstat-wrapper

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.3.4

## Recent versions

- 1.0.4 (latest) — 2023-04-08
- 1.0.3 — 2023-04-05
- 1.0.2 — 2021-07-06
- 1.0.1 — 2021-07-05
- 1.0.0 — 2021-07-03

## README

# <p align="center"><a href="https://api.mcsrvstat.us">MCSRVSTAT</a> Simple Javascript Wrapper</p>
<p align="center"><i>I do not own MCSRVSTAT, this is simply a wrapper for their API :)</i></p>

<p align="center">
<a href="https://npmjs.com/package/mcsrvstat-wrapper"><img src="https://nodei.co/npm/mcsrvstat-wrapper.png?downloads=true&downloadRank=true&stars=true"></a>

<p align="center">Easily fetch the status of a Minecraft server (Java or Bedrock) all from Node!</p>

# How do I use this?
You can utilize the following methods below.  
If something is missing from these responses that are returned from [MCSRVSTAT's API](https://api.mcsrvstat.us/) and you'd like to see them supported, create an issue!

## fetchJavaServer
Fetch the status of a Minecraft Java server
```js
const serverInfo = await fetchJavaServer('hostname.example.com');
console.log(serverInfo);
// { online: true, version: 'Requires MC 1.8 / 1.19', players: { online: 5, max: 20 }, connection: { ip: 'xxx.xxx.xxx.xxx', hostname: 'hostname.example.com' } }
```

## fetchBedrockServer
Fetch the status of a Minecraft Bedrock server
```js
const serverInfo = await fetchBedrockServer('hostname.example.com');
console.log(serverInfo);
// { online: true, version: 'x.xx.xx', players: { online: 5, max: 20 }, connection: { ip: 'xxx.xxx.xxx.xxx', hostname: 'hostname.example.com' } }
```

## fetchIcon
Generates a link to the servers icon
```js
let url = await mcsrvstat.fetchIcon('hostname.example.com');
console.log(url)
// 'https://api.mcsrvstat.us/icon/hostname.example.com'
```

## getJavaHttp
Returns the status of a Minecraft Java server using HTTP status code conventions.  
`200` is expected for Online and `404` is expected for Offline.
```js
const httpCode = await mcsrvstat.javaHttpCode('hostname.example.com');
console.log(httpCode);
// 200/404
```

## getBedrockHttp
Returns the status of a Minecraft Bedrock server using HTTP status code conventions.  
`200` is expected for Online and `404` is expected for Offline.
```js
const httpCode = await mcsrvstat.javaHttpCode('hostname.example.com');
console.log(httpCode);
// 200/404
```

---
_Source: https://npm.io/package/mcsrvstat-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
