Skip to main content

Delete Leaderboard

For more detailed examples and guidance on implementing the Myria Leaderboard SDK, please refer to our TypeScript SDK samples on GitHub here. This repository includes practical examples demonstrating how to create, manage, and interact with leaderboards, making it easier for you to integrate leaderboard functionality into your projects.

Developer can delete leaderboard by using Developer API Key when the leaderboard is no longer available or inactive. To delete a leaderboard using the @myria/leaderboard-ts-sdk, follow the steps below.

Step 1: Initialize the Leaderboard Manager

As with creating a leaderboard, you first need to initialize the LeaderboardManager with the necessary parameters, including your environment type and the developerApiKey.

import { LeaderboardManager, InitLeaderboardParams, LeaderboardEnv } from '@myria/leaderboard-ts-sdk';

const developerApiKey = "YOUR_DEVELOPER_API_KEY";

const leaderboardParams: InitLeaderboardParams = {
env: LeaderboardEnv.staging, // Use your desired environment type
apiKey: developerApiKey,
};

const leaderboardManager = new LeaderboardManager(leaderboardParams);

Step 2: Identify the Leaderboard to Delete

Next, identify the leaderboard you want to delete by specifying its unique ID.

const leaderboardId = 55; // Replace with the actual leaderboard ID

Input Details:

Mandatory Fields:

  • leaderboardId: Leaderboard ID is required to perform delete the leaderboard

Step 3: Delete the Leaderboard

With the LeaderboardManager initialized and the leaderboard ID specified, you can delete the leaderboard by calling the deleteLeaderboardById method.

console.log("Deleting the leaderboard...");
const deleteLeaderboardResp = await leaderboardManager.deleteLeaderboardById(leaderboardId);

console.log("Deleted leaderboard response:", deleteLeaderboardResp);
console.log(JSON.stringify(deleteLeaderboardResp, null, 2));

Ouput Details:

  • ResponseDetails: HTTP 204 No Content Status

Summary

By following these steps, you can successfully delete a leaderboard using the @myria/leaderboard-ts-sdk. This process involves initializing the LeaderboardManager, specifying the leaderboard ID, and invoking the deleteLeaderboardById method to remove the leaderboard.

For more details on other operations and features, refer to the full documentation.