API Documentation
Access game server statistics programmatically with our RESTful API
Quick Start
The MetricsGame API provides access to real-time game server statistics. All endpoints return JSON responses and are free to use with reasonable rate limits.
Base URL
https://metricsgame.com
Format
JSON
Auth
None Required
Rate Limits
•
100 requests/hour per IP address
•
1,000 requests/day per IP address
Need higher limits? Contact us for enterprise solutions.
Available Endpoints
GET
Get Server Data
Retrieve detailed information about a specific game server including current players, max players, map, gamemode, and more.
Endpoint
/api/server/data/{id}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer |
✓ Yes | Unique server identifier |
Example Request
curl -X GET "https://metricsgame.com/api/server/data/12345" \
-H "Accept: application/json"
Example Response
{
"status": "success",
"data": {
"id": 12345,
"name": "My Awesome GMod Server",
"ip": "192.168.1.100",
"port": 27015,
"game_id": 1,
"game_name": "Garry's Mod",
"current_players": 18,
"max_players": 32,
"map": "rp_downtown_v4c_v2",
"gamemode": "DarkRP",
"country": "US",
"ping": 45,
"version": "2023.11.10",
"password_protected": false,
"secure": true,
"last_seen": "2025-12-09T14:30:00Z",
"status": "online"
}
}
Error Response
{
"status": "error",
"message": "Server not found",
"code": 404
}
HTTP Response Codes
| Code | Status | Description |
|---|---|---|
200 |
OK | Request successful |
400 |
Bad Request | Invalid parameters or malformed request |
404 |
Not Found | Server or resource not found |
429 |
Too Many Requests | Rate limit exceeded |
500 |
Internal Server Error | Server error, please try again later |
Code Examples
JavaScript
// Using Fetch API
fetch('https://metricsgame.com/api/server/data/12345')
.then(response => response.json())
.then(data => {
console.log(data);
console.log(`Server: ${data.data.name}`);
console.log(`Players: ${data.data.current_players}/${data.data.max_players}`);
})
.catch(error => console.error('Error:', error));
Python
import requests
response = requests.get(
'https://metricsgame.com/api/server/data/12345'
)
if response.status_code == 200:
data = response.json()
server = data['data']
print(f"Server: {server['name']}")
print(f"Players: {server['current_players']}/{server['max_players']}")
PHP
$url = 'https://metricsgame.com/api/server/data/12345';
$response = file_get_contents($url);
$data = json_decode($response, true);
if ($data['status'] === 'success') {
$server = $data['data'];
echo "Server: " . $server['name'] . "\n";
echo "Players: " . $server['current_players'] . "/" . $server['max_players'];
}
Node.js
const axios = require('axios');
axios.get('https://metricsgame.com/api/server/data/12345')
.then(response => {
const server = response.data.data;
console.log(`Server: ${server.name}`);
console.log(`Players: ${server.current_players}/${server.max_players}`);
})
.catch(error => console.error('Error:', error));
Best Practices
✓
Cache responses - Store API responses locally for at least 1-2 minutes to reduce redundant calls
✓
Handle errors gracefully - Always check response status and handle errors appropriately
✓
Respect rate limits - Implement exponential backoff when hitting rate limits
✓
Use compression - Enable gzip compression in your HTTP client to reduce bandwidth
✗
Don't hammer the API - Avoid making rapid sequential requests for the same data
✗
Don't bypass limits - Using multiple IPs or proxies to bypass rate limits may result in a ban
Need Help?
Have questions about the API or need assistance? Our team is here to help!
Coming Soon
We're constantly improving our API. Here's what's coming next:
- Search servers by name or IP
- Get historical server statistics
- List servers by game
- WebSocket support for real-time updates
- API authentication for higher rate limits