SDK Basics


Welcome to the Ocugine JavaScript SDK documentation section. Here you can learn some basics of the our SDK. If you need to get some additional information - please, visit our forums.

If you want to use latest stable JS SDK - please, visit our GitHub releases page.

General Object

The Ocugine JS SDK based on Singleton programming pattern. This means that all interaction between objects occurs through the main object. In our case, it is an OcugineSDK class.

General Class has these public methods:

  • call - used to send API requests;
  • module - used to call child objects;

We are most interested in the Module method. It is used to get an instance of SDK child objects. For example:


The short name of the called object is passed to the method arguments. If this object was previously initialized by the OcugineSDK class, then it will return a link to it.

The list of available modules:

  • Auth - Ocugine_Auth instance. Use this module for authentication;
  • Analytics - Ocugine_Analytics instance. Use this module to send analytics flags and update user retention;
  • Gaming - Ocugine_Gaming instance. Use this module to work with leaderboards, achievements, missions, etc;
  • Monetization - Ocugine_Monetization instance. Use this module to work with Payments, player inventory, etc;
  • Notify - Ocugine_Notifications instance. Use this module to work with In-Game notifications;
  • Marketing - Ocugine_Marketing instance. Use this module to work with In-Game marketing tools;
  • Ads - Ocugine_Ads instance. Use this module to work with Advertising;
  • Backend - Ocugine_Backend instance. Use this module to work with Cloud-Services;
  • Reports - Ocugine_Reports instance. Use this module to work with Crashes and Performance reports;
  • Localization - Ocugine_Localization instance. Use this module to work with Localization services;
  • Users - Ocugine_Users instance. Use this module to work with Users, Fields, Groups, etc;
  • UI - Ocugine_UI instance. Use this module to work with UI. Please, note, what you need to connect an Ocugine Styles;
  • Utils - Ocugine_Utils instance. Utils module.

You can change Module short names in the SDK. You can found mapping object in the Ocugine SDK javascript file:

const OcugineMapping = {
    "auth": Ocugine_Auth, // Ocugine Auth
    "analytics": Ocugine_Analytics, // Analytics
    "gaming": Ocugine_Gaming, // Gaming Services
    "monetization": Ocugine_Monetization, // Monetization
    "notify": Ocugine_Notifications, // Notifications
    "marketing": Ocugine_Marketing, // Marketing
    "ads": Ocugine_Ads, // Advertising
    "backend": Ocugine_Backend, // Backend
    "reports": Ocugine_Reports, // Reports
    "localization": Ocugine_Localization, // Localization
    "users": Ocugine_Users, // Ocugine Users
    "ui": Ocugine_UI, // Ocugine UI
    "utils": Ocugine_Utils  // Utils Class

Method Models

All methods has two callbacks: success and error. These callback methods has own arguments.

For example, let's view module("Gaming").achievements.getPlayerList() method:

    console.log(data); // Data object contains **list** subobject
}, function(error){
    console.log(error); // Where error - string message


You can work with Ocugine SDK Authentication using manual methods in the "Auth" object, but we recommend to use "showOAuth" method from "UI" object.

For example. You can authenticate users by few lines of code:

    /* TODO: Authentication Complete */
}, function(error){
    /* TODO: Authentication Error */

Or you can use full-authentication stack:

    // Get Authentication Link
    OcugineSDK.module("auth").getLink("all", function(data){
        // Generate Authentication Window
        let wind; wind =; // Window

        // Check Authentication Status
        let timer = setInterval(function() {
            if(wind.closed) {
                    /* TODO: Token is ready */
                }, function(err){
        }, 1000);
    }, function(err){
        /* TODO: Failed to get Authentication Link */
    // Check User Grants
        /* TODO: Success */
    }, function(err){
        /* TODO: Call this code again */