Documentation
Sync Galxe Points with Bandit's Leaderboard

Sync Galxe Points with Bandit's Leaderboard

This guide explain how to pull XP data from Galxe and update XP values in Bandit's leaderboard. This will help you keep the XP values in sync between Galxe and Bandit.

Step 1: Pull User XP Data from Galxe

To begin, you need to use the Galxe GraphQL API to pull the latest user XP data. This data will be used to calculate the XP differences. Please refer to the Galxe API Documentation (opens in a new tab) for more details on how to make the API request.

Step 2: Calculate XP Difference

In this step, you will fetch the latest XP data from Galxe and retrieve the previously stored XP data from the database. Follow these substeps:

2.1 Fetch Latest XP Data

Make an API call to Galxe to fetch the latest XP data for each user.

2.2 Retrieve Previously Stored XP Data

Query the database to get the stored XP for each user. This will be used to calculate the difference in XP.

2.3 Compute the Difference in XP

For each user, calculate the difference between the current XP and the previously stored XP. If there is no previous record for a user, consider the difference as the full XP value.

2.4 Update the Database

Update the database with the new XP values. Store the new XP value into the database for future reference.

Step 3: Update XP to Bandit

In this step, you will use the Bandit Custom XP API (opens in a new tab) to update the XP for each user based on the computed differences.

Refer to the Bandit Custom XP API documentation for more details on how to make the API request.

Example Workflow

Here's an example workflow to help you understand the process:

Day 1

  1. Fetch XP from Galxe: Pulled XP - 1000XP
  2. Store in Database: Store 1000XP
  3. Update Bandit: Update 1000XP

Day 2

  1. Fetch XP from Galxe: Pulled XP - 1500XP
  2. Calculate Difference:
    • Previous XP: 1000XP
    • Current XP: 1500XP
    • Difference: 500XP
  3. Store in Database: Update stored XP to 1500XP
  4. Update Bandit: Update 500XP

That's it! You have successfully pulled user XP data from Galxe, calculated the XP differences, and updated the XP values in Bandit.

If you have any further questions, please refer to the respective API documentations for more details.