Class: TorqueAdminClient

@torque-labs/torque-ts-sdkDocs


@torque-labs/torque-ts-sdk / TorqueAdminClient

Class: TorqueAdminClient

The TorqueAdminClient class is used to manage admin actions in the Torque API.

Example

const client = new TorqueAdminClient(TorqueAdminClientOptions);

const result = await client.createCampaign(<campaignData>);
const result = await client.endCampaign(<campaignData>);

Constructors

new TorqueAdminClient()

new TorqueAdminClient(options): TorqueAdminClient

Create a new instance of the TorqueAdminClient class with the provided API key.

Parameters

ParameterTypeDescription

options

The options for the TorqueAdminClient.

Returns

TorqueAdminClient

Defined in

src/classes/admin.ts:86

Properties

PropertyType

client

connection

Connection

userClient

undefined | TorqueUserClient

tokenList

undefined | SafeToken[]

Methods

createCampaign()

createCampaign(data): Promise<SignatureField>

Create a new campaign with the provided data.

Parameters

ParameterTypeDescription

data

object

The data for the campaign to create.

data.asymmetricRewards?

{ amount: string; participants: null | RaffleParticipants; payoutTx: null | string; tokenAddress: string; userPubKey: null | string; }[]

-

data.audience?

null | string

-

data.blinkOnly?

null | boolean

-

data.campaignContent?

null | string

-

data.campaignDescription?

null | string

-

data.campaignImage?

null | string

-

data.campaignName

string

-

data.campaignType

CampaignType

-

data.conversionAudience?

object

-

data.conversionAudience.campaignIds

string[]

-

data.conversionAudience.operation

ConversionAudienceOperation

-

data.conversionCount?

null | number

-

data.endTime

number

-

data.eventConfig

( | { requirement: { antiSybilFee: number; requireSignature: boolean; targetUrl: string; }; type: CLICK; } | { requirement: { description: null | string; eventName: string; fields: ({ description: null | string; image: null | string; label: null | string; name: string; } & { type: "string"; validation: { match: ... | ... | ...; required: ... | ... | ... | ...; }; } | { description: null | string; image: null | string; label: null | string; name: string; } & { type: "number"; validation: { max: ... | ... | ...; min: ... | ... | ...; }; } | { description: null | string; image: null | string; label: null | string; name: string; } & { type: "boolean"; validation: { match: ... | ... | ... | ...; }; })[]; formEnabled: boolean; targetUrl: null | string; }; type: CUSTOM_EVENT; } | { requirement: { marketIndex: number; shares: number; }; type: DRIFT_BET; } | { requirement: { minAmount: number; tokenAddress: string; }; type: DRIFT_DEPOSIT; } | { requirement: { antiSybilFee: number; fields: { label: string; name: string; options: { label: string; value: string; }[]; required: null | boolean; type: FormFieldType; }[]; }; type: FORM_SUBMISSION; } | { requirement: { amount: number; tokenAddress: string; }; type: KAMINO_LEND; } | { requirement: { amount: number; tokenAddress: string; }; type: MARGINFI_LEND; } | { requirement: { fields: ({ description: null | string; image: null | string; label: null | string; name: string; } & { type: "string"; validation: { match: ... | ... | ...; required: ... | ... | ... | ...; }; } | { description: null | string; image: null | string; label: null | string; name: string; } & { type: "number"; validation: { max: ... | ... | ...; min: ... | ... | ...; }; } | { description: null | string; image: null | string; label: null | string; name: string; } & { type: "boolean"; validation: { match: ... | ... | ... | ...; }; })[]; }; type: MEMO; } | { requirement: { minAmount: number; mint: string; }; type: NFT_BUY_BID; } | { requirement: { collectionAddress: string; tradeType: NftCollectionTradeType; }; type: NFT_COLLECTION_TRADE; } | { requirement: { customProgramId: string; daoPubKey: string; proposalPubKey: string; }; type: REALMS_VOTE; } | { requirement: { amount: number; epochs: number; validator: string; }; type: STAKE_SOL; } | { requirement: { inAmount: null | number; inToken: null | string; outAmount: null | number; outToken: null | string; usdcValue: null | number; }; timeConfig: { duration: number; requirement: { amount: number; token: string; tokenStandard: string; }; type: TOKEN_HOLDING; }; type: SWAP; } | { requirement: { collectionIds: string[]; }; type: TENSOR_BID; } | { requirement: { collectionIds: string[]; }; type: TENSOR_BUY; })[]

-

data.landingPage

string

-

data.lootBoxRewards

{ enabled: true; rewards: { amount: number; users: number; }[]; tokenAddress: string; } | { enabled: false; }

-

data.offerBgImage?

null | string

-

data.offerTheme

OfferTheme

-

data.publisherPayoutPerConversion

number

-

data.publisherRewardType

RewardType

-

data.publisherTokenAddress?

string

-

data.startTime

number

-

data.userPayoutPerConversion?

number

-

data.userRewardType?

RewardType

-

data.userTokenAddress?

string

-

Returns

Promise<SignatureField>

A promise that resolves with the signature of the transaction.

Defined in

src/classes/admin.ts:226


deleteAudience()

deleteAudience(id): Promise<{
  audienceId: string;
}>

Delete an existing audience.

Parameters

ParameterTypeDescription

id

string

The ID of the audience to delete.

Returns

Promise<{ audienceId: string; }>

A promise that resolves to the deleted audience.

NameType

audienceId

string

Throws

If the client is not initialized or if there was an error deleting the audience.

Defined in

src/classes/admin.ts:691


endCampaign()

endCampaign(data): Promise<SignatureField>

End a campaign using the provided campaign ID.

Parameters

ParameterTypeDescription

data

object

The ID of the campaign to end.

data.campaignId

string

-

Returns

Promise<SignatureField>

A promise that resolves to the signature of the transaction.

Throws

Throws an error if the client is not initialized or if there is an error ending the campaign.

Defined in

src/classes/admin.ts:261


getActiveCampaigns()

getActiveCampaigns(params?): Promise<{
  campaigns: ApiCampaign[];
}>

Get a list of all currently active campaigns.

Parameters

ParameterType

params?

object

params.advertiserPubKey?

string

params.limit?

number

params.page?

number

params.status?

string

Returns

Promise<{ campaigns: ApiCampaign[]; }>

A promise that resolves to an array of ApiCampaign objects.

NameType

campaigns

Throws

If the client is not initialized or there was an error getting the list of campaigns.

Defined in

src/classes/admin.ts:131


getAudience()

getAudience(id): Promise<ApiAudience>

Get an audience by ID.

Parameters

ParameterTypeDescription

id

string

The ID of the audience to fetch.

Returns

Promise<ApiAudience>

A promise that resolves to an array of Audiences.

Throws

If the client is not initialized or there was an error getting the audience.

Defined in

src/classes/admin.ts:523


getAudiences()

getAudiences(): Promise<{
  audiences: ApiAudience[];
}>

Get a list of the user's saved audiences.

Returns

Promise<{ audiences: ApiAudience[]; }>

A promise that resolves to an array of Audiences.

NameType

audiences

Throws

If the client is not initialized or there was an error getting the audiences.

Defined in

src/classes/admin.ts:559


getCampaign()

getCampaign(campaignId): Promise<ApiCampaign>

Get the details of a specific campaign.

Parameters

ParameterTypeDescription

campaignId

string

The ID of the campaign to retrieve.

Returns

Promise<ApiCampaign>

A Promise that resolves to the campaign data.

Throws

Throws an error if a fetching a campaign failed.

Defined in

src/classes/admin.ts:198


getCampaignAnalytics()

getCampaignAnalytics(campaignId): Promise<CampaignAnalytics>

Get the analytics data for a specific campaign.

Parameters

ParameterTypeDescription

campaignId

string

The ID of the campaign to retrieve the analytics for.

Returns

Promise<CampaignAnalytics>

A Promise that resolves to the analytics data for the campaign.

Throws

Throws an error if a fetching a campaign failed.

Defined in

src/classes/admin.ts:487


getCampaigns()

getCampaigns(params?, includeHistoric?): Promise<{
  campaigns: ApiCampaign[];
}>

Parameters

ParameterType

params?

object

params.advertiserPubKey?

string

params.limit?

number

params.page?

number

params.status?

string

includeHistoric?

boolean

Returns

Promise<{ campaigns: ApiCampaign[]; }>

NameType

campaigns

Defined in

src/classes/admin.ts:150


getHistoricCampaigns()

getHistoricCampaigns(params?): Promise<{
  campaigns: ApiCampaign[];
}>

Get a list of all historic campaigns.

Parameters

ParameterType

params?

object

params.advertiserPubKey?

string

params.limit?

number

params.page?

number

params.status?

string

Returns

Promise<{ campaigns: ApiCampaign[]; }>

A promise that resolves to an array of ApiCampaign objects.

NameType

campaigns

Throws

If the client is not initialized or there was an error getting the list of campaigns.

Defined in

src/classes/admin.ts:142


getLeaderboard()

getLeaderboard(campaignId): Promise<ApiCampaignLeaderboard>

Get the leaderboard for a specific campaign.

Parameters

ParameterTypeDescription

campaignId

string

The ID of the campaign to get the leaderboard for.

Returns

Promise<ApiCampaignLeaderboard>

A Promise that resolves to the leaderboard data for the campaign.

Throws

Throws an error if the client is not initialized or if there is an error getting the leaderboard.

Defined in

src/classes/admin.ts:295


initPublisher()

initPublisher(): Promise<string>

Initialize a publisher account for the current user.

Returns

Promise<string>

A promise that resolves to the signature of the transaction.

Throws

Throws an error if there was an error creating the publisher.

Defined in

src/classes/admin.ts:361


logout()

logout(): Promise<void>

Returns

Promise<void>

Defined in

src/classes/admin.ts:114


payoutPublisher()

payoutPublisher(data): Promise<string>

Process a publisher payout for the current user, if eligible.

Parameters

ParameterType

data

object

data.amount

number

data.token

string

Returns

Promise<string>

A promise that resolves to the signature of the transaction.

Throws

Throws an error if there was an error paying out the publisher.

Defined in

src/classes/admin.ts:397


raffleRewards()

raffleRewards(campaignId): Promise<ApiRaffleRewards>

Get the raffle rewards for a specific campaign.

Parameters

ParameterTypeDescription

campaignId

string

The ID of the campaign to get the raffle rewards for.

Returns

Promise<ApiRaffleRewards>

Throws

Throws an error if the client is not initialized or if there is an error getting the raffle rewards.

Defined in

src/classes/admin.ts:325


saveAudience()

saveAudience(metadata, config?): Promise<{
  audienceId: string;
}>

Save an audience to the user's account.

Parameters

ParameterTypeDescription

metadata

The metadata of the audience.

config?

The configuration of the audience to save.

Returns

Promise<{ audienceId: string; }>

A promise that resolves to the id of the saved audience.

NameType

audienceId

string

Throws

If the client is not initialized or there was an error saving the audience.

Defined in

src/classes/admin.ts:598


updateAudience()

updateAudience(
   id, 
   metadata?, 
   config?): Promise<{
  audienceId: string;
}>

Update an existing audience with the provided configuration.

Parameters

ParameterTypeDescription

id

string

The ID of the audience to update.

metadata?

The metadata of the audience.

config?

The configuration of the audience to update.

Returns

Promise<{ audienceId: string; }>

A promise that resolves to the updated audience.

NameType

audienceId

string

Throws

If the client is not initialized or if there was an error updating the audience.

Defined in

src/classes/admin.ts:645


getSafeTokenList()

static getSafeTokenList(filter?, apiUrl?): Promise<SafeToken[]>

Retrieves the list of safe tokens from the Jupiter ag.

Parameters

ParameterTypeDescription

filter?

string

An optional filter to filter the tokens by text.

apiUrl?

string

-

Returns

Promise<SafeToken[]>

A promise that resolves to an array of SafeToken objects.

Throws

If the client is not initialized or there was an error fetching the safe token list.

Defined in

src/classes/admin.ts:439

Last updated