getLibrary()
Gets library/playlist data by ID or slug.
Signature
const response = await window.FairShareSDK.getLibrary(identifier);
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | string | Library/playlist ID or slug |
Returns
Promise<LibraryResponse> — The response object containing metadata and library data.
Library Object:
| Property | Type | Description |
|---|---|---|
id | number | Library ID |
title | string | Library title |
slug | string | URL-friendly identifier |
custom_slug | boolean | Whether slug is custom |
enrollment_packs | array | Array of enrollment packs associated with the library |
library_items | array | Array of library items (pages and media) in the playlist |
products | array | Array of products attached to the playlist |
Example
// Get library/playlist const response = await window.FairShareSDK.getLibrary("my-playlist-id"); console.log('Title:', response.library.title); console.log('Slug:', response.library.slug); // Loop through library items response.library.library_items.forEach(item => { console.log(`${item.type}:`, item.item.title); }); // Access products response.library.products.forEach(product => { console.log('Product:', product.title); });