Last updated

getLibrary()

Gets library/playlist data by ID or slug.

Signature

const response = await window.FairShareSDK.getLibrary(identifier);

Parameters

ParameterTypeDescription
identifierstringLibrary/playlist ID or slug

Returns

Promise<LibraryResponse> — The response object containing metadata and library data.

Library Object:

PropertyTypeDescription
idnumberLibrary ID
titlestringLibrary title
slugstringURL-friendly identifier
custom_slugbooleanWhether slug is custom
enrollment_packsarrayArray of enrollment packs associated with the library
library_itemsarrayArray of library items (pages and media) in the playlist
productsarrayArray 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);
});