Cricap Mini App SDK Documentation

By Cricap ยท Updated ยท Contact the team

Using the current Trends host? Start with the Trends integration guide. It describes the supported bridge and review flow. This API reference covers broader SDK interfaces; do not assume every interface is available in the embedded web host. Check the SDK source for version-specific details.

Official JavaScript SDK for building mini apps on the Cricap platform. Build, deploy, and monetize your games with seamless integration.

๐ŸŽ‰ v1.1.0 Released! New Mini App Ecosystem, QCoin system, and enhanced API endpoints.

๐Ÿš€ Quick Start

npm install @cricap/miniapp-sdk
import { initCricapSDK } from '@cricap/miniapp-sdk';

const sdk = initCricapSDK({
  appId: 'miniapp_your_id',
  environment: 'production',
  debug: true,
});

const result = await sdk.initialize();
if (result.success) {
  await sdk.ui.show({ animation: 'slide-up' });
}

Overview

The Cricap Mini App Ecosystem enables third-party developers to build applications that run within the Cricap platform. This SDK provides seamless integration with authentication, user data, leaderboards, wallet, and real-time notifications.

Installation

npm

npm install @cricap/miniapp-sdk

yarn

yarn add @cricap/miniapp-sdk

SDK Initialization

OptionTypeRequiredDescription
appIdstringโœ…Your mini app unique identifier
environmentstringโœ…development, staging, or production
debugbooleanโŒEnable debug logging

UI Container Methods

Show Mini App

await sdk.ui.show({
  animation: 'slide-up',
  style: 'sheet',
  overlay: true,
  closeOnBackdrop: true
});

Notification System

await sdk.notifications.subscribe([
  'leaderboard.updates',
  'wallet.transactions'
]);

sdk.notifications.onNotification((notification) => {
  console.log('Received:', notification);
});

Backend API - Authentication

Base URLs

EnvironmentBase URL
Productionhttps://api.cricap.com/v1
Staginghttps://api-staging.cricap.com/v1

Token Exchange

POST /auth/token
// Request
{
  "grantType": "authorization_code",
  "code": "auth_code_from_container",
  "appId": "miniapp_abc123",
  "appSecret": "sk_live_xxxxxxxx"
}

// Response
{
  "success": true,
  "data": {
    "accessToken": "eyJhbGciOiJSUzI1NiIs...",
    "refreshToken": "rt_xxxxxxxx",
    "tokenType": "Bearer",
    "expiresIn": 3600
  }
}

Backend API - User

Get User Profile

GET /users/me
// Response
{
  "success": true,
  "data": {
    "userId": "user_xyz789",
    "username": "gamer123",
    "displayName": "Pro Gamer",
    "avatarUrl": "https://cdn.cricap.com/avatars/xyz789.png"
  }
}

Backend API - QCoin System

Update QCoin Balance

POST /qcoin/update
// Request
{
  "amount": 100,
  "reason": "Game reward"
}

// Response
{
  "message": "QCoin balance updated",
  "balance": 500,
  "change": 100
}

Webhooks

Event Types

Event TypeDescription
user.authUser authentication event
user.wallet.updateWallet balance changed
qcoin.updateQCoin balance updated

Frequently Asked Questions

How do I install the Cricap Mini App SDK?

Install using npm: npm install @cricap/miniapp-sdk

What is the base URL for the Cricap API?

Production: https://api.cricap.com/v1, Staging: https://api-staging.cricap.com/v1

How do I authenticate with the Cricap API?

Use the /auth/token endpoint to exchange an authorization code for an access token.