Skip to main content

API reference

This section provides a comprehensive reference of the available API methods in the JavaScript SDK beyond those covered in the other sections.

Data retrieval functions

The SDK provides methods to retrieve various types of data without using the widgets directly. These functions allow for complete customization of the user interface.

FunctionDescriptionEvent TriggeredResponse Data
Mambo.getUserNotifications()Retrieves notifications for the current usermambo.data.user_notificationsUser Notifications
Mambo.getUserWallets()Retrieves point wallets for the current usermambo.data.user_walletsUser Points
Mambo.getUserCoupons()Retrieves coupons for the current usermambo.data.user_couponsUser Coupons
Mambo.getUserRewards()Retrieves rewards for the current usermambo.data.user_rewardsUser Rewards
Mambo.getUserAchievements()Retrieves achievements for the current usermambo.data.user_achievementsUser Rewards
Mambo.getUserLevels()Retrieves levels for the current usermambo.data.user_levelsUser Rewards
Mambo.getUserGifts()Retrieves gifts for the current usermambo.data.user_giftsUser Rewards
Mambo.getUserMissions()Retrieves missions for the current usermambo.data.user_missionsUser Rewards
Mambo.getUserKPIs(year)Retrieves KPIs for the current usermambo.data.user_kpisUser KPIs
Mambo.getUserActivities(page, count)Retrieves activities for the current usermambo.data.activitiesUser Activities
Mambo.getBehaviours()Retrieves available behavioursmambo.data.behavioursBehaviours
Mambo.getAchievements()Retrieves available achievementsmambo.data.achievementsRewards
Mambo.getLevels()Retrieves available levelsmambo.data.levelsRewards
Mambo.getMissions()Retrieves available missionsmambo.data.missionsRewards
Mambo.getLeaderboards(fn, tagUuid)Retrieves available leaderboardsmambo.data.leaderboardsLeaderboards

Usage example

Here's how to use these API methods to retrieve data:

JavaScript
Note

The events that return data objects will return either a Backbone Collection or Model. To work with these as standard JSON objects, call the toJSON() function on the data object.

Building custom interfaces

Using these API methods, you can build completely custom interfaces for your gamification elements. This approach gives you full control over the presentation while still leveraging the SDK's communication with the Mambo platform.

A typical implementation pattern:

  1. Define event listeners for the data you need
  2. Call the appropriate API methods to fetch the data
  3. Process the returned data in your event listeners
  4. Render the data using your own UI components or templates

This allows you to maintain consistent branding and user experience while still taking advantage of the gamification platform's capabilities.