@smartico/public-api 0.0.345 → 0.0.347
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 +114 -1
- package/dist/SmarticoAPI.d.ts +4 -1
- package/dist/WSAPI/WSAPI.d.ts +4 -1
- package/dist/WSAPI/WSAPITypes.d.ts +2 -0
- package/dist/index.js +46 -24
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +17 -5
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/classes/WSAPI.md +4 -1
- package/docs/api/interfaces/TStoreItem.md +8 -0
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +16 -2
- package/src/Store/StoreItem.ts +1 -0
- package/src/WSAPI/WSAPI.ts +4 -6
- package/src/WSAPI/WSAPITypes.ts +2 -0
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
|
-
##
|
|
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
|
|
package/dist/SmarticoAPI.d.ts
CHANGED
|
@@ -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;
|
package/dist/WSAPI/WSAPI.d.ts
CHANGED
|
@@ -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
|
|
@@ -521,6 +521,8 @@ export interface TStoreItem {
|
|
|
521
521
|
only_in_custom_section?: boolean;
|
|
522
522
|
/** ID of specific Custom Section type */
|
|
523
523
|
custom_section_type_id?: number;
|
|
524
|
+
/** The message that should be shown to the user if they are not eligible to buy it. This message can be used to explain the reason why user cannot buy the item, e.g. 'You should be VIP to buy this item'. */
|
|
525
|
+
cant_buy_message?: string;
|
|
524
526
|
}
|
|
525
527
|
/**
|
|
526
528
|
* TAchCategory describes the badge category item. Each badge item can be assigned to 1 or more categories
|
package/dist/index.js
CHANGED
|
@@ -1026,7 +1026,7 @@ var StoreItemTransform = function StoreItemTransform(items) {
|
|
|
1026
1026
|
return r.id >= 1;
|
|
1027
1027
|
}).map(function (r) {
|
|
1028
1028
|
var _r$itemPublicMeta$pri, _r$categoryIds;
|
|
1029
|
-
var x = {
|
|
1029
|
+
var x = _extends({
|
|
1030
1030
|
id: r.id,
|
|
1031
1031
|
name: r.itemPublicMeta.name,
|
|
1032
1032
|
purchase_type: mapPurchaseType$1(r.itemPublicMeta.purchase_type),
|
|
@@ -1051,7 +1051,9 @@ var StoreItemTransform = function StoreItemTransform(items) {
|
|
|
1051
1051
|
custom_section_id: r.itemPublicMeta.custom_section_id,
|
|
1052
1052
|
only_in_custom_section: r.itemPublicMeta.only_in_custom_section,
|
|
1053
1053
|
custom_section_type_id: r.itemPublicMeta.custom_section_type_id
|
|
1054
|
-
}
|
|
1054
|
+
}, r.itemPublicMeta.cant_buy_message ? {
|
|
1055
|
+
cant_buy_message: r.itemPublicMeta.cant_buy_message
|
|
1056
|
+
} : {});
|
|
1055
1057
|
return x;
|
|
1056
1058
|
});
|
|
1057
1059
|
};
|
|
@@ -3675,7 +3677,8 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
3675
3677
|
}
|
|
3676
3678
|
}
|
|
3677
3679
|
/**
|
|
3678
|
-
* Returns draw run for provided raffle_id and run_id
|
|
3680
|
+
* Returns draw run for provided raffle_id and run_id.
|
|
3681
|
+
* You can pass winners_from and winners_to parameters to get a specific range of winners. Default is 0-20.
|
|
3679
3682
|
*
|
|
3680
3683
|
*
|
|
3681
3684
|
* **Example**:
|
|
@@ -3700,12 +3703,10 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
3700
3703
|
_proto.getRaffleDrawRun = function getRaffleDrawRun(props) {
|
|
3701
3704
|
try {
|
|
3702
3705
|
var _this57 = this;
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
return drawRunTransform(res);
|
|
3708
|
-
});
|
|
3706
|
+
if (!props.raffle_id || !props.run_id) {
|
|
3707
|
+
throw new Error('both raffle_id and run_id are required');
|
|
3708
|
+
}
|
|
3709
|
+
return Promise.resolve(_this57.api.getRaffleDrawRunT(null, props.raffle_id, props.run_id, props.winners_from, props.winners_to));
|
|
3709
3710
|
} catch (e) {
|
|
3710
3711
|
return Promise.reject(e);
|
|
3711
3712
|
}
|
|
@@ -5259,43 +5260,64 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
5259
5260
|
return Promise.reject(e);
|
|
5260
5261
|
}
|
|
5261
5262
|
};
|
|
5262
|
-
_proto.
|
|
5263
|
+
_proto.getRaffleDrawRunT = function getRaffleDrawRunT(user_ext_id, raffle_id, run_id, winners_from, winners_to) {
|
|
5264
|
+
if (winners_from === void 0) {
|
|
5265
|
+
winners_from = 0;
|
|
5266
|
+
}
|
|
5267
|
+
if (winners_to === void 0) {
|
|
5268
|
+
winners_to = 20;
|
|
5269
|
+
}
|
|
5263
5270
|
try {
|
|
5264
5271
|
var _this72 = this;
|
|
5265
|
-
var
|
|
5266
|
-
|
|
5272
|
+
var winners_limit = winners_to - winners_from > 50 ? 50 : winners_to - winners_from;
|
|
5273
|
+
var winners_offset = winners_from;
|
|
5274
|
+
return Promise.resolve(_this72.getRaffleDrawRun(user_ext_id, {
|
|
5275
|
+
raffle_id: raffle_id,
|
|
5276
|
+
run_id: run_id,
|
|
5277
|
+
winners_limit: winners_limit,
|
|
5278
|
+
winners_offset: winners_offset
|
|
5279
|
+
})).then(drawRunTransform);
|
|
5267
5280
|
} catch (e) {
|
|
5268
5281
|
return Promise.reject(e);
|
|
5269
5282
|
}
|
|
5270
5283
|
};
|
|
5271
|
-
_proto.
|
|
5284
|
+
_proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(user_ext_id, props) {
|
|
5272
5285
|
try {
|
|
5273
5286
|
var _this73 = this;
|
|
5274
|
-
var message = _this73.buildMessage(user_ext_id, exports.ClassId.
|
|
5275
|
-
return Promise.resolve(_this73.send(message, exports.ClassId.
|
|
5287
|
+
var message = _this73.buildMessage(user_ext_id, exports.ClassId.RAF_GET_DRAW_HISTORY_REQUEST, props);
|
|
5288
|
+
return Promise.resolve(_this73.send(message, exports.ClassId.RAF_GET_DRAW_HISTORY_RESPONSE));
|
|
5276
5289
|
} catch (e) {
|
|
5277
5290
|
return Promise.reject(e);
|
|
5278
5291
|
}
|
|
5279
5292
|
};
|
|
5280
|
-
_proto.
|
|
5293
|
+
_proto.claimRafflePrize = function claimRafflePrize(user_ext_id, props) {
|
|
5281
5294
|
try {
|
|
5282
5295
|
var _this74 = this;
|
|
5283
|
-
var message = _this74.buildMessage(user_ext_id, exports.ClassId.
|
|
5284
|
-
return Promise.resolve(_this74.send(message, exports.ClassId.
|
|
5296
|
+
var message = _this74.buildMessage(user_ext_id, exports.ClassId.RAF_CLAIM_PRIZE_REQUEST, props);
|
|
5297
|
+
return Promise.resolve(_this74.send(message, exports.ClassId.RAF_CLAIM_PRIZE_RESPONSE));
|
|
5285
5298
|
} catch (e) {
|
|
5286
5299
|
return Promise.reject(e);
|
|
5287
5300
|
}
|
|
5288
5301
|
};
|
|
5289
|
-
_proto.
|
|
5302
|
+
_proto.raffleOptin = function raffleOptin(user_ext_id, props) {
|
|
5290
5303
|
try {
|
|
5291
5304
|
var _this75 = this;
|
|
5292
|
-
var message = _this75.buildMessage(user_ext_id, exports.ClassId.
|
|
5305
|
+
var message = _this75.buildMessage(user_ext_id, exports.ClassId.RAF_OPTIN_REQUEST, props);
|
|
5306
|
+
return Promise.resolve(_this75.send(message, exports.ClassId.RAF_OPTIN_RESPONSE));
|
|
5307
|
+
} catch (e) {
|
|
5308
|
+
return Promise.reject(e);
|
|
5309
|
+
}
|
|
5310
|
+
};
|
|
5311
|
+
_proto.getActivityLog = function getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset) {
|
|
5312
|
+
try {
|
|
5313
|
+
var _this76 = this;
|
|
5314
|
+
var message = _this76.buildMessage(user_ext_id, exports.ClassId.GET_POINT_HISTORY_REQUEST, {
|
|
5293
5315
|
startTimeSeconds: Math.floor(startTimeSeconds),
|
|
5294
5316
|
endTimeSeconds: Math.floor(endTimeSeconds),
|
|
5295
5317
|
limit: limit,
|
|
5296
5318
|
offset: offset
|
|
5297
5319
|
});
|
|
5298
|
-
return Promise.resolve(
|
|
5320
|
+
return Promise.resolve(_this76.send(message, exports.ClassId.GET_POINT_HISTORY_RESPONSE));
|
|
5299
5321
|
} catch (e) {
|
|
5300
5322
|
return Promise.reject(e);
|
|
5301
5323
|
}
|
|
@@ -5308,11 +5330,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
5308
5330
|
to = 50;
|
|
5309
5331
|
}
|
|
5310
5332
|
try {
|
|
5311
|
-
var
|
|
5333
|
+
var _this77 = this;
|
|
5312
5334
|
var limit = to - from > 50 ? 50 : to - from;
|
|
5313
5335
|
var offset = from;
|
|
5314
|
-
return Promise.resolve(
|
|
5315
|
-
return ActivityLogTransform(
|
|
5336
|
+
return Promise.resolve(_this77.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this77$getActivityLo) {
|
|
5337
|
+
return ActivityLogTransform(_this77$getActivityLo.logHistory);
|
|
5316
5338
|
});
|
|
5317
5339
|
} catch (e) {
|
|
5318
5340
|
return Promise.reject(e);
|