Skip to main content

BattleMetrics API Wrapper

Ruff PyPI - Version PyPI - Downloads

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for battlemetrics 2.1.1
File Size Uploaded Provenance Actions
battlemetrics-2.1.1.tar.gz 28.6 kB With provenance Details for battlemetrics-2.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for battlemetrics 2.1.1
File Interpreter ABI Platform Actions
battlemetrics-2.1.1-py3-none-any.whl Python 3 none any Details for battlemetrics-2.1.1-py3-none-any.whl

Total release size: 61.1 kB

Release files / battlemetrics-2.1.1.tar.gz

Download URL battlemetrics-2.1.1.tar.gz
Size 28.6 kB
Tags Source
SHA-256 checksum
How to use checksums
96c9d3e247d8f3d07e22cac944d11b1d3650dcfb800c330c07ed3ea0690933ec
BLAKE2b-256 checksum
How to use checksums
6b0a88f0b14322b005d3b5824f42ee6f743e6e1bf8356902806a7a24332997f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Release files / battlemetrics-2.1.1-py3-none-any.whl

Download URL battlemetrics-2.1.1-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbd3cf4e098f1023c733e6952551aecfe56984c68e2b7ac5aed52b55e79d7623
BLAKE2b-256 checksum
How to use checksums
21c08bc93fd3f256a86135789fd6d9e5c82309d302c6d63d50540acabb8a8d30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Security for battlemetrics 2.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for battlemetrics-2.1.1.tar.gz

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 Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page