Mini Apps API & SDK
How do I get started with the Mini Apps SDK?
To get started, install the official @sociogram-dev/mini-apps-sdk via npm or yarn. This SDK allows your web-based mini-application to communicate with the Sociogram host platform (whether it's running in a web iframe or a mobile WebView). For backend functionality, you will need the @sociogram-dev/platform-api SDK, which uses a MiniAppToken for authentication.
How does the user login process work for a Mini App?
When a user opens your Mini App, the Sociogram platform sends initial user data (like their wallet address and user ID) to your application. This data is available via WebApp.initData. Your app's frontend and backend can use this information to create a session and identify the user without a traditional login process.
How do I handle in-app purchases?
The in-app purchase process is managed through the Sociogram SDK.
- Invoice Generation: Your backend creates an invoice object with a price and payload (your internal purchase identifier).
- Frontend Call: Your Mini App's frontend passes this invoice to the Sociogram client using the WebApp.openInvoice() method.
- Webhook Callbacks: You set up a single webhook route on your backend to handle purchase validation and confirmation events sent by Sociogram. When a payment is successful, the Sociogram platform calls your webhook, and your backend delivers the digital goods to the user.
How can my backend send user notifications or verify user actions?
Using the backend SDK (@sociogram-dev/platform-api), you can:
- Send Notifications: Use the sdk.notifyUser(userId, message) method to send a direct notification to a user's Sociogram account.
- Verify Actions: The SDK provides methods to check if a user has performed specific on-platform actions, such as making a post (sdk.searchPublications), engaging with content (sdk.checkEngagement), or following another profile (sdk.checkFollow).
How do payouts for developers work?
All revenue generated from your Mini App accumulates in your Developer Balance. From the Sociogram Developer Portal, you can transfer these earnings to your Main Balance. Once the funds are in your Main Balance, you can withdraw them to your external crypto wallet. You can also use the backend SDK to transfer funds from your app's balance directly to your users.