mcapi

package
v0.0.0-...-89ddf38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 6 Imported by: 0

README

MCApi.us Golang Client

GoDoc

You may use this client to get the status of a server from MCApi.us.

There are two methods for the two functions the API provides, GetServerStatus and GetServerQuery. It should be fairly easy to understand how to use either from the godoc.

Documentation

Overview

Package mcapi has methods for requesting information from mcapi.us

Index

Examples

Constants

This section is empty.

Variables

View Source
var APIEndpoint = "https://mcapi.us"

APIEndpoint is the endpoint to use for requesting any information.

Functions

func GetServerQuery

func GetServerQuery(ip string, port int) (*types.ServerQuery, error)

GetServerQuery allows you to query a server to get more detailed information.

Note that this function requires you to have query enabled on your server.

Example
status, err := GetServerQuery("mc.syfaro.net", 25565)
if err != nil {
	panic(err)
}

fmt.Printf("You have %d/%d players on a server running %s!", status.Players.Now, status.Players.Max, status.ServerMod)
Output:

You have 0/20 players on a server running CraftBukkit on Bukkit 1.8.3-R0.1-SNAPSHOT!

func GetServerStatus

func GetServerStatus(ip string, port int) (*types.ServerStatus, error)

GetServerStatus allows you to ping a server and get basic information.

Example
status, err := GetServerStatus("mc.syfaro.net", 25565)
if err != nil {
	panic(err)
}

fmt.Printf("You have %d/%d players online!", status.Players.Now, status.Players.Max)
Output:

You have 0/20 players online!

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL