This is the NodeJS Typescript SDK for API described at https://github.com/merokudao/storekit/blob/main/apps/docs/public/api-specs/meroku-server.yml and hosted at https://docs.meroku.store.
This package is generated using Swagger CodeGen. More details on that follows the usage section.
The versioning of this package is consistent with the API spec version. So if you are using OpenAPI Spec
v 1.21, then the package should be 1.21
.
T O C
npm install @merokudao/storekit-sdk
or
yarn add @merokudao/storekit-sdk
import {
DAppRegistryApi,
Dapp,
DappAvailableOnPlatformEnum,
StoreRegistryApi,
DappCategoryEnum,
DappWithDevCreds,
DeveloperProfilesApi,
} from '@merokudao/storekit-sdk';
const baseURL = process.env.STOREKIT_API_URL as string | 'https://api.meroku.store';
// Configure the API and instantiate
const dAppRegistryAPI = new DAppRegistryApi(
{
basePath: baseURL
},
undefined,
undefined
);
// Get the dApps list
const dApps: Dapp[] = await dAppRegistryAPI.searchDapps();
There are URLs that support visit to an app's webapp or download the build for an app. These methods should be used instead of raw linking, because these store details about visits, downloads, installs and uninstalls. These metrics are used to prepare trending dapps.
Getting a dapp will always send it's global metrics.
The URL to visit a dapp's home page should be constructed as below. The return
value of getViewURL
should be shown on the UI. When user clicks on it,
they will be redirected to the dapp home page.
const basePath = process.env.STOREKIT_API_URL as string | 'https://api.meroku.store';
const dappId = "example.app";
const getViewURL = (base_path: string,
dappId: string,
userId: string | undefined,
userAddress: string | undefined) => {
if (!userId && !userAddress) {
throw Error("One of userId or userAddress must be defined");
}
if (userId) {
return `${base_path}/api/v1/o/view/${dappId}?userId=${userId}`;
} else if (userAddress) {
return `${base_path}/api/v1/o/view/${dappId}?userAddress=${userAddress}`;
}
}
AnalyticsApi.new()
const getDownloadURL = (base_path: string,
dappId: string,
userId: string | undefined,
userAddress: string | undefined) => {
if (!userId && !userAddress) {
throw Error("One of userId or userAddress must be defined");
}
if (userId) {
return `${base_path}/api/v1/o/download/${dappId}?userId=${userId}`;
} else if (userAddress) {
return `${base_path}/api/v1/o/download/${dappId}?userAddress=${userAddress}`;
}
}
In the UI the return value of getDownloadURL
should be shown. When user
clicks on it, they will be redirected to the download URL and the file will
be automatically downloaded.
const analyticsApi = new AnalyticsApi({
basePath: baseURL
});
const body: DappRating = {
dappId: 'test_example.app',
rating: 4,
comment: 'comment from user',
userId: 12
};
const response: DappRating = await analyticsApi.apiV1DappRatePost(body)
const dappId = 'test_example.dapp';
const userId = 2;
const userAddress = undefined;
const response: DappRating = await analyticsApi.apiV1DappRateGet(dappId, userId, userAddress);
Initialise the API as below.
const featuredApi = new FeaturedSectionApi({
basePath: baseURL
});
const featuredSections: Array<FeaturedSection> = await featuredApi.getFeaturedDAppsV1()
This should be iterated and shown on ui.
Gets the title of the registry
const title: string = await featuredApi.getStoreTitleV1()
const storeApi = new StoreRegistryApi()
APis to interact with appStore's
const stores = await storeApi.searchStores()
const stores = await storeApi.searchStoresByStoreId('kailash')
const stores = await storeApi.searchStoresByOwnerAddress('0xA0B867319e3fBb15181D118097b1069C6380222E')
const stores = await storeApi.autocompleteStores('unstoppable')
const developerApi = new DeveloperProfilesApi()
APis to interact with developer's
const developers = await developerApi.searchDeveloperProfile()
const developers = await developerApi.searchDeveloperByDevId('kai.dev')
const developers = await developerApi.searchDeveloperByOwnerAddress('0xA0B867319e3fBb15181D118097b1069C6380222E')
const developers = await developerApi.autocompleteDeveloper('kai')