1.2.2 • Published 1 year ago

refmint-sdk v1.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

refmint-sdk

SDK for use with https://app.refmint.xyz or https://test.refmint.xyz

The Refmint SDK is for developers to be able to make API calls to the Refmint app server and testnet server. The following pages will describe how to make calls to the Refmint API. Developers will need to install the refmint-sdk to their project. This can be done using npm or by cloning the github project.

Update Note: As of v.1.1.18, there is now an enum for baseUrl when initializing the Refmint client. Previously, one had to pass the baseUrl endpoint string (i.e. 'https://testnet.refmint.xyz'). Now, instead of passing the base url, you must import the BaseURLOptions enum from refmint-sdk as show in the examples below. This enum has options of LOCAL, TESTNET (equivalent of https://test.refmint.xyz), and MAINNET (equivalent of https://app.refmint.xyz). Pass the enum value as shown in the examples below:

I.E.

Previously:

var refmintClient = new Refmint({ apiKey: api_key, baseUrl: "https://test.refmint.xyz" });

Is now:

var refmintClient = new Refmint({ apiKey: api_key, baseUrl: BaseURLOptions.TESTNET });

Update note: As of v.1.2.0, The Game and NFT project clients have been seperated. They are now seperate and can be initiated as below:

var refmintClient = new Refmint.Game({ apiKey: api_key, baseUrl: BaseURLOptions.TESTNET });

OR

var refmintClient = new Refmint.NFT({ apiKey: api_key, baseUrl: BaseURLOptions.TESTNET });

npm i refmint-sdk

Usage

Log Referral Example:

Arguments: custom_url: string // Custom URL of your project wallet_adress: string // wallet_adress of the new user being referred link_id: string // affiliate referral_id of the referrer email_address (optional): string // email address of the referred new user phone_number (optional): string // phone number of the referred new user

Response: { referral_link: string // ink to raffle refferal page, referral_id: string // affiliate referral_id of the referred user }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const wallet_adress = '0x123abc456def'; //insert wallet of referree here
const link_id = 'fqOm45Jv'; //example link id for an affiliate on the example project
const email_address = ''; // (optional) insert referree email here
const phone_number = '1234567890' // (optional) insert referree phone number here
const api_key = 'reYam27iBtMqeGuEhR2ywSV6440wo3gx2CcIC5IK6RNHRCvBoKAHdsNx3FyLz2t1'; //demo api key for testnet

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.logReferral(custom_url,wallet_adress,link_id,email_address,phone_number).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Log View Example:

Arguments: custom_url: string // Custom URL of your project link_id: string // affiliate referral_id of the referrer

Response: N/A

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const link_id = 'fqOm45Jv'; //example link id for an affiliate on the example project
const api_key = 'reYam27iBtMqeGuEhR2ywSV6440wo3gx2CcIC5IK6RNHRCvBoKAHdsNx3FyLz2t1'; //demo api key for testnet

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.logView(custom_url,link_id).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e)
});

Is Affiliate Check Example:

Arguments: custom_url: string // Custom URL of your project wallet_address: string // wallet_address of the user to be checked

Response: boolean

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = "refmintsdk";
const wallet_address = "0xE7bb679Fa033517393001e1E43b3d326016E0A0c";

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.isAffiliate(
      custom_url,
      wallet_address,
    ).then((resp) => {
      if (resp) {
        // do something if wallet_address belongs to an affiliate
      } else {
        // do something else if wallet_address doesn't belong to an affiliate
      }
}).catch(e => {
	console.log(e);
});

Affiliate Data Example:

Arguments: custom_url: string // Custom URL of your project wallet_address: string // wallet_address of the user to be checked

Response: { clicks: number, // the number of clicks/views of this project via the affiliate referrals: number, // the number of referred users by this affiliate referral_mints: number, // the number of mints by referred users from the affiliate amount_owed: number, // the commission earned from referred mints by this affiliate amount_claimable: number, //commissions from referred mints that haven't been claimed yet by the affiliate amount_claimed: number, // commissions from referred mints that have already been claimed the by affiliate additional_raffle_entries: number, // raffle entries earned from referring users type: ENUM string "PAID", "LINK", "RAFFLE", "LIVE", "DQ", // type of the affiliate is_on_allow_list: boolean, // boolean indicating if the affiliate is on the allowlist for the project link_id: string, // link id of the affiliate affiliate_link: string // link to the referral page where new us }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = "refmintsdk";
const wallet_address = "0xE7bb679Fa033517393001e1E43b3d326016E0A0c";

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.affiliateLink(
      custom_url,
      wallet_address,
    ).then((resp) => {
      
      // console.log(resp) example return:
      // {
      //     "clicks":0,
      //     "referrals":0,
      //     "referral_mints":0,
      //     "amount_owed":"0",
      //     "amount_claimable":"0",
      //     "amount_claimed":"0",
      //     "additional_raffle_entries":0,
      //     "type":"LIVE",
      //     "is_on_allow_list":false,
      //     "link_id":"toRMyGkK",
      //     "affiliate_link":"https://test.refmint.xyz/p/refmintsdk/toRMyGkK"
      //}
      
      // console.log(resp.clicks) // returns 0
      
}).catch(e => {
	console.log(e);
});

Modify Score Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign users: { wallet_adress: string // wallet_adress of the user whose score we want to add to score: number // how much to add to be added/subtracted to user score }[] // array of objects which has a wallet address and score to be added/subtracted to user score

Response: N/A

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const project_url = 'refmintsdk'; // custom url for the project
const campaign_url = 'campaignURL'; // custom url for the project
const users = [
  {
    wallet_address: '0x123abc456def',
    score: 10
  },
  {
    wallet_address: '0xabc123def456',
    score: -3
  },
];

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.modifyScore(custom_url,campaign_url,users).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Query Leaderboard Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign order_by: string // what to sort leaderboard by 'score' or referral page_size: number // how many users to include in query result page: number // which page of users to return, ie set to page to 2 and page size to 1o if you want users 11-20 with_points_only: boolean // whether to only include users with a score or not

Response: An array of objects: { createdat: number, // date this user object for the leaderboard was created project_id: string, // unique ID for the project referral: number, // number of referrals by the user for the project score: number, // the user's score for the project updated_at: number, // the date the user was last updated wallet_address: string, // the user's wallet address _id: string, // the user's unique id for the project } ,{ ... }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const project_url = 'refmintsdk'; //example project on testnet
const campaign_url = 'campaignURL'; //example campaign on testnet
const order_by = 'score'; // order the leaderboard by highgest score
const page_size = 10; // include 10 users in this request
const page = 1; // get the first (page_size) users , i.e. users 1-10 in this case with the top score
const with_points_only = true; // only include users in the list of their score is greater than 0

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.leaderboard(project_url,campaign_url,order_by,page_size,page,with_points_only).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

User Score Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign wallet_address: string // the wallet address of the user to check for a score

Response: { project_url: string, // custom_url of the project campaign_url: string, // custom_url of the campaign wallet_address: string, // wallet_address of user }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const campaign_url = 'myCampaignURL'; // example campaign in the project
const wallet_address = '0x123abc456def'; // example wallet_address

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.userScore(custom_url,campaign_url,wallet_address).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Add Users Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign users: { wallet_address: string, score: number, referral: number }[] // array of objects (object is a user object with a wallet_addres, the score, and referrals total) link_id?: string // optional, whether or not to attribute a referral, insert the link_id of the referrer

Response:

An array of user objects: { wallet_address: string // wallet_address of the referred user referral_link: string // referral link for new user for the campaign referral_id: string // added user's referral id } ,{ ... }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const campaign_url = 'myCampaignURL'; // example campaign
const users = [{wallet_address:'0x123abc456def', score: 0, referral: 0}]; // example user to be added
const link_id = 'fqOm45Jv'; // optional, example link_id of the referrer

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.addUsers(custom_url,campaign_url,users,link_id).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Referral Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign wallet_address: string // the wallet address of the user to add a referral to referral_only: boolean // true if only to count referral, false if you want to add points as well (based on campaign points_per_referral)

Response: N/A

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const project_url = 'refmintsdk'; //example project on testnet
const campaign_url = 'myCampaignURL'; // example campaign
const wallet_address = '0x123abc456def'; // example wallet_address to add referral to
const referral_only = true; // only add referral (or false to add points as well)

var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.referral(project_url,campaign_url,wallet_address,referral_only).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Is User Example:

Arguments: custom_url: string // Custom URL of your project wallet_address: string // wallet addresses to check if user of project

Response: boolean

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const wallet_address = '0x123abc456def'; //wallet address to check


var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.isUser(custom_url,wallet_address).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

User Links Example:

Arguments: custom_url: string // Custom URL of your project wallet_address: string // wallet addresses to grab links for

Response: Object { referral_link: string // referral link to the project referral_id: string // referral_id of the user }

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const custom_url = 'refmintsdk'; //example project on testnet
const wallet_address = '0x123abc456def'; //wallet address to check


var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.userLinks(custom_url,wallet_address).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});

Click Example:

Arguments: project_url: string // Custom URL of your project campaign_url: string // Custom URL of your campaign link_id?: string // optional, user's link id to attribute click to

Response: N/A

import Refmint from "refmint-sdk"
import { BaseURLOptions } from "refmint-sdk"

const project_url = 'refmintsdk'; //example project on testnet
const campaign_url = 'campaign_1'; //example project on testnet
const link_id? = 'fqOm45Jv'; // optional, example link_id of the referrer


var refmintClient = new Refmint({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

refmintClient.click(project_url,campaign_url,link_id).then((resp) => {
	//do something...
}).catch(e => {
	console.log(e);
});
1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.17

1 year ago

1.1.9

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago