Getting leaderboards and individual points using Fuul SDK

This article shows how to get point rewards - individually or in a leaderboard format

Projects can decide to show a leaderboard or a user profile on their own website.

Leaderboard

To get the points leaderboard for your project use the getPointsLeaderboard method.

import { Fuul } from ('@fuul/sdk');

await Fuul.getPointsLeaderboard();

A simple response for retrieving this information would be the following:

{
  "total_results": 100,
  "page": 1,
  "page_size": 10,
  "results": [
    {
      "address": "0xBfBAdD58B65B54D1a5cEa6d9c730fbd57c182d32",
      "total_amount": 200,
      "rank": 1,
      "total_attributions": 10
      
    },
    {
      "address": "0xg9BAdD58B65B54D1a5c216d9c730fbd57c182d56",
      "total_amount": 200,
      "rank": 2,
      "total_attributions": 10
    }
  ]
}

You can also filter out this information for a specific user by passing on the user_address, dates with the from and to parameters, and type of users with user_type.

import { Fuul } from ('@fuul/sdk');

await Fuul.getPointsLeaderboard({ 
    user_address: '0x12345',
    from: new Date('2021-01-01'),
    to: new Date('2022-01-01'),
    user_type: 'all' // all, affiliate or end_user
});

You can retrieve the tier and the volume information of users by adding them on the fields parameter as follows:

import { Fuul } from ('@fuul/sdk');

await Fuul.getPointsLeaderboard(fields: 'tier,referred_volume');

The referred_volume parameter will be returned in USD values.

Points for a specific address per conversion

To get all points for an address use the getUserPointsByConversion method.

import { Fuul } from ('@fuul/sdk');

await Fuul.getUserPointsByConversion({ user_address: '0x12345' });

You can also filter out dates as follows:

import { Fuul } from ('@fuul/sdk');

await Fuul.getUserPointsByConversion({
      user_address: '0x12345',
      from: new Date('2021-01-01'),
      to: new Date('2022-01-01'),
});

A simple response for retrieving this information would be the following:

{
  "total_results": 100,
  "page": 1,
  "page_size": 10,
  "results": [
    {
      "is_referrer": true,
      "conversion_id": "4bdabf2c-271a-4d66-afd0-a9f24119810a",
      "conversion_name": "Buy",
      "total_amount": 200
    },
    {
      "is_referrer": false,
      "conversion_id": "4bdabf2c-271a-4d66-afd0-a9f24119810a",
      "conversion_name": "Buy",
      "total_amount": 400
    }
  ]
}

You can also get the data directly from the API. Please check out our interactive documentation here

Last updated