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
base service
Constructors
Constructor
new OEmbedService(
http,debugMode?):OEmbedService
Parameters
| Parameter | Type |
|---|---|
http | HttpClient |
debugMode? | boolean |
Returns
OEmbedService
Overrides
BaseService.constructor
debug mode embed service http client base
Methods
getHomeOEmbedHtml()
getHomeOEmbedHtml(
options?):Promise<GetHomeOEmbedHtmlResult>
Get home page oEmbed as HTML
Returns HTML with meta tags for social media previews.
Parameters
| Parameter | Type |
|---|---|
options? | GetHomeOEmbedOptions |
Returns
Promise<GetHomeOEmbedHtmlResult>
HTML string with meta tags
Example
const { html } = await oembedService.getHomeOEmbedHtml();
// html contains <meta property="og:..." /> tags
get home embed html result options
getHomeOEmbedJson()
getHomeOEmbedJson(
options?):Promise<GetHomeOEmbedJsonResult>
Get home page oEmbed as JSON
Returns oEmbed data for the site homepage, featuring the top/live token.
Parameters
| Parameter | Type |
|---|---|
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);
get home embed json result options
getPoolOEmbedHtml()
getPoolOEmbedHtml(
options):Promise<GetPoolOEmbedHtmlResult>
Get pool/token oEmbed as HTML
Returns HTML with meta tags for social media previews.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | GetPoolOEmbedOptions | Options with tokenName |
Returns
Promise<GetPoolOEmbedHtmlResult>
HTML string with meta tags
Example
const { html } = await oembedService.getPoolOEmbedHtml({ tokenName: 'anime' });
// html contains <meta property="og:..." /> tags
get pool embed html result options
getPoolOEmbedJson()
getPoolOEmbedJson(
options):Promise<GetPoolOEmbedJsonResult>
Get pool/token oEmbed as JSON
Returns oEmbed data for a token's buy/sell page.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | GetPoolOEmbedOptions | Options 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);
get pool embed json result options
getProfileOEmbedHtml()
getProfileOEmbedHtml(
options):Promise<GetProfileOEmbedHtmlResult>
Get profile oEmbed as HTML
Returns HTML with meta tags for social media previews.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | GetProfileOEmbedOptions | Options 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
get profile embed html result options
getProfileOEmbedJson()
getProfileOEmbedJson(
options):Promise<GetProfileOEmbedJsonResult>
Get profile oEmbed as JSON
Returns oEmbed data for a user's profile page.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | GetProfileOEmbedOptions | Options 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);
get profile embed json result options
setJwtAuth()
setJwtAuth(
jwtAuth):void
Set the JWT authentication manager. Allows dynamic configuration of JWT auth after service creation.
Parameters
| Parameter | Type | Description |
|---|---|---|
jwtAuth | JwtAuth | JWT auth manager instance |
Returns
void
Inherited from
BaseService.setJwtAuth
set jwt auth base service