beatsaber-playlist-tool/docs/ClientWrapperUsage.md

1.3 KiB

API Client Wrapper Usage

BeatLeaderClient

from helpers.BeatLeaderAPI import BeatLeaderAPI
from clients.beatleader.models.scores_sort_by import ScoresSortBy
from clients.beatleader.models.order import Order

# Instantiate the API client
beatleader_api = BeatLeaderAPI()

# Specify the player ID you want to fetch scores for
player_id = "76561199407393962"

# Fetch player scores
scores_data = beatleader_api.get_player_scores(
    player_id=player_id,
    use_cache=True,            # Use cached data if available
    count=100,                 # Number of scores per page
    sort_by=ScoresSortBy.DATE, # Sort scores by date
    order=Order.DESC,          # In descending order
    max_pages=2                # Maximum number of pages to fetch
)
print(f"Got {len(scores_data.get('playerScores'))} scores for player {player_id}")

BeatSaverClient

from helpers.BeatSaverAPI import BeatSaverAPI
beatsaver_api = BeatSaverAPI()
map_data = beatsaver_api.get_maps(year=2024, month=9)

SimpleBeatLeaderAPI

from helpers.SimpleBeatLeaderAPI import SimpleBeatLeaderAPI
player_id = "76561199407393962"
beatleader_api = SimpleBeatLeaderAPI()
data = beatleader_api.get_player_accgraph(player_id)
data[0]
filtered_data = [{'acc': item['acc'], 'stars': item['stars'], 'hash': item['hash']} for item in data]
filtered_data[0]