Skip to main content

index/classes/OEmbedService.md

OEmbed Service Class

Provides methods for accessing oEmbed data for social media previews:

  • Home page oEmbed (featuring top/live token)
  • Pool/token oEmbed (for /buy-sell/:tokenName pages)
  • Profile oEmbed (for /profile/:address pages)

Response Formats:

  • HTML (default): Returns meta tags for social previews
  • JSON: Returns oEmbed spec-compliant JSON

Cache Headers: Responses include Cache-Control headers (60s fresh, 5min stale-while-revalidate)

Public endpoint - no authentication required.

Example​

const oembedService = new OEmbedService(httpClient, true);

// Get pool oEmbed as JSON
const { oembed } = await oembedService.getPoolOEmbedJson({ tokenName: 'anime' });
console.log('Title:', oembed.title);
console.log('Live:', oembed.isLive);

// Get profile oEmbed as HTML
const { html } = await oembedService.getProfileOEmbedHtml({
address: 'eth|123...'
});
console.log(html);

Extends​

  • BaseService

Constructors​

Constructor​

new OEmbedService(http, debugMode?): OEmbedService

Parameters​

ParameterType
httpHttpClient
debugMode?boolean

Returns​

OEmbedService

Overrides​

BaseService.constructor

Methods​

getHomeOEmbedHtml()​

getHomeOEmbedHtml(options?): Promise<GetHomeOEmbedHtmlResult>

Get home page oEmbed as HTML

Returns HTML with meta tags for social media previews.

Parameters​

ParameterType
options?GetHomeOEmbedOptions

Returns​

Promise<GetHomeOEmbedHtmlResult>

HTML string with meta tags

Example​

const { html } = await oembedService.getHomeOEmbedHtml();
// html contains <meta property="og:..." /> tags

getHomeOEmbedJson()​

getHomeOEmbedJson(options?): Promise<GetHomeOEmbedJsonResult>

Get home page oEmbed as JSON

Returns oEmbed data for the site homepage, featuring the top/live token.

Parameters​

ParameterType
options?GetHomeOEmbedOptions

Returns​

Promise<GetHomeOEmbedJsonResult>

Home oEmbed data

Example​

const { oembed } = await oembedService.getHomeOEmbedJson();
console.log('Site:', oembed.provider_name);
console.log('Featured token:', oembed.featuredToken);

getPoolOEmbedHtml()​

getPoolOEmbedHtml(options): Promise<GetPoolOEmbedHtmlResult>

Get pool/token oEmbed as HTML

Returns HTML with meta tags for social media previews.

Parameters​

ParameterTypeDescription
optionsGetPoolOEmbedOptionsOptions with tokenName

Returns​

Promise<GetPoolOEmbedHtmlResult>

HTML string with meta tags

Example​

const { html } = await oembedService.getPoolOEmbedHtml({ tokenName: 'anime' });
// html contains <meta property="og:..." /> tags

getPoolOEmbedJson()​

getPoolOEmbedJson(options): Promise<GetPoolOEmbedJsonResult>

Get pool/token oEmbed as JSON

Returns oEmbed data for a token's buy/sell page.

Parameters​

ParameterTypeDescription
optionsGetPoolOEmbedOptionsOptions with tokenName

Returns​

Promise<GetPoolOEmbedJsonResult>

Pool oEmbed data

Example​

const { oembed } = await oembedService.getPoolOEmbedJson({ tokenName: 'anime' });
console.log('Token:', oembed.tokenName);
console.log('Symbol:', oembed.symbol);
console.log('Live stream:', oembed.isLive);
console.log('Viewers:', oembed.viewerCount);

getProfileOEmbedHtml()​

getProfileOEmbedHtml(options): Promise<GetProfileOEmbedHtmlResult>

Get profile oEmbed as HTML

Returns HTML with meta tags for social media previews.

Parameters​

ParameterTypeDescription
optionsGetProfileOEmbedOptionsOptions with address

Returns​

Promise<GetProfileOEmbedHtmlResult>

HTML string with meta tags

Example​

const { html } = await oembedService.getProfileOEmbedHtml({
address: 'eth|123...'
});
// html contains <meta property="og:..." /> tags

getProfileOEmbedJson()​

getProfileOEmbedJson(options): Promise<GetProfileOEmbedJsonResult>

Get profile oEmbed as JSON

Returns oEmbed data for a user's profile page.

Parameters​

ParameterTypeDescription
optionsGetProfileOEmbedOptionsOptions with address

Returns​

Promise<GetProfileOEmbedJsonResult>

Profile oEmbed data

Example​

const { oembed } = await oembedService.getProfileOEmbedJson({
address: 'eth|123...'
});
console.log('User:', oembed.displayName);
console.log('Tokens created:', oembed.tokensCreated);
console.log('Graduated:', oembed.tokensGraduated);
console.log('Volume:', oembed.totalVolumeGala);

setJwtAuth()​

setJwtAuth(jwtAuth): void

Set the JWT authentication manager. Allows dynamic configuration of JWT auth after service creation.

Parameters​

ParameterTypeDescription
jwtAuthJwtAuthJWT auth manager instance

Returns​

void

Inherited from​

BaseService.setJwtAuth