-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.gohtml
145 lines (129 loc) · 9.03 KB
/
docs.gohtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Minecraft Server API</title>
<meta name="description" content="Super simple HTTP API for basic Minecraft (Java Edition) server info, including player count and protocol.">
<meta name="keywords" content="Minecraft Server Ping, Minecraft Server API, Minecraft REST API, Minecraft Server REST">
<meta property="og:title" content="Minecraft Server API">
<meta property="og:site_name" content="Minecraft Server API">
<meta property="og:description" content="Super simple HTTP API for basic Minecraft (Java Edition) server info, including player count and protocol.">
<meta property="og:image" content="/assets/cover.jpg">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:title" content="Minecraft Server API">
<meta property="twitter:site" content="@graphiteIsaac">
<meta property="twitter:description" content="Super simple HTTP API for basic Minecraft (Java Edition) server info, including player count and protocol.">
<meta property="twitter:image" content="/assets/cover.jpg">
<link rel="icon" href="/assets/favicon.svg">
<style>{{ .style|css }}</style>
</head>
<body>
<header>
<h5>v{{ .version }}</h5>
<h1>Minecraft Server API</h1>
<p>Super simple HTTP API for basic Minecraft (Java) server info</p>
<a href="https://github.com/graphiteisaac/go-mcapi">
<svg width="20" height="20" viewBox="0 0 20 20" fill="#72767A" xmlns="http://www.w3.org/2000/svg">
<path d="M6.48047 15.5234C6.48047 15.6016 6.39062 15.6641 6.27734 15.6641C6.14844 15.6758 6.05859 15.6133 6.05859 15.5234C6.05859 15.4453 6.14844 15.3828 6.26172 15.3828C6.37891 15.3711 6.48047 15.4336 6.48047 15.5234ZM5.26563 15.3477C5.23828 15.4258 5.31641 15.5156 5.43359 15.5391C5.53516 15.5781 5.65234 15.5391 5.67578 15.4609C5.69922 15.3828 5.625 15.293 5.50781 15.2578C5.40625 15.2305 5.29297 15.2695 5.26563 15.3477ZM6.99219 15.2813C6.87891 15.3086 6.80078 15.3828 6.8125 15.4727C6.82422 15.5508 6.92578 15.6016 7.04297 15.5742C7.15625 15.5469 7.23437 15.4727 7.22266 15.3945C7.21094 15.3203 7.10547 15.2695 6.99219 15.2813ZM9.5625 0.3125C4.14453 0.3125 0 4.42578 0 9.84375C0 14.1758 2.72656 17.8828 6.62109 19.1875C7.12109 19.2773 7.29688 18.9688 7.29688 18.7148C7.29688 18.4727 7.28516 17.1367 7.28516 16.3164C7.28516 16.3164 4.55078 16.9023 3.97656 15.1523C3.97656 15.1523 3.53125 14.0156 2.89062 13.7227C2.89062 13.7227 1.99609 13.1094 2.95312 13.1211C2.95312 13.1211 3.92578 13.1992 4.46094 14.1289C5.31641 15.6367 6.75 15.2031 7.30859 14.9453C7.39844 14.3203 7.65234 13.8867 7.93359 13.6289C5.75 13.3867 3.54688 13.0703 3.54688 9.3125C3.54688 8.23828 3.84375 7.69922 4.46875 7.01172C4.36719 6.75781 4.03516 5.71094 4.57031 4.35937C5.38672 4.10547 7.26562 5.41406 7.26562 5.41406C8.04688 5.19531 8.88672 5.08203 9.71875 5.08203C10.5508 5.08203 11.3906 5.19531 12.1719 5.41406C12.1719 5.41406 14.0508 4.10156 14.8672 4.35937C15.4023 5.71484 15.0703 6.75781 14.9688 7.01172C15.5938 7.70313 15.9766 8.24219 15.9766 9.3125C15.9766 13.082 13.6758 13.3828 11.4922 13.6289C11.8516 13.9375 12.1563 14.5234 12.1563 15.4414C12.1563 16.7578 12.1445 18.3867 12.1445 18.707C12.1445 18.9609 12.3242 19.2695 12.8203 19.1797C16.7266 17.8828 19.375 14.1758 19.375 9.84375C19.375 4.42578 14.9805 0.3125 9.5625 0.3125ZM3.79687 13.7852C3.74609 13.8242 3.75781 13.9141 3.82422 13.9883C3.88672 14.0508 3.97656 14.0781 4.02734 14.0273C4.07812 13.9883 4.06641 13.8984 4 13.8242C3.9375 13.7617 3.84766 13.7344 3.79687 13.7852ZM3.375 13.4687C3.34766 13.5195 3.38672 13.582 3.46484 13.6211C3.52734 13.6602 3.60547 13.6484 3.63281 13.5938C3.66016 13.543 3.62109 13.4805 3.54297 13.4414C3.46484 13.418 3.40234 13.4297 3.375 13.4687ZM4.64063 14.8594C4.57813 14.9102 4.60156 15.0273 4.69141 15.1016C4.78125 15.1914 4.89453 15.2031 4.94531 15.1406C4.99609 15.0898 4.97266 14.9727 4.89453 14.8984C4.80859 14.8086 4.69141 14.7969 4.64063 14.8594ZM4.19531 14.2852C4.13281 14.3242 4.13281 14.4258 4.19531 14.5156C4.25781 14.6055 4.36328 14.6445 4.41406 14.6055C4.47656 14.5547 4.47656 14.4531 4.41406 14.3633C4.35938 14.2734 4.25781 14.2344 4.19531 14.2852Z"/>
</svg>
<span>GitHub</span>
</a>
</header>
<main>
<div class="req">
<div>
<div class="label">
<code class="method">GET</code>
<span class="route">/v1/ping/{ip}</span>
</div>
<p>Get basic information</p>
</div>
<section>
<button class="tooltip" onclick="copy('ping')">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.125 0C5.15977 0 4.375 0.784766 4.375 1.75V7.875C4.375 8.84023 5.15977 9.625 6.125 9.625H12.25C13.2152 9.625 14 8.84023 14 7.875V1.75C14 0.784766 13.2152 0 12.25 0H6.125ZM1.75 4.375C0.784766 4.375 0 5.15977 0 6.125V12.25C0 13.2152 0.784766 14 1.75 14H7.875C8.84023 14 9.625 13.2152 9.625 12.25V10.5H7.875V12.25H1.75V6.125H3.5V4.375H1.75Z" fill="#AAAAB6"/>
</svg>
<span>Copy</span>
</button>
<code class="url" data-url="ping">mc-api.co/v1/<span class="white">ping</span>/<span class="blue">your.server.ip</span></code>
</section>
</div>
<div class="req">
<div>
<div class="label">
<code class="method">GET</code>
<span class="route">/v1/icon/{ip}</span>
</div>
<p>Get server icon image</p>
</div>
<section>
<button class="tooltip" onclick="copy('icon')">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.125 0C5.15977 0 4.375 0.784766 4.375 1.75V7.875C4.375 8.84023 5.15977 9.625 6.125 9.625H12.25C13.2152 9.625 14 8.84023 14 7.875V1.75C14 0.784766 13.2152 0 12.25 0H6.125ZM1.75 4.375C0.784766 4.375 0 5.15977 0 6.125V12.25C0 13.2152 0.784766 14 1.75 14H7.875C8.84023 14 9.625 13.2152 9.625 12.25V10.5H7.875V12.25H1.75V6.125H3.5V4.375H1.75Z" fill="#AAAAB6"/>
</svg>
<span>Copy</span>
</button>
<code class="url" data-url="icon">mc-api.co/v1/<span class="white">icon</span>/<span class="blue">your.server.ip</span></code>
</section>
</div>
<h4 style="text-align:center;margin-bottom:1.6rem">Try it out!</h4>
<div class="try">
<form id="ping" autocomplete="off">
<div>mc-api.co/v1/ping/</div>
<input type="text" name="ip" autocomplete="off" aria-label="IP Address">
<button type="submit">Ping</button>
</form>
<div id="error" style="display:none">Could not ping server</div>
<div id="loader" style="display:none">Loading...</div>
<div class="result" style="display:none">
<img src="" id="icon" alt="Server Icon">
<div>
<div id="ip">play.server.com</div>
<div id="players">10/10 online</div>
</div>
</div>
</div>
</main>
<footer>
<h2>Found a problem?</h2>
<p>Chat with me on <a href="https://discord.com/users/204084691425427466" target="_blank">Discord</a>, or make a pull request on <a href="https://github.com/graphiteisaac/go-mcapi">GitHub</a></p>
<p class="small">Made by @graphiteIsaac</p>
</footer>
<script>
function copy(method) {
window.navigator.clipboard.writeText(`https://mc-api.co/v1/${method}/`)
document.querySelector('.url[data-url=' + method + ']').classList.add('active')
setTimeout(() => {
document.querySelector('.url[data-url=' + method + ']').classList.remove('active')
}, 2000)
}
document.getElementById('ping').addEventListener('submit', async (e) => {
e.preventDefault()
const fd = new FormData(e.target)
const ip = fd.get('ip')
if (ip.length < 3) return
document.querySelector('.result').style.display = 'none'
document.getElementById('loader').style.display = 'block'
try {
const req = await fetch(document.location.origin + '/v1/ping/' + ip + "?icon=true")
const { favicon, players } = await req.json()
if (req.status !== 200) {
throw req.status
}
document.getElementById('ip').innerText = ip.toString()
document.getElementById('players').innerText = players.online + ' / ' + players.max + ' online'
document.getElementById('icon').src = favicon
document.getElementById('loader').style.display = 'none'
document.getElementById('error').style.display = 'none'
document.querySelector('.result').style.display = 'flex'
} catch(e) {
document.getElementById('error').style.display = 'block'
}
document.getElementById('loader').style.display = 'none'
})
</script>
</body>
</html>