API Reference
Complete reference for all SDK methods available in your mini-app.
User Actions
WebApp.followUser(address: string)
Requests the Sociogram platform to initiate a "follow" action for a specified user address.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
const userAddressToFollow = '0x123...abc';
try {
WebApp.followUser(userAddressToFollow);
console.log(`Requested to follow user: ${userAddressToFollow}`);
} catch (error) {
console.error('Error requesting to follow user:', error);
}WebApp.openLink(url: string, options?: Record<string, unknown>)
Requests the Sociogram platform to open a given URL.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
WebApp.openLink('https://sociogram.dev', { target: '_blank' });
WebApp.openLink('https://docs.sociogram.dev');WebApp.readTextFromClipboard(text: string)
Requests the Sociogram platform to copy the provided text to the user's clipboard.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
const textToCopy = 'Hello, Sociogram!';
WebApp.readTextFromClipboard(textToCopy);Financial Transactions
WebApp.openInvoice(invoiceData: InvoiceData, callback?: InvoiceCallback)
Requests the Sociogram platform to open an invoice payment modal.
tsx
import WebApp, { CurrencyType } from '@sociogram-dev/mini-apps-sdk';
async function initiatePayment() {
const userId = WebApp.initData?.uid;
if (!userId) {
console.error('User ID not available.');
return;
}
const invoiceTitle = 'Premium Feature Access';
const invoicePrice = 10.5;
const currency = CurrencyType.USD;
try {
const invoicePayload = {
invoiceId: 'mock_invoice_123',
};
const invoiceId = WebApp.openInvoice(
{
invoicePayload: invoicePayload,
title: invoiceTitle,
price: invoicePrice,
currency: currency,
},
(status) => {
console.log(`Invoice ${invoiceId} status: ${status}`);
if (status === 'success') {
alert('Payment successful!');
} else {
alert('Payment failed or cancelled.');
}
}
);
} catch (error) {
console.error('Failed to initiate invoice:', error);
}
}User Lists & Social Graphs
WebApp.getFollowers(params?: GetUsersParams, callback?: (response: UsersResponse) => void)
Requests a list of followers for the current user.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
function fetchFollowers() {
const requestId = WebApp.getFollowers({ limit: 20 }, (response) => {
if (response.error) {
console.error('Failed to get followers:', response.error);
return;
}
console.log('Followers:', response.rows);
if (response.cursor) {
console.log('More followers available. Next cursor:', response.cursor);
}
});
}Content Sharing
WebApp.share(data: { text: string; url: string })
Requests the Sociogram platform to open a sharing dialog.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
WebApp.share({
text: 'Check out this amazing mini-app on Sociogram!',
url: 'https://sociogram.dev/your-mini-app-link',
});Post Interactions
WebApp.openRewardModal(data: PostActionData)
Requests the Sociogram platform to open the reward modal for a specific post.
tsx
import WebApp from '@sociogram-dev/mini-apps-sdk';
const postIdToReward = 'some_post_id_123';
WebApp.openRewardModal({ postId: postIdToReward });