@smartico/public-api 0.0.346 → 0.0.348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,6 +40,22 @@ _smartico.api.getMiniGames( { onUpdate: miniGamesUpdates} ).then( games => {
40
40
 
41
41
  See the [API documentation](docs/api/classes/WSAPI.md) for all available methods and returning data.
42
42
 
43
+ See [expo.smartico.ai](https://expo.smartico.ai/widgets/intro) for the open-source examples of using the API as React-based components. Available examples:
44
+
45
+ * [User profile](https://expo.smartico.ai/widgets/user) — display user gamification info (points, level, badges)
46
+ * [Mini-games](https://expo.smartico.ai/widgets/mini_games) — show list of mini-games and trigger a mini-game with a deep link
47
+ * [Prize history](https://expo.smartico.ai/widgets/prize_history) — show user's mini-game prize history
48
+ * [Missions](https://expo.smartico.ai/widgets/missions) — list missions, opt-in, and claim rewards
49
+ * [Store](https://expo.smartico.ai/widgets/store) — display store items and categories, handle purchases
50
+ * [Tournaments](https://expo.smartico.ai/widgets/tournaments) — show tournament lobby and registration
51
+ * [Inbox](https://expo.smartico.ai/widgets/inbox) — inbox messages with read/delete/favorite actions
52
+ * [Custom Level Map](https://expo.smartico.ai/widgets/api_custom_lvl_map) — build a custom level progression map
53
+ * [Custom mini-game via API](https://expo.smartico.ai/widgets/dp_custom_mini_game) — implement a fully custom mini-game using the API
54
+ * [Custom mini-game example](https://expo.smartico.ai/widgets/dp_custom_mini_game_example) — working example of a custom mini-game
55
+ * [Jackpots](https://expo.smartico.ai/jackpots/jp_intro) — jackpot opt-in, custom win animation, multi-jackpot
56
+ * [Raffles](https://expo.smartico.ai/raffles/raffle_intro) — raffle draws, prizes, and draw history
57
+ * [UI Widgets](https://expo.smartico.ai/ui_widgets/dp_ui_widgets) — pre-built UI widgets for mini-games, leaderboard, store, missions, badges, tournaments, levels, and jackpots
58
+
43
59
  ## Visitor mode
44
60
 
45
61
  You can also get gamification data for the visitors (not authorized users).
@@ -56,6 +72,43 @@ _smartico.vapi('EN').getLevels().then( levels => {
56
72
 
57
73
  ```
58
74
 
75
+ See [expo.smartico.ai/visitor_api](https://expo.smartico.ai/visitor_api/visitor_api_intro) for open-source examples of the Visitor API:
76
+
77
+ * [Missions](https://expo.smartico.ai/visitor_api/visitor_api_missions) — display missions available for visitors
78
+ * [Tournaments](https://expo.smartico.ai/visitor_api/visitor_api_tournaments) — show tournament lobby for non-authenticated users
79
+ * [Store](https://expo.smartico.ai/visitor_api/visitor_api_store) — display store items before user login
80
+ * [Custom levels map](https://expo.smartico.ai/visitor_api/visitor_api_custom_lvl_map) — build a custom level map for visitors
81
+
82
+ ## Using in Native apps (iOS/Android)
83
+
84
+ Smartico supports integration with native iOS and Android applications via a WebSocket-based protocol and a Native Bridge for WebView communication.
85
+
86
+ ### General integration guide
87
+
88
+ See the full integration guide: [iOS/Android clients integration guide](https://help.smartico.ai/welcome/technical-guides/front-end-integration/ios-android-clients-integration-guide)
89
+
90
+ ### Connection flow
91
+
92
+ 1. Establish a WebSocket connection to the Smartico API endpoint
93
+ 2. Send `INIT` (cid: 3) → receive `INIT_RESPONSE` (cid: 4)
94
+ 3. Send `IDENTIFY` (cid: 5) → receive `IDENTIFY_RESPONSE` (cid: 6)
95
+ 4. Send `LOGIN` (cid: 7) → receive `LOGIN_RESPONSE` (cid: 11)
96
+ 5. Session is active — call any API methods (missions, store, mini-games, tournaments, etc.)
97
+ 6. Maintain connection with PING/PONG keepalive
98
+ 7. Listen for server-initiated events (popups, mini-game triggers, deep links, property changes)
99
+
100
+ ### Gamification widget & popups
101
+
102
+ The `IDENTIFY_RESPONSE` returns `native_app_gf_url` and `native_app_popup_url` — use these to load gamification and engagement content in a WebView. The native app communicates with loaded web pages through the Native Bridge interface (`SmarticoBridge`).
103
+
104
+ ### Push notifications
105
+
106
+ Register push tokens via WebSocket (cid: 1003) or via HTTP POST/GET to the Smartico public endpoint. See the [integration guide](https://help.smartico.ai/welcome/technical-guides/front-end-integration/ios-android-clients-integration-guide) for details on reporting delivery, impression, and click events.
107
+
108
+ ### Protocol reference
109
+
110
+ For the full low-level protocol specification including all API methods (levels, missions, store, mini-games, tournaments, leaderboard, inbox, jackpots, raffles, etc.) and server-initiated events, see [Native Protocol](docs/native/PROTOCOL.md).
111
+
59
112
  ## Backend usage (NodeJS context)
60
113
 
61
114
  Note: access to the server-to-server API is not provided by default and is a topic for a separate agreement with Smartico.
@@ -84,7 +137,67 @@ response.templates.forEach( t => {
84
137
 
85
138
  ```
86
139
 
87
- ## Development and publishing process
140
+ ## Backend usage (http-protocol)
141
+
142
+ You can make HTTP calls to the Smartico public endpoint to interact with user data server-to-server — for example, to check if a specific user belongs to segment(s).
143
+
144
+ > **Note:** Usage of backend-based integration is subject to rate limits and additional charges. High/intensive usage may degrade performance of your client setup. Please contact your Smartico account manager for pricing details based on your expected request volume.
145
+
146
+ ### What you will need
147
+
148
+ - **Endpoint** — has the form `https://imgX.smr.vc/s2s-api`, where `X` corresponds to your environment ID (ask your account manager)
149
+ - **Label public API key**
150
+ - **Brand public API key**
151
+
152
+ ### Example: check segment membership
153
+
154
+ This example checks whether a user belongs to specific segments. It corresponds to `checkSegmentListMatch` (cid: 161 / response cid: 162) described in [Native Protocol](docs/native/PROTOCOL.md).
155
+
156
+ **Request:**
157
+
158
+ ```bash
159
+ curl --location 'https://imgX.smr.vc/s2s-api' \
160
+ --header 'Content-Type: application/json' \
161
+ --data '{
162
+ "api_key": "your-label-public-api-key",
163
+ "brand_key": "your-brand-public-api-key",
164
+ "ext_user_id": "your-user-ext-id",
165
+ "cid": 161,
166
+ "uuid": "f07f0730-4886-4135-81b7-62c94659d3cf",
167
+ "ts": 1770278728317,
168
+ "segment_id": [
169
+ 6493, 1234
170
+ ]
171
+ }'
172
+ ```
173
+
174
+ **Response:**
175
+
176
+ ```json
177
+ {
178
+ "segments": [
179
+ {
180
+ "segment_id": 6493,
181
+ "is_matching": true
182
+ },
183
+ {
184
+ "segment_id": 1234,
185
+ "is_matching": false
186
+ }
187
+ ],
188
+ "errCode": 0,
189
+ "errMsg": "",
190
+ "cid": 162,
191
+ "ts": 1770303940950,
192
+ "uuid": "f07f0730-4886-4135-81b7-62c94659d3cf"
193
+ }
194
+ ```
195
+
196
+ ### Using other API methods
197
+
198
+ You can call any API method described in [Native Protocol](docs/native/PROTOCOL.md) using the same HTTP approach. Build the request body with the appropriate `cid` and method-specific fields, along with `api_key`, `brand_key`, `ext_user_id`, `uuid`, and `ts`. The response will follow the same structure documented for each method.
199
+
200
+ ## For Smartico developers
88
201
 
89
202
  ### Publishing process
90
203
 
@@ -115,6 +115,10 @@ export declare enum ClassId {
115
115
  RAF_CLAIM_PRIZE_RESPONSE = 909,
116
116
  RAF_OPTIN_REQUEST = 916,
117
117
  RAF_OPTIN_RESPONSE = 917,
118
+ BNR_GET_BANNER_PLACEMENTS_REQUEST = 950,
119
+ BNR_GET_BANNER_PLACEMENTS_RESPONSE = 951,
120
+ BNR_GET_BANNER_CONTENT_REQUEST = 952,
121
+ BNR_GET_BANNER_CONTENT_RESPONSE = 953,
118
122
  REGISTER_PUSH_NOTIFICATIONS_TOKEN_REQ = 1003,
119
123
  REGISTER_PUSH_NOTIFICATIONS_TOKEN_RESP = 2003,
120
124
  CLIENT_DEBUG_REQUEST = 77777,
@@ -11,7 +11,7 @@ import { GetTournamentInfoResponse, GetTournamentsResponse, TournamentRegisterRe
11
11
  import { LeaderBoardDetails, LeaderBoardPeriodType } from './Leaderboard';
12
12
  import { GetLevelMapResponse } from './Level';
13
13
  import { WSAPI } from './WSAPI/WSAPI';
14
- import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult, TUICustomSection, TBonus, TRaffle, TLevelCurrent, TActivityLog } from './WSAPI/WSAPITypes';
14
+ import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult, TUICustomSection, TBonus, TRaffle, TLevelCurrent, TActivityLog, TRaffleDraw } from './WSAPI/WSAPITypes';
15
15
  import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
16
16
  import { GetJackpotsPotsResponse, GetJackpotsResponse, JackpotsOptinResponse, JackpotsOptoutResponse } from './Jackpots';
17
17
  import { GetCustomSectionsResponse } from './CustomSections';
@@ -160,7 +160,10 @@ declare class SmarticoAPI {
160
160
  getRaffleDrawRun(user_ext_id: string, payload: {
161
161
  raffle_id: number;
162
162
  run_id: number;
163
+ winners_limit?: number;
164
+ winners_offset?: number;
163
165
  }): Promise<GetDrawRunResponse>;
166
+ getRaffleDrawRunT(user_ext_id: string, raffle_id: number, run_id: number, winners_from?: number, winners_to?: number): Promise<TRaffleDraw>;
164
167
  getRaffleDrawRunsHistory(user_ext_id: string, props: {
165
168
  raffle_id: number;
166
169
  draw_id?: number;
@@ -77,7 +77,7 @@ export declare class WSAPI {
77
77
  * **Visitor mode: not supported**
78
78
  */
79
79
  getCurrentLevel(): Promise<TLevelCurrent>;
80
- /** Returns all the missions available the current user.
80
+ /** Returns all the missions configured for the current user (server-side scoped, not filtered by Widget visibility).
81
81
  * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
82
82
  * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
83
83
  * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
@@ -257,7 +257,7 @@ export declare class WSAPI {
257
257
  * */
258
258
  getCustomSections(): Promise<TUICustomSection[]>;
259
259
  /**
260
- * Returns the list of mini-games available for user
260
+ * Returns the list of mini-games configured for the current user (not filtered by spin availability or Widget visibility).
261
261
  * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
262
262
  * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
263
263
  *
@@ -735,7 +735,8 @@ export declare class WSAPI {
735
735
  onUpdate?: (data: TRaffle[]) => void;
736
736
  }): Promise<TRaffle[]>;
737
737
  /**
738
- * Returns draw run for provided raffle_id and run_id
738
+ * Returns draw run for provided raffle_id and run_id.
739
+ * You can pass winners_from and winners_to parameters to get a specific range of winners. Default is 0-20.
739
740
  *
740
741
  *
741
742
  * **Example**:
@@ -759,6 +760,8 @@ export declare class WSAPI {
759
760
  getRaffleDrawRun(props: {
760
761
  raffle_id: number;
761
762
  run_id: number;
763
+ winners_from?: number;
764
+ winners_to?: number;
762
765
  }): Promise<TRaffleDraw>;
763
766
  /**
764
767
  * Returns history of draw runs for the provided raffle_id and draw_id, if the draw_id is not provided will return history of all the draws for the provided raffle_id
package/dist/index.js CHANGED
@@ -144,6 +144,10 @@ exports.ClassId = void 0;
144
144
  RAF_GET_TICKETS_RESPONSE = 903,
145
145
  RAF_CLAIM_PRIZE_REQUEST = 906,
146
146
  */
147
+ ClassId[ClassId["BNR_GET_BANNER_PLACEMENTS_REQUEST"] = 950] = "BNR_GET_BANNER_PLACEMENTS_REQUEST";
148
+ ClassId[ClassId["BNR_GET_BANNER_PLACEMENTS_RESPONSE"] = 951] = "BNR_GET_BANNER_PLACEMENTS_RESPONSE";
149
+ ClassId[ClassId["BNR_GET_BANNER_CONTENT_REQUEST"] = 952] = "BNR_GET_BANNER_CONTENT_REQUEST";
150
+ ClassId[ClassId["BNR_GET_BANNER_CONTENT_RESPONSE"] = 953] = "BNR_GET_BANNER_CONTENT_RESPONSE";
147
151
  /*
148
152
  !Important, if adding new messages that are 'acting' on behalf of the client,
149
153
  you need to include them in the CLASS_ID_IGNORE_FOR_SIMULATION
@@ -2368,7 +2372,7 @@ var WSAPI = /*#__PURE__*/function () {
2368
2372
  return Promise.reject(e);
2369
2373
  }
2370
2374
  }
2371
- /** Returns all the missions available the current user.
2375
+ /** Returns all the missions configured for the current user (server-side scoped, not filtered by Widget visibility).
2372
2376
  * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
2373
2377
  * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
2374
2378
  * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
@@ -2679,7 +2683,7 @@ var WSAPI = /*#__PURE__*/function () {
2679
2683
  }
2680
2684
  }
2681
2685
  /**
2682
- * Returns the list of mini-games available for user
2686
+ * Returns the list of mini-games configured for the current user (not filtered by spin availability or Widget visibility).
2683
2687
  * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
2684
2688
  * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
2685
2689
  *
@@ -3677,7 +3681,8 @@ var WSAPI = /*#__PURE__*/function () {
3677
3681
  }
3678
3682
  }
3679
3683
  /**
3680
- * Returns draw run for provided raffle_id and run_id
3684
+ * Returns draw run for provided raffle_id and run_id.
3685
+ * You can pass winners_from and winners_to parameters to get a specific range of winners. Default is 0-20.
3681
3686
  *
3682
3687
  *
3683
3688
  * **Example**:
@@ -3702,12 +3707,10 @@ var WSAPI = /*#__PURE__*/function () {
3702
3707
  _proto.getRaffleDrawRun = function getRaffleDrawRun(props) {
3703
3708
  try {
3704
3709
  var _this57 = this;
3705
- return Promise.resolve(_this57.api.getRaffleDrawRun(null, props)).then(function (res) {
3706
- if (!props.raffle_id || !props.run_id) {
3707
- throw new Error('both raffle_id and run_id are required');
3708
- }
3709
- return drawRunTransform(res);
3710
- });
3710
+ if (!props.raffle_id || !props.run_id) {
3711
+ throw new Error('both raffle_id and run_id are required');
3712
+ }
3713
+ return Promise.resolve(_this57.api.getRaffleDrawRunT(null, props.raffle_id, props.run_id, props.winners_from, props.winners_to));
3711
3714
  } catch (e) {
3712
3715
  return Promise.reject(e);
3713
3716
  }
@@ -5261,43 +5264,64 @@ var SmarticoAPI = /*#__PURE__*/function () {
5261
5264
  return Promise.reject(e);
5262
5265
  }
5263
5266
  };
5264
- _proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(user_ext_id, props) {
5267
+ _proto.getRaffleDrawRunT = function getRaffleDrawRunT(user_ext_id, raffle_id, run_id, winners_from, winners_to) {
5268
+ if (winners_from === void 0) {
5269
+ winners_from = 0;
5270
+ }
5271
+ if (winners_to === void 0) {
5272
+ winners_to = 20;
5273
+ }
5265
5274
  try {
5266
5275
  var _this72 = this;
5267
- var message = _this72.buildMessage(user_ext_id, exports.ClassId.RAF_GET_DRAW_HISTORY_REQUEST, props);
5268
- return Promise.resolve(_this72.send(message, exports.ClassId.RAF_GET_DRAW_HISTORY_RESPONSE));
5276
+ var winners_limit = winners_to - winners_from > 50 ? 50 : winners_to - winners_from;
5277
+ var winners_offset = winners_from;
5278
+ return Promise.resolve(_this72.getRaffleDrawRun(user_ext_id, {
5279
+ raffle_id: raffle_id,
5280
+ run_id: run_id,
5281
+ winners_limit: winners_limit,
5282
+ winners_offset: winners_offset
5283
+ })).then(drawRunTransform);
5269
5284
  } catch (e) {
5270
5285
  return Promise.reject(e);
5271
5286
  }
5272
5287
  };
5273
- _proto.claimRafflePrize = function claimRafflePrize(user_ext_id, props) {
5288
+ _proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(user_ext_id, props) {
5274
5289
  try {
5275
5290
  var _this73 = this;
5276
- var message = _this73.buildMessage(user_ext_id, exports.ClassId.RAF_CLAIM_PRIZE_REQUEST, props);
5277
- return Promise.resolve(_this73.send(message, exports.ClassId.RAF_CLAIM_PRIZE_RESPONSE));
5291
+ var message = _this73.buildMessage(user_ext_id, exports.ClassId.RAF_GET_DRAW_HISTORY_REQUEST, props);
5292
+ return Promise.resolve(_this73.send(message, exports.ClassId.RAF_GET_DRAW_HISTORY_RESPONSE));
5278
5293
  } catch (e) {
5279
5294
  return Promise.reject(e);
5280
5295
  }
5281
5296
  };
5282
- _proto.raffleOptin = function raffleOptin(user_ext_id, props) {
5297
+ _proto.claimRafflePrize = function claimRafflePrize(user_ext_id, props) {
5283
5298
  try {
5284
5299
  var _this74 = this;
5285
- var message = _this74.buildMessage(user_ext_id, exports.ClassId.RAF_OPTIN_REQUEST, props);
5286
- return Promise.resolve(_this74.send(message, exports.ClassId.RAF_OPTIN_RESPONSE));
5300
+ var message = _this74.buildMessage(user_ext_id, exports.ClassId.RAF_CLAIM_PRIZE_REQUEST, props);
5301
+ return Promise.resolve(_this74.send(message, exports.ClassId.RAF_CLAIM_PRIZE_RESPONSE));
5287
5302
  } catch (e) {
5288
5303
  return Promise.reject(e);
5289
5304
  }
5290
5305
  };
5291
- _proto.getActivityLog = function getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset) {
5306
+ _proto.raffleOptin = function raffleOptin(user_ext_id, props) {
5292
5307
  try {
5293
5308
  var _this75 = this;
5294
- var message = _this75.buildMessage(user_ext_id, exports.ClassId.GET_POINT_HISTORY_REQUEST, {
5309
+ var message = _this75.buildMessage(user_ext_id, exports.ClassId.RAF_OPTIN_REQUEST, props);
5310
+ return Promise.resolve(_this75.send(message, exports.ClassId.RAF_OPTIN_RESPONSE));
5311
+ } catch (e) {
5312
+ return Promise.reject(e);
5313
+ }
5314
+ };
5315
+ _proto.getActivityLog = function getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset) {
5316
+ try {
5317
+ var _this76 = this;
5318
+ var message = _this76.buildMessage(user_ext_id, exports.ClassId.GET_POINT_HISTORY_REQUEST, {
5295
5319
  startTimeSeconds: Math.floor(startTimeSeconds),
5296
5320
  endTimeSeconds: Math.floor(endTimeSeconds),
5297
5321
  limit: limit,
5298
5322
  offset: offset
5299
5323
  });
5300
- return Promise.resolve(_this75.send(message, exports.ClassId.GET_POINT_HISTORY_RESPONSE));
5324
+ return Promise.resolve(_this76.send(message, exports.ClassId.GET_POINT_HISTORY_RESPONSE));
5301
5325
  } catch (e) {
5302
5326
  return Promise.reject(e);
5303
5327
  }
@@ -5310,11 +5334,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
5310
5334
  to = 50;
5311
5335
  }
5312
5336
  try {
5313
- var _this76 = this;
5337
+ var _this77 = this;
5314
5338
  var limit = to - from > 50 ? 50 : to - from;
5315
5339
  var offset = from;
5316
- return Promise.resolve(_this76.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this76$getActivityLo) {
5317
- return ActivityLogTransform(_this76$getActivityLo.logHistory);
5340
+ return Promise.resolve(_this77.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this77$getActivityLo) {
5341
+ return ActivityLogTransform(_this77$getActivityLo.logHistory);
5318
5342
  });
5319
5343
  } catch (e) {
5320
5344
  return Promise.reject(e);