minecraft-server-status 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minecraft_server_status/__init__.py +4 -0
- minecraft_server_status/bedrock.py +64 -0
- minecraft_server_status/java.py +63 -0
- minecraft_server_status-0.0.1.dist-info/METADATA +225 -0
- minecraft_server_status-0.0.1.dist-info/RECORD +8 -0
- minecraft_server_status-0.0.1.dist-info/WHEEL +5 -0
- minecraft_server_status-0.0.1.dist-info/licenses/License +8 -0
- minecraft_server_status-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
class Bedrock:
|
|
5
|
+
def __init__(self, ip, port=19132, ttl = 10):
|
|
6
|
+
self.ip = ip
|
|
7
|
+
self.port = port
|
|
8
|
+
self._data = None
|
|
9
|
+
self._last_fetch = 0
|
|
10
|
+
self.ttl = ttl
|
|
11
|
+
|
|
12
|
+
def _fetch(self):
|
|
13
|
+
now = time.time()
|
|
14
|
+
|
|
15
|
+
if self._data is None or (now - self._last_fetch) > self.ttl: # only fetch once
|
|
16
|
+
try:
|
|
17
|
+
res = requests.get(
|
|
18
|
+
f"https://api.mcstatus.io/v2/status/bedrock/{self.ip}:{self.port}",
|
|
19
|
+
timeout=5
|
|
20
|
+
)
|
|
21
|
+
self._data = res.json()
|
|
22
|
+
self._last_fetch = now
|
|
23
|
+
except Exception as e:
|
|
24
|
+
# if request fails, keep old data instead of crashing
|
|
25
|
+
if self._data is None:
|
|
26
|
+
self._data = {"online": False, "error": str(e)}
|
|
27
|
+
|
|
28
|
+
return self._data
|
|
29
|
+
|
|
30
|
+
def status(self):
|
|
31
|
+
return self._fetch()["online"] or None
|
|
32
|
+
|
|
33
|
+
def ip_address(self):
|
|
34
|
+
return self._fetch()["ip_address"] or None
|
|
35
|
+
|
|
36
|
+
def port_number(self):
|
|
37
|
+
return self._fetch()["port"] or None
|
|
38
|
+
|
|
39
|
+
def expires_at(self):
|
|
40
|
+
return self._fetch()["expires_at"] or None
|
|
41
|
+
|
|
42
|
+
def server_minecraft_version(self):
|
|
43
|
+
return self._fetch()["version"] or None
|
|
44
|
+
|
|
45
|
+
def players(self):
|
|
46
|
+
return self._fetch()["players"] or None
|
|
47
|
+
|
|
48
|
+
def gameMode(self):
|
|
49
|
+
return self._fetch()["gamemode"] or None
|
|
50
|
+
|
|
51
|
+
def server_id(self):
|
|
52
|
+
return self._fetch()["server_id"] or None
|
|
53
|
+
|
|
54
|
+
def edition(self):
|
|
55
|
+
return self._fetch()["edition"] or None
|
|
56
|
+
|
|
57
|
+
def software(self):
|
|
58
|
+
return self._fetch()["software"] or None
|
|
59
|
+
|
|
60
|
+
def plugins(self):
|
|
61
|
+
return self._fetch()["plugins"] or []
|
|
62
|
+
|
|
63
|
+
def raw(self):
|
|
64
|
+
return self._fetch()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
class Java:
|
|
5
|
+
def __init__(self, ip, port=25565, ttl = 10):
|
|
6
|
+
self.ip = ip
|
|
7
|
+
self.port = port
|
|
8
|
+
self._data = None
|
|
9
|
+
self._last_fetch = 0
|
|
10
|
+
self.ttl = ttl
|
|
11
|
+
|
|
12
|
+
def _fetchJ(self):
|
|
13
|
+
now = time.time()
|
|
14
|
+
|
|
15
|
+
if self._data is None or (now - self._last_fetch)>self.ttl:
|
|
16
|
+
try:
|
|
17
|
+
data = requests.get(f"https://api.mcstatus.io/v2/status/java/{self.ip}:{self.port}", timeout=5)
|
|
18
|
+
self._data = data.json()
|
|
19
|
+
self._last_fetch = now
|
|
20
|
+
|
|
21
|
+
except Exception as e:
|
|
22
|
+
# if request fails, keep old data instead of crashing
|
|
23
|
+
if self._data is None:
|
|
24
|
+
self._data = {"online": False, "error": str(e)}
|
|
25
|
+
|
|
26
|
+
return self._data
|
|
27
|
+
|
|
28
|
+
def status(self):
|
|
29
|
+
return self._fetchJ()["online"] or None
|
|
30
|
+
|
|
31
|
+
def ip(self):
|
|
32
|
+
return self._fetchJ()["ip_address"] or None
|
|
33
|
+
|
|
34
|
+
def expires_at(self):
|
|
35
|
+
return self._fetchJ()["expires_at"] or None
|
|
36
|
+
|
|
37
|
+
def srv_record(self):
|
|
38
|
+
return self._fetchJ()["srv_record"] or None
|
|
39
|
+
|
|
40
|
+
def java_minecraft_version(self):
|
|
41
|
+
return self._fetchJ()["version"] or None
|
|
42
|
+
|
|
43
|
+
def players(self):
|
|
44
|
+
return self._fetchJ()["players"] or None
|
|
45
|
+
|
|
46
|
+
def message_of_the_day(self):
|
|
47
|
+
return self._fetchJ()["motd"] or None
|
|
48
|
+
|
|
49
|
+
def icon(self):
|
|
50
|
+
return self._fetchJ()["icon"] or None
|
|
51
|
+
|
|
52
|
+
def mods(self):
|
|
53
|
+
return self._fetchJ()["mods"] or None
|
|
54
|
+
|
|
55
|
+
def software(self):
|
|
56
|
+
return self._fetchJ()["software"] or None
|
|
57
|
+
|
|
58
|
+
def plugins(self):
|
|
59
|
+
return self._fetchJ()["plugins"] or []
|
|
60
|
+
|
|
61
|
+
def raw(self):
|
|
62
|
+
return self._fetchJ()
|
|
63
|
+
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minecraft_server_status
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python package for fetching Minecraft Java and Bedrock server status, players, version, and plugins.
|
|
5
|
+
Author-email: Arpit Jaiswal <arpitjaiswal9526@gmail.com>
|
|
6
|
+
License: The MIT License (MIT)
|
|
7
|
+
Copyright © 2026 Arpit Jaiswal
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: License
|
|
18
|
+
Requires-Dist: requests
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# minecraft_server_status
|
|
22
|
+
|
|
23
|
+
A lightweight Python package to fetch **Minecraft Java** and **Minecraft Bedrock** server status using the public **mcstatus.io API**.
|
|
24
|
+
|
|
25
|
+
This package provides simple classes and methods to check whether a server is online, view player counts, server version, plugins, software, and more — without handling raw HTTP requests yourself.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
* Supports **Minecraft Java Edition**
|
|
32
|
+
* Supports **Minecraft Bedrock Edition**
|
|
33
|
+
* **TTL-based caching** (auto refresh after set time)
|
|
34
|
+
* **Fail-safe network handling** (doesn’t crash on request errors)
|
|
35
|
+
* Configurable **timeout & TTL**
|
|
36
|
+
* Clean and simple method-based access
|
|
37
|
+
* Full **raw JSON** access available
|
|
38
|
+
* Minimal dependency (`requests` only)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Once published to PyPI:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install minecraft_server_status
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For local development:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
* Python **3.9+**
|
|
61
|
+
* `requests`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Project Structure
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
minecraft_server_status/
|
|
69
|
+
│
|
|
70
|
+
├── pyproject.toml
|
|
71
|
+
├── README.md
|
|
72
|
+
├── LICENSE
|
|
73
|
+
└── src/
|
|
74
|
+
└── minecraft_server_status/
|
|
75
|
+
├── __init__.py
|
|
76
|
+
├── java.py
|
|
77
|
+
└── bedrock.py
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Quick Start
|
|
83
|
+
|
|
84
|
+
### Java Server Example
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from minecraft_server_status import Java
|
|
88
|
+
|
|
89
|
+
# ttl = cache time in seconds (default 10)
|
|
90
|
+
server = Java("hypixel.net", ttl=15)
|
|
91
|
+
|
|
92
|
+
print(server.status()) # True / False
|
|
93
|
+
print(server.players()) # Player information
|
|
94
|
+
print(server.java_minecraft_version()) # Version details
|
|
95
|
+
print(server.plugins()) # Plugin list
|
|
96
|
+
print(server.raw()) # Full JSON response
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### Bedrock Server Example
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from minecraft_server_status import Bedrock
|
|
105
|
+
|
|
106
|
+
server = Bedrock("play.example.com", ttl=20)
|
|
107
|
+
|
|
108
|
+
print(server.status())
|
|
109
|
+
print(server.players())
|
|
110
|
+
print(server.server_minecraft_version())
|
|
111
|
+
print(server.software())
|
|
112
|
+
print(server.raw())
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## TTL Caching Explained
|
|
118
|
+
|
|
119
|
+
TTL (**Time To Live**) controls how often the API is called.
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
server = Java("hypixel.net", ttl=30)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
* First call → Fetches API
|
|
128
|
+
* Next calls within 30 sec → Uses cached data
|
|
129
|
+
* After 30 sec → Auto refreshes
|
|
130
|
+
|
|
131
|
+
This prevents:
|
|
132
|
+
|
|
133
|
+
* API spam
|
|
134
|
+
* Rate limits
|
|
135
|
+
* Slow performance
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Error Handling
|
|
140
|
+
|
|
141
|
+
If the API request fails:
|
|
142
|
+
|
|
143
|
+
* The package **does not crash**
|
|
144
|
+
* Old cached data is reused
|
|
145
|
+
* If no previous data exists → returns:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
{"online": False, "error": "..."}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Java Class Methods
|
|
154
|
+
|
|
155
|
+
| Method | Description |
|
|
156
|
+
| -------------------------- | -------------------------- |
|
|
157
|
+
| `status()` | Returns online status |
|
|
158
|
+
| `ip()` | Resolved IP address |
|
|
159
|
+
| `expires_at()` | Cache expiration timestamp |
|
|
160
|
+
| `srv_record()` | SRV record information |
|
|
161
|
+
| `java_minecraft_version()` | Minecraft version data |
|
|
162
|
+
| `players()` | Player count & sample list |
|
|
163
|
+
| `message_of_the_day()` | Server MOTD |
|
|
164
|
+
| `icon()` | Base64 server icon |
|
|
165
|
+
| `mods()` | Installed mods |
|
|
166
|
+
| `software()` | Server software name |
|
|
167
|
+
| `plugins()` | Plugin list |
|
|
168
|
+
| `raw()` | Full API JSON |
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Bedrock Class Methods
|
|
173
|
+
|
|
174
|
+
| Method | Description |
|
|
175
|
+
| ---------------------------- | -------------------------- |
|
|
176
|
+
| `status()` | Online status |
|
|
177
|
+
| `ip_address()` | Resolved IP |
|
|
178
|
+
| `port_number()` | Server port |
|
|
179
|
+
| `expires_at()` | Cache expiration timestamp |
|
|
180
|
+
| `server_minecraft_version()` | Version details |
|
|
181
|
+
| `players()` | Player data |
|
|
182
|
+
| `gameMode()` | Current game mode |
|
|
183
|
+
| `server_id()` | Unique server ID |
|
|
184
|
+
| `edition()` | Bedrock edition info |
|
|
185
|
+
| `software()` | Server software |
|
|
186
|
+
| `plugins()` | Plugin list |
|
|
187
|
+
| `raw()` | Full API JSON |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## How It Works
|
|
192
|
+
|
|
193
|
+
* Uses `https://api.mcstatus.io` internally
|
|
194
|
+
* Data is cached with **TTL**
|
|
195
|
+
* Network errors are handled gracefully
|
|
196
|
+
* Multiple method calls **do not trigger multiple API requests**
|
|
197
|
+
* Designed for bots, dashboards, and quick checks
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Notes
|
|
202
|
+
|
|
203
|
+
* If a field is unavailable, the method returns `None`
|
|
204
|
+
* Not intended for high-frequency real-time monitoring
|
|
205
|
+
* Depends on the availability of the mcstatus.io API
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
MIT License — see `LICENSE` file.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Author
|
|
216
|
+
|
|
217
|
+
**Arpit Jaiswal**
|
|
218
|
+
|
|
219
|
+
GitHub: [https://github.com/Arp1it](https://github.com/Arp1it)
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Contributing
|
|
224
|
+
|
|
225
|
+
Pull requests, bug reports, and improvements are welcome 🚀
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
minecraft_server_status/__init__.py,sha256=mfz8hFdkVVzs_hLhUKF87QTt9hidK0zK5wJHYrW5f18,85
|
|
2
|
+
minecraft_server_status/bedrock.py,sha256=9sII_MIMlLPfy9rpeJXXmkY8ZMkivlfNxKkMvLIAMuk,1834
|
|
3
|
+
minecraft_server_status/java.py,sha256=vVB4L5ZmVgNQ6nKhcrLWBHktBg8jxl6srUNND0WSEes,1770
|
|
4
|
+
minecraft_server_status-0.0.1.dist-info/licenses/License,sha256=HuF-5MUIM5L00Iw7lZNfVwyGzGe087dunonyyn1XdSE,1084
|
|
5
|
+
minecraft_server_status-0.0.1.dist-info/METADATA,sha256=Om_z_c6njJHuoxsgy6-3FJD9gceZMOK5Vk2_ncVc4iI,6697
|
|
6
|
+
minecraft_server_status-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
7
|
+
minecraft_server_status-0.0.1.dist-info/top_level.txt,sha256=euUTavhTiqGBpgjixixZuikd37LS6YYTwUpo5YFYyXQ,24
|
|
8
|
+
minecraft_server_status-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright © 2026 Arpit Jaiswal
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
minecraft_server_status
|