Public API get methods
These joyInstance methods read data. Each one requests Joy's Public API and returns the data to your client side.
Customer
Gets the info of the customer who is currently logged in on the store, via the Joy API.
joyInstance.customer().then(function(resp){
console.log(resp)
});Sample response:
{
"id": "avsu0TQoHYd4Zq5TZ123",
"shopifyCustomerId": 123123123,
"earnSignUp": true,
"name": "admin super",
"hasPoint": true,
"state": "enabled",
"shopId": "7vqeDbhZtyofeuH7l123",
"type": "member",
"acceptsMarketing": false,
"urlReferral": "https://inviteee.to/i/1234",
"email": "[email protected]",
"createdAt": "2023-04-04T07:03:32.119Z",
"totalSpent": 22,
"latestActivity": "2023-06-14T04:45:55.465Z",
"point": 100,
"updatedAt": "2023-08-08T04:10:06.186Z",
"appliedCollectionIds": []
}Shop
Gets the shop data from Joy's Public API. Returns a Promise that resolves to the shop data.
joyInstance.shop().then(function(resp){
console.log(resp)
});Sample response:
{
disableWatermark: true,
plan:'free',
isAvailableProPlan :false,
placeCurrencySymbol :true,
currency:'VND',
}Translations
Gets the translation dictionary data from the Joy app via the Public API.
joyInstance.translation().then(function(resp){
console.log(resp)
});Sample response:
{
"Admin adjusted points": "Admin adjusted points",
"Admin redeemed a reward": "Admin redeemed a reward",
"Already a member?": "Already a member?",
"Applicable for collections: {{collections}}": "Applicable for collections: {{collections}}",
"Applicable for {{request_amount}} minimum orders": "Applicable for {{request_amount}} minimum orders",
"Apply coupon now": "Apply coupon now",
"Back": "Back",
"Copy coupon": "Copy coupon",
"Copy invite link": "Copy invite link",
"Copy": "Copy",
"Coupon Code: {{coupon_code}}": "Coupon Code: {{coupon_code}}",
"Current balance is insufficient": "Current balance is insufficient",
"Description": "Description",
"Discount {{earning_discount}} for every {{redeeming_points}}": "Discount {{earning_discount}} for every {{redeeming_points}}",
"Discount {{earning_discount}} for {{redeeming_points}}": "Discount {{earning_discount}} for {{redeeming_points}}",
"Discount {{percentage}}% for {{redeeming_points}}": "Discount {{percentage}}% for {{redeeming_points}}",
"Earn {{earning_points}} for each review from 3 stars & has photo or video": "Earn {{earning_points}} for each review from 3 stars & has photo or video",
"Earn {{earning_points}} for every order": "Earn {{earning_points}} for every order",
"Earn {{earning_points}} for every review": "Earn {{earning_points}} for every review",
"Earn {{earning_points}} for every {{amount_spent}} spent": "Earn {{earning_points}} for every {{amount_spent}} spent",
"Earn {{earning_points}}": "Earn {{earning_points}}",
"Earn": "Earn",
"Spend": "Spend",
"Expired on: {{expired_date}}": "Expired on: {{expired_date}}",
"Expired points": "Expired points",
"Expired": "Expired",
"Free gift on": "Free gift on",
"Free shipping on": "Free shipping on",
"Get Link": "Get Link",
"Get rewards for being our customers": "Get rewards for being our customers",
"How to Earn Point": "How to earn points",
"How to Redeem": "How to redeem points",
"Earn points": "Earn points",
}
Redeeming programs
Gets the list of redeeming programs from the Public API.
joyInstance.redeemPrograms().then(function(resp){
console.log(resp)
});Sample response:
[
{
"id": "MuvzQblxTj4b7jsUUJzM",
"spendPoint": 200,
"isUsePrefixDiscountCode": false,
"earnAmount": 48,
"title": "Free product",
"type": "spending",
"priority": 1,
"appliedCollectionIds": [],
"specificProductIds": [
44728173330719
],
"redeemType": "fixed",
"appliedTo": "sf_product",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"event": "free_gift",
"status": true,
"specificProducts": [],
"redeemIn": "available_in_online_store",
"createdAt": "2023-06-14T04:45:26.580Z",
"updatedAt": "2023-06-14T04:45:26.580Z"
}
]Earning programs
Gets the list of earning programs from the Public API.
joyInstance.earnPrograms().then(function(resp){
console.log(resp)
});Sample response:
[
{
"id": "R3GMi0Ijytcm2emw1hGw",
"limitUnit": "minute",
"includeProducts": [],
"autoRemovePoints": true,
"earnBy": "price",
"type": "earning",
"title": "Place Order",
"productPointsCalculator": {
"color": "#8F00C1",
"fontSize": 14,
"type": "congratulation",
"font": "Noto+Sans"
},
"earnPoint": 10,
"hasLimit": false,
"typeProductMatch": "all",
"typeCondition": "all",
"statusProductPointsCalculator": false,
"shopId": "7vqeDbhZtyofeuH7l1ky",
"event": "place_order",
"conditions": [
{
"field": "title",
"typeMatch": "contains",
"content": ""
}
],
"enableCardPage": false,
"excludeProducts": [],
"statusUseCondition": false,
"limitInterval": 1,
"createdAt": "2023-04-04T06:51:59.639Z",
"rateMoney": 1,
"priority": 1,
"priorityPlaceOrder": 1,
"giftStatus": "none",
"status": true,
"appliedCollectionIds": [],
"hasEarnRateForTier": true,
"earnRateTiers": {
"nJjsaiV4Q3P61ZqqLFlL": "",
"f8QjhfgLDJhMrbjuX9Pa": ""
},
"updatedAt": "2023-07-27T10:00:31.598Z"
}
]
Customer activities
Gets a list of the customer's activity history. Paginate with the before and after parameters.
joyInstance.customerHistory({before: '', after: ''}).then(function(resp){
console.log(resp)
});Sample response:
{
"data": [
{
"id": "pIHrNxusdjoMZnv9xXlM",
"statusSentNotification": false,
"oldPoint": 300,
"source": "user",
"type": "redeem_point",
"priceRuleId": 1387420942623,
"programTitle": "Free product",
"newPoint": 100,
"customerId": "avsu0TQoHYd4Zq5TZnJg",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"discountId": 17813899542815,
"couponCode": "JOY-5KMCUB0L26KA",
"email": "[email protected]",
"programId": "MuvzQblxTj4b7jsUUJzM",
"createdAt": "2023-06-14T04:45:55.341Z",
"updatedAt": "2023-06-14T04:45:55.341Z",
"appliedCollectionIds": []
},
{
"id": "5uqHhphWxR7XVgybA2Pm",
"newPoint": 100,
"statusSentNotification": false,
"customerId": "avsu0TQoHYd4Zq5TZnJg",
"oldPoint": 0,
"shopId": "7vqeDbhZtyofeuH7l1ky",
"source": "user",
"type": "earn_point",
"event": "sign_up",
"email": "[email protected]",
"createdAt": "2023-04-04T07:03:32.210Z",
"updatedAt": "2023-04-04T07:03:32.210Z",
"appliedCollectionIds": []
}
],
"count": 2,
"total": 0,
"pageInfo": {
"hasPre": false,
"hasNext": false,
"totalPage": 0
}
}Coupon list
Gets a list of the coupons the customer redeemed. Paginate with the before and after parameters.
joyInstance.rewardList({before: '', after: '', isAvailableCoupon: true}).then(function(resp){
console.log(resp)
});Sample response:
{
"data": [
{
"id": "8zXV8ujMn2IEvZuv3CXh",
"programTitle": "Coupon 10% off",
"orderReqAmount": null,
"appliedCollectionIds": [],
"expiredAt": null,
"programDescription": "Referral Program",
"customerId": "avsu0TQoHYd4Zq5TZnJg",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"discountId": 17780573569311,
"couponCode": "JOY-IF5F1SL4G2QC",
"email": "[email protected]",
"priceRuleId": 1381868568863,
"programId": "C9AxToCOBRE5z0gQvsTJ",
"createdAt": "2023-04-04T07:18:45.805Z",
"updatedAt": "2023-04-04T07:18:45.805Z"
}
],
"count": 1,
"total": 0,
"pageInfo": {
"hasPre": false,
"hasNext": false,
"totalPage": 0
}
}Tiers
Gets a list of all VIP tiers available in your programs.
joyInstance.tiers().then(function(resp){
console.log(resp)
});Sample response:
[
{
"id": "f8QjhfgLDJhMrbjuX9Pa",
"isSystemTier": true,
"icon": "https://cdnapps.avada.io/joy/vip-tiers/icons/bronze.png",
"rateMoney": "",
"iconCustom": "",
"placedOrderReward": false,
"earnPoint": "",
"createdAt": "2023-04-04T07:05:30.589Z",
"targetPoint": 0,
"members": 0,
"name": "Bronze",
"systemType": "bronze",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"updatedAt": "2023-04-04T07:05:30.589Z",
"isTierActive": false,
"tierRewards": []
},
{
"id": "nJjsaiV4Q3P61ZqqLFlL",
"isSystemTier": true,
"icon": "https://cdnapps.avada.io/joy/vip-tiers/icons/silver.png",
"rateMoney": "",
"iconCustom": "",
"placedOrderReward": false,
"earnPoint": "",
"createdAt": "2023-04-04T07:05:30.590Z",
"targetPoint": 200,
"members": 0,
"name": "Silver",
"systemType": "silver",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"updatedAt": "2023-04-04T07:05:30.590Z",
"isTierActive": false,
"tierRewards": []
},
]Branding
Gets the branding setting of the floating widget:
joyInstance.settingsBranding().then(function(resp){
console.log(resp)
});Sample response:
{
"widgetButtonColor": "#781EC6",
"headlineTextColor": "#FFF",
"headingTextColor": "#781EC6",
"actionTextColor": "#FFF",
"actionBgColor": "#781EC6",
"customSolidColor": "#781EC6",
"customGradientColorA": "#781EC6",
"customGradientColorB": "#781EC6",
"brandColor": "#781EC6",
"textColor": "#781EC6",
"type": "branding_points",
"actionColor": "#FFF",
"pointSingular": "point",
"pointPlural": "points",
"pointPosition": "after",
"currencyPosition": "before",
"contentHeader": "Welcome to our store",
"signUpTitle": "Join and Earn Rewards",
"signUpDesc": "Get rewards for being our customers",
"signUpBtnLabel": "Join program",
"signInLabel": "Already a member?",
"signInBtnLabel": "Sign in",
"redeemBtnLabel": "Redeem",
"applyCouponBtnLabel": "Apply coupon now",
"floatBtnLabel": "Rewards",
"earnPointLabel": "How to Earn Points",
"redeemPointLabel": "How to Redeem",
"rewardListLabel": "Reward List",
"pointHistoryLabel": "Points History",
"backBtnLabel": "Back",
"floatBtnPosition": "right-bottom",
"hideOnMobile": false,
"hideFloatButton": false,
"iconPopup": "popup_gift",
"autoShowPopup": true,
"autoShowWithHash": false,
"showWithHash": "",
"appCss": "",
"themeTextFont": "Roboto",
"headlineTextFont": "Roboto",
"headingTextFont": "Roboto",
"actionTextFont": "Roboto",
"positionMenu": [
{
"isParent": true,
"showBeforeLogin": true,
"id": "points",
"childItems": [
{
"nextPage": "howToEarn",
"showBeforeLogin": true,
"id": "earn-point",
"title": "How to Earn Point",
"isShow": true
},
{
"nextPage": "howToRedeem",
"showBeforeLogin": true,
"id": "redeem-point",
"title": "How to Redeem",
"isShow": true
}
],
"title": "Points",
"isShow": true
},
{
"nextPage": "referralStep1",
"showBeforeLogin": true,
"id": "refer",
"title": "Refer your friends",
"isShow": true
},
{
"nextPage": "tierLogin1",
"showBeforeLogin": true,
"id": "vip",
"title": "VIP Tier",
"isShow": true
},
{
"nextPage": "rewards",
"id": "reward-list",
"title": "Reward list",
"isShow": true
},
{
"nextPage": "activities",
"id": "history",
"title": "Point History",
"isShow": true
}
],
"id": "7vqeDbhZtyofeuH7l1ky",
"shopId": "7vqeDbhZtyofeuH7l1ky",
"firstSave": true
}Point calculators
Two methods return the number of points a customer can get: one for a product, one for a cart. Each matches an API endpoint.
The response looks like this:
{
"html": "<style>\n.Avada-PointsCalculator__Link:hover {\n opacity: 0.8;\n}\n.Avada-PointsCalculator__Icon svg {\n display: block;\n width: 100%;\n height: 100%;\n}\n.Avada-PointsCalculator__Icon img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n}\n</style>\n<div style=\"display: inline-flex; align-items: center; color: #303030; font-size: 14px; font-family: inherit;\">\n <span class=\"Avada-PointsCalculator__Icon\" style=\"display: inline-block; width: 24px; height: 24px; margin-right: 8px; vertical-align: middle;\"><img src=\"https://cdn.shopify.com/s/files/1/0961/2312/6078/files/media_joy_doodle-art-fill.svg?v=1760468630\" alt=\"icon\" style=\"width: 30px; height: 30px; object-fit: contain;\" /></span>\n <span style=\"display: inline; margin: 0; line-height: 1.5;\">\n Receive 699 points for buying this item.\n </span>\n</div>",
"points": 699,
"pointCurrencyName": {
"singular": "point",
"plural": "points"
},
"fromCache": false
}Product calculator
Pass the variantId and the productId. The customerId is retrieved automatically.
(async () => {
const variantId = ShopifyAnalytics.meta.product.variants[0].id;
const productId = ShopifyAnalytics.meta.product.id;
const result = await joyInstance.calculateProductPoints({variantId, productId});
console.log("Result ", result);
})()Here is the direct API implementation:
(async () => {
const variantId = ShopifyAnalytics.meta.product.variants[0].id;
const productId = ShopifyAnalytics.meta.product.id;
const customerId = window.ShopifyAnalytics.meta.page.customerId;
// 2. Send to your endpoint
const apiRes = await fetch(`https://api.joy.so/app/api/v1/widgets/points-calculator/product?domain=${Shopify.shop}&productId=${productId}&variantId=${variantId}&q=1&customerId=${customerId}`, {
method: 'GET'
});
const { data } = await apiRes.json();
console.log('API Response:', data);
})();Cart calculator
With autoFetchCart: true, the method calls the /cart.js AJAX API itself. If you already called that API, pass the items manually with the items parameter instead.
(async () => {
const result = await joyInstance.calculateCartPoints({autoFetchCart: true});
console.log("Result ", result);
})()Here is the API version:
(async () => {
// 1. Fetch cart
const cartRes = await fetch('/cart.js');
const cartData = await cartRes.json();
console.log('Cart Data:', cartData);
// 2. Send to your endpoint
const apiRes = await fetch(`https://api.joy.so/app/api/v1/widgets/points-calculator/cart?domain=${Shopify.shop}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
items: cartData.items
})
});
const { data } = await apiRes.json();
console.log('API Response:', data);
})()