BattleMetrics API Wrapper
An async Python wrapper for the BattleMetrics API with full type safety using Pydantic models.
[!CAUTION] This API Wrapper is very new and partly untested. Please report any issues instantly.
[!NOTE] Since the BattleMetrics API Documentation is partly finished not every endpoint might be included. Make an Issue Report for any missing endpoints.
Installation
To install the latest published version off of PyPI, you can run the following command:
pip install battlemetrics
To install the development version from GitHub (requires Git):
pip install git+https://github.com/OseSem/battlemetrics
Usage
Basic Example
import asyncio
from battlemetrics import Battlemetrics
async def main():
client = Battlemetrics("your-api-key")
# Get server information
server = await client.get_server(12345)
print(f"Server: {server.attributes.name}")
print(f"Players: {server.attributes.players}/{server.attributes.max_players}")
await client.close()
asyncio.run(main())
Using the Context Manager
import asyncio
from battlemetrics import Battlemetrics
async def main():
async with Battlemetrics("your-api-key") as client:
# Search for players
players = await client.list_players(search="username", game="rust")
for player in players:
print(f"Player: {player.attributes.name} (ID: {player.id})")
# Get player session history
if players:
sessions = await client.player_session_history(players[0].id)
for session in sessions:
print(f"Session: {session.attributes.start} - {session.attributes.stop}")
asyncio.run(main())
Searching for Servers
import asyncio
from battlemetrics import Battlemetrics
async def main():
async with Battlemetrics("your-api-key") as client:
# Search for Rust servers in the US
servers = await client.list_servers(
search="vanilla",
game="rust",
countries=["US"],
page_size=10
)
for server in servers:
print(f"{server.attributes.name} - {server.attributes.players} players")
asyncio.run(main())
Metadata
Release files for battlemetrics 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| battlemetrics-2.1.0.tar.gz | 28.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| battlemetrics-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.0 kB
Release files / battlemetrics-2.1.0.tar.gz
| Download URL | battlemetrics-2.1.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c9c47d4bd54e30805239161be8fd01e0e2169e62d03d7dc81233a87b5079514
|
|
BLAKE2b-256 checksum How to use checksums |
a8638cd07ef8c8f3e0f94207fa342186b5069a3c82b43739e721b7bb19d08901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 12, 2026.
Transparency logRelease files / battlemetrics-2.1.0-py3-none-any.whl
| Download URL | battlemetrics-2.1.0-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd0aac8b6d67dd637e93a7a378111cc23089643665f257e34f263d9531aa08d3
|
|
BLAKE2b-256 checksum How to use checksums |
6f8eca9654ee83da2d6517166268a49f7c5ce525766919f84703a60cbf2162ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 12, 2026.
Transparency log