Asyncronous Python wrapper for the BattleMetrics API.
Project description
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file battlemetrics-2.0.5.tar.gz.
File metadata
- Download URL: battlemetrics-2.0.5.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db76200bd7b4873ea5020e1bfc936498701e1c9f60f0e419fd32c783568876b8
|
|
| MD5 |
7b55479cda33bfafc1646c51634ecc85
|
|
| BLAKE2b-256 |
65b1de131135f9f03b87ab68de875ed3e159caba0c437b93875830ecf32f80c2
|
Provenance
The following attestation bundles were made for battlemetrics-2.0.5.tar.gz:
Publisher:
release.yml on OseSem/battlemetrics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
battlemetrics-2.0.5.tar.gz -
Subject digest:
db76200bd7b4873ea5020e1bfc936498701e1c9f60f0e419fd32c783568876b8 - Sigstore transparency entry: 928460983
- Sigstore integration time:
-
Permalink:
OseSem/battlemetrics@57e604e46d351f587b8702742ed686e696968d76 -
Branch / Tag:
refs/tags/v2.0.5 - Owner: https://github.com/OseSem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@57e604e46d351f587b8702742ed686e696968d76 -
Trigger Event:
push
-
Statement type:
File details
Details for the file battlemetrics-2.0.5-py3-none-any.whl.
File metadata
- Download URL: battlemetrics-2.0.5-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc629867f6f796186872fc584f9f0669fec49fef3e75885ab8caa2dc2469ce2
|
|
| MD5 |
dbeb0c4d2590a37f4bd8ff21463cab04
|
|
| BLAKE2b-256 |
8e87efde4100600344bdb5b50ed223e5209ec2906f1842e34da0ff64a984bd25
|
Provenance
The following attestation bundles were made for battlemetrics-2.0.5-py3-none-any.whl:
Publisher:
release.yml on OseSem/battlemetrics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
battlemetrics-2.0.5-py3-none-any.whl -
Subject digest:
8bc629867f6f796186872fc584f9f0669fec49fef3e75885ab8caa2dc2469ce2 - Sigstore transparency entry: 928460986
- Sigstore integration time:
-
Permalink:
OseSem/battlemetrics@57e604e46d351f587b8702742ed686e696968d76 -
Branch / Tag:
refs/tags/v2.0.5 - Owner: https://github.com/OseSem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@57e604e46d351f587b8702742ed686e696968d76 -
Trigger Event:
push
-
Statement type: