@kolverse/sdk
v1.0.13
Published
This SDK provides functions to interact with KOLVerse.
Downloads
10
Readme
KOLVerse SDK
This SDK provides functions to interact with KOLVerse.
Installation
To install the SDK, use npm or yarn:
npm install @kolverse/sdk
Be aware that the SDK may be provided as a private package in other NPM registries or using different package names.
Usage
Importing the SDK
import {
connectToKolVerse,
handleKolVerseCallback,
Identity,
} from '@kolverse/sdk';
Functions
getKolsInSuperGuild
Retrieves the KOLs in a super guild.
Parameters:
guild
: The super guild to retrieve KOLs from.
Returns:
Promise<Kol[]>
: A promise that resolves to an array of KOLs.
Example:
const kols: Kol[] = await getKolsInSuperGuild('super-guild');
console.log(
'KOLs:',
kols.map(kol => `${kol.username} (${kol.invitationCode})`)
);
connectToKolVerse
Redirects the user to the KolVerse signup/signin flow with the provided invitation code and callbacks.
Parameters:
invitationCode
(string): The invitation code.successUrl
(string): The URL to redirect to upon successful flow.errorUrl
(string): The URL to redirect to if there is an error.
Example:
connectToKolVerse('your-invitation-code', '/success', '/error');
handleKolVerseCallback
Handles the callback from the KolVerse authentication flow.
Returns:
Identity
: An object containing the authenticated user's identity.
Throws:
AuthenticationFlowError
: If there is an error.
Example:
try {
const identity: Identity = handleKolVerseCallback();
console.log('Authenticated user:', identity.id, identity.username);
} catch (error) {
console.error('Authentication failed:', error);
}
activateGuild
Activates a guild for the authenticated user.
Parameters:
guild
(string): The guild to activate.
deactivateGuild
Deactivates a guild for the authenticated user.
Parameters:
guild
(string): The guild to activate.
Types
Identity
An interface representing the authenticated user's identity.
Properties:
id
(string): Integration ID of the authenticated user.username
(string): Twitter username of the authenticated user.
Kol
KOL essential details.
Properties:
username (string)
: Username of the KOL.profileImageUrl (string)
: Profile image URL of the KOL.invitationCode (string)
: Invitation code of the KOL.
Errors
AuthenticationFlowError
An error thrown during the authentication flow.