1.0.2 • Published 2 years ago

helika-ua-sdk v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Helika User Acquisition SDK

SDK for use with https://ua-api.helika.io or https://ua-api-dev.helika.io

The Helika UA SDK is for developers to be able to make API calls to the Helika UA Mainnet and Testnet endpoints. The following pages will describe how to make calls to the Helika UA API. Developers will need to install the helika-ua-sdk to their project. This can be done using npm or by cloning the github project.

Installation

npm i helika-ua-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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const custom_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const custom_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

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

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

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

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

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

helikaUA.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://ua-dev.helika.io/p/helikasdk/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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const project_url = 'helikausdk'; // 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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const project_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

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

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

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const custom_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const project_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

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


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

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

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


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

helikaUA.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 HelikaUA from "helika-ua-sdk"
import { BaseURLOptions } from "helika-ua-sdk"

const project_url = 'helikausdk'; //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 helikaUA = new HelikaUA({
	apiKey: api_key,
	baseUrl: BaseURLOptions.TESTNET
});

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

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago