import SnagSolutions from '@snagsolutions/sdk';
const client = new SnagSolutions({
apiKey: process.env['X_API_KEY'], // This is the default and can be omitted
});
const rules = await client.loyalty.rules.list();
console.log(rules.data);{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Loyalty Rule",
"description": "Loyalty Rule Description",
"endTime": "2023-10-01T12:34:56Z",
"startTime": "2023-10-01T12:34:56Z",
"rewardType": "points",
"organizationId": "123e4567-e89b-12d3-a456-426614174001",
"websiteId": "123e4567-e89b-12d3-a456-426614174002",
"type": "purchase",
"frequency": "daily",
"amount": 10,
"createdAt": "2023-10-01T12:34:56Z",
"updatedAt": "2023-10-05T15:30:00Z",
"deletedAt": null,
"loyaltyRuleChain": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"name": "My Rule Chain",
"loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
"loyaltyConditions": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"type": "rule",
"description": "My Condition",
"amount": 100,
"repeatCount": 1,
"requiredCount": 1,
"csvUrl": "https://example.com/csv",
"association": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRuleGroupId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
"loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyBadgeId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRule": {
"name": "My Loyalty Rule"
}
}
]
}
]
}
],
"collectionAddress": "0x1234567890abcdef1234567890abcdef12345678",
"mediaUrl": "https://assets.snagsolutions.io/media.png",
"metadata": {
"key": "value"
}
}
],
"hasNextPage": true
}Retrieve configured loyalty rules with optional pagination and filters
import SnagSolutions from '@snagsolutions/sdk';
const client = new SnagSolutions({
apiKey: process.env['X_API_KEY'], // This is the default and can be omitted
});
const rules = await client.loyalty.rules.list();
console.log(rules.data);{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Loyalty Rule",
"description": "Loyalty Rule Description",
"endTime": "2023-10-01T12:34:56Z",
"startTime": "2023-10-01T12:34:56Z",
"rewardType": "points",
"organizationId": "123e4567-e89b-12d3-a456-426614174001",
"websiteId": "123e4567-e89b-12d3-a456-426614174002",
"type": "purchase",
"frequency": "daily",
"amount": 10,
"createdAt": "2023-10-01T12:34:56Z",
"updatedAt": "2023-10-05T15:30:00Z",
"deletedAt": null,
"loyaltyRuleChain": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"name": "My Rule Chain",
"loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
"loyaltyConditions": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"type": "rule",
"description": "My Condition",
"amount": 100,
"repeatCount": 1,
"requiredCount": 1,
"csvUrl": "https://example.com/csv",
"association": [
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRuleGroupId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
"loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyBadgeId": "123e4567-e89b-12d3-a456-426614174001",
"loyaltyRule": {
"name": "My Loyalty Rule"
}
}
]
}
]
}
],
"collectionAddress": "0x1234567890abcdef1234567890abcdef12345678",
"mediaUrl": "https://assets.snagsolutions.io/media.png",
"metadata": {
"key": "value"
}
}
],
"hasNextPage": true
}Unique identifier for the organization to filter by
"123e4567-e89b-12d3-a456-426614174001"
Unique identifier for the website to filter by
"123e4567-e89b-12d3-a456-426614174002"
Address of the collection to filter by
"0x1234567890abcdef1234567890abcdef12345678"
ID of the loyalty rule group to filter results
"123e4567-e89b-12d3-a456-426614174004"
Pagination cursor to start after a specific resource ID
"123e4567-e89b-12d3-a456-426614174010"
Maximum number of records to return (max 100)
1 <= x <= 10050
The IDs of the loyalty rule
"123e4567-e89b-12d3-a456-426614174001"
If true this will only return active rules, the rules for which the startTime is in the past and the endTime is in the future
true, false true
IDs of the users to filter results by
"123e4567-e89b-12d3-a456-426614174005"
ID of the user group to filter results by
"123e4567-e89b-12d3-a456-426614174006"
If true this will only return special rules, special rules are the rules that are used for anti sybil as honey pot
true, false true
Whether to include deleted/archived records
false
200
Show child attributes
Unique identifier for the loyalty rule
"123e4567-e89b-12d3-a456-426614174000"
Name of the loyalty rule
"Loyalty Rule"
Description of the loyalty rule
"Loyalty Rule Description"
End time of the loyalty rule
"2023-10-01T12:34:56Z"
Start time of the loyalty rule
"2023-10-01T12:34:56Z"
Type of the reward
points, multiplier, badge "points"
Unique identifier for the organization
"123e4567-e89b-12d3-a456-426614174001"
Unique identifier for the website
"123e4567-e89b-12d3-a456-426614174002"
Type of the loyalty rule
"purchase"
Frequency of the loyalty rule
"daily"
Amount associated with the loyalty rule
10
Timestamp when the loyalty rule was created
"2023-10-01T12:34:56Z"
Timestamp when the loyalty rule was last updated
"2023-10-05T15:30:00Z"
Timestamp when the loyalty rule was deleted (if applicable)
null
Chains attached to the loyalty rule
Show child attributes
Unique identifier for the rule chain
"123e4567-e89b-12d3-a456-426614174001"
Name of the rule chain
"My Rule Chain"
Unique identifier for the loyalty rule
"123e4567-e89b-12d3-a456-426614174111"
Show child attributes
Unique identifier for the condition
"123e4567-e89b-12d3-a456-426614174001"
Type of the condition
rule, rules, points, section, level, api, badge, badges, csv "rule"
Description of the condition
"My Condition"
Amount of the condition
100
Number of times the condition must be met
1
Number of times the condition must be met
1
URL of the CSV file
"https://example.com/csv"
Show child attributes
Unique identifier for the association
"123e4567-e89b-12d3-a456-426614174001"
Unique identifier for the loyalty rule group
"123e4567-e89b-12d3-a456-426614174001"
Unique identifier for the loyalty rule
"123e4567-e89b-12d3-a456-426614174111"
Unique identifier for the loyalty currency
"123e4567-e89b-12d3-a456-426614174001"
Unique identifier for the loyalty badge
"123e4567-e89b-12d3-a456-426614174001"
Optional address of the collection
"0x1234567890abcdef1234567890abcdef12345678"
URL of the media associated with the loyalty rule
"https://assets.snagsolutions.io/media.png"
Optional metadata for the loyalty rule
Show child attributes
Show child attributes
If enabled, the first transaction done on the platform will complete this rule
true
Flag indicating whether to include only non-listed items.
true
Indicates if the full royalty has been paid for items.
false
Wallet address of the user can only be used if userId is not provided
"0x1234567890abcdef1234567890abcdef12345678"
Royalty percentage of the item.
1 <= x <= 1005
Indicates if the user has a verified Twitter account.
true
Indicates if only existing users are rewarded.
true
Indicates if the item has never been sold.
false
Flag indicating whether to include only native tokens.
true
Flag indicating whether the fill source is included.
true
Fill source of the order for the token sale
"opensea.io"
Liquidity pool details.
Show child attributes
Blockchain network of the liquidity pool.
abstract, abstractTestnet, apechain, arbitrum, avalanche, avalancheFuji, base, baseSepolia, berachain, berachainArtio, berachainBepolia, binance, bscTestnet, campTestnet, fantom, fantomTestnet, flowMainnet, mainnet, nexusTestnet, optimism, polygon, polygon_mumbai, skaleNebula, skaleEuropa, skaleCalypso, solana, sophon, sophonTestnet, sui, superseed, superseedSepolia, vanar, xai, zksync, coti, cotiTestnet, morph, morphTestnet, morphHolesky, ultra, ultraTestnet, nitrograph, sepolia, optimism_sepolia, arbitrumSepolia, goerli, optimism_goerli, arbitrumGoerli, basecamp, somnia, zkverify, polkadot, kusama, flow_cadence "mainnet"
Protocol of the liquidity pool.
"Uniswap V2"
Indicates if only in-range liquidity is rewarded.
true
Liquidity provided per day in USD
1000
Custom function to calculate the the reward amount based on the liquidity provided per day. X is the reward amount, Y is the liquidity provided per day in USD.
"x = y * 1000"
Calculation type of the liquidity pool.
fixed, custom "fixed"
Twitter username of the user.
"@example_user"
Unique identifier of the Twitter user.
"1234567890"
Hashtag associated with the Twitter post.
"#loyalty"
Flag indicating whether the verified multiplier is enabled.
true
Multiplier applied to rewards for verified users.
1.5
Indicates if the multiplier has been applied to rewards.
true
Flag indicating whether to include only known users.
false
Percentage reward given to a user for their first referral.
10
Lump sum reward given to a referrer.
50
Loyalty currency ID of the referrer reward.
"1234567890"
Percentage reward given for a second-level referral.
5
Flag indicating whether streaks are enabled.
true
Promotional code associated with the rule.
"PROMO123"
Type of the promotional code.
code, csv, generate "code"
Numbers of the promotional code to be generated.
10
URL of the CSV file containing promo codes.
"https://example.com/promo_codes.csv"
Flag indicating whether joining Discord servers is required.
true
Array of Discord servers, channels, and roles to join.
Show child attributes
ID of the Discord server to join.
"123456789012345678"
Array of Discord channels to join.
Show child attributes
ID of the Discord channel.
"987654321098765432"
Phrase of text to be present in the discord message
"Hello"
Array of streak milestones and corresponding rewards.
Array of collections associated with the rule.
Show child attributes
Blockchain address of the collection.
"0xabcdefabcdefabcdefabcdefabcdefabcdef"
Blockchain network of the collection.
abstract, abstractTestnet, apechain, arbitrum, avalanche, avalancheFuji, base, baseSepolia, berachain, berachainArtio, berachainBepolia, binance, bscTestnet, campTestnet, fantom, fantomTestnet, flowMainnet, mainnet, nexusTestnet, optimism, polygon, polygon_mumbai, skaleNebula, skaleEuropa, skaleCalypso, solana, sophon, sophonTestnet, sui, superseed, superseedSepolia, vanar, xai, zksync, coti, cotiTestnet, morph, morphTestnet, morphHolesky, ultra, ultraTestnet, nitrograph, sepolia, optimism_sepolia, arbitrumSepolia, goerli, optimism_goerli, arbitrumGoerli, basecamp, somnia, zkverify, polkadot, kusama, flow_cadence "mainnet"
Multiplier applied to the rewards for this collection.
2
Array defining ranges and corresponding rewards.
Show child attributes
Start value of the range.
1
End value of the range.
10
Reward amount for this range.
5
ID of the loyalty badge for this range.
"badge123"
Amount of the loyalty multiplier for this range.
1.5
API key for custom rewards integration.
"api-key-1234"
Optional link associated with the metadata.
"https://example.com"
Social media platform associated with the rule.
Custom, Discord, EpicGames, Instagram, Steam, Telegram, TikTok, Twitch, X(Twitter), YouTube, Google, GitHub "X(Twitter)"
Name of the social platform.
"Twitter"
URL of the social platform's logo.
"https://example.com/logo.png"
Flag indicating if rewards are given per impression.
true
Minimum quantity constraint for token holding.
1
Maximum quantity constraint for token holding.
10
Flag indicating if the sale currency is included.
false
Flag indicating if the token hold multiplier is applied.
true
Currency associated with sales.
"USD"
Flag indicating if rewards are applied retroactively.
true
Time delay in seconds to verify actions.
300
Object defining referral requirements.
Show child attributes
Flag indicating if achieving points is required.
true
Flag indicating if completing the profile is required.
false
Flag indicating if connecting Twitter is required.
true
Flag indicating if connecting Discord is required.
true
Flag indicating if connecting email is required.
true
Array of loyalty currency IDs used for multipliers.
["currency123", "currency456"]Placeholder text for verification input fields.
"Enter your verification code here."
Minimum length of the verification text.
10
Text displayed on the action button.
"Verify Now"
ID of the Telegram channel.
"telegram-channel-123"
URL of the associated Twitter account.
"https://twitter.com/example_user"
URL of the associated Twitter post.
"https://twitter.com/example/status/1234567890"
Flag indicating if liking the post is required.
true
Flag indicating if reposting is required.
true
Flag indicating if commenting is required.
true
Text to check in the Twitter post, username, or bio.
"loyalty"
Flag indicating if the post link is required.
true
Flag indicating if media metadata is required.
true
Criteria to evaluate the reward.
IMPRESSIONS_COUNT, ELIGIBLE_POST "IMPRESSIONS_COUNT"
Object containing details of the associated smart contract.
Show child attributes
ID of the smart contract.
"123e4567-e89b-12d3-a456-426614174000"
Event emitted by the smart contract.
"Transfer"
Type of the smart contract interaction.
function, event "event"
Criteria to evaluate the smart contract event.
everyEvent, byParameter "everyEvent"
Array of parameters for the smart contract.
Show child attributes
Name of the smart contract parameter.
"value"
Condition to check for the parameter.
">="
Value of the parameter.
"100"
Mapping of addresses for the smart contract.
"0x123...789"
Object containing details of the amount multiplier from the event.
Show child attributes
Mapping of the value for the smart contract.
"amount"
Type of wallet associated with the rule.
evm, solana, imx, sui, ton, cosmos, ultra, agw, flow_cadence, substrate "evm"
URL of the image associated with the rule.
"https://example.com/image.png"
Flag indicating if all contracts are tracked.
true
give points for only one token ownership per contract
true
Flag indicating if the multiplier is skipped.
true
ID of the Steam app.
"1234567890"
URL of the GitHub repository to check for star.
"https://github.com/owner/repo"
Flag indicating if the progress is tracked. If enabled, the rule can only be completed once the progress is 100%.
true
Flag indicating if the reward is rewarded per action.
true
Flag indicating if the reward is rewarded by batch.
true
Number of tokens per batch.
100
ID of the Youtube video.
"1234567890"
ID of the Youtube channel.
"1234567890"
Flag indicating if the rule is restricted to new users.
false
Flag indicating if the rule can also reward badges per range.
false
Metadata for swap loyalty rules
Show child attributes
any, relay, lifi any, specific Flag indicating if the rule should reward based on value of traded tokens instead of count.
false
Description of the external rule condition (only for external rules)
"Complete the specific task on external platform"
Flag indicating if the rule should use direct RPC to get the balance of tokens.
false
Type of ERC20 token for the loyalty rule.
erc20, native "erc20"
{ "key": "value" }Was this page helpful?