livestory-js-sdk
v1.0.3
Published
JavaScript SDK for Live Story's Delivery API
Readme
Live Story JavaScript SDK
Installation
npm install livestory-js-sdk # yarn add livestory-js-sdkCompatibility
| Version to install | Support | | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | Latest livestory-js-sdk | Modern browsers + Node 18+ |
How to use it
Using the Content Delivery API
For access token generation, refer to the Developer Documentation
// 1. Import the LiveStory client
import LiveStoryClient from "livestory-js-sdk";
// 2. Initialize the client using the access token generated
// in your Live Story dashboard at https://design.livestory.io
const Livestory = new LiveStoryClient({
accessToken: <YOUR_ACCESS_TOKEN>
});Usage examples
// Get layouts by folder id
try {
const response = await Livestory.getLayouts({ folder_id: 'your_folder_id' });
console.log(response.items);
}
catch (err) {
const lsErr = err as ILsError;
console.error('Error fetching layouts:', lsErr.status, lsErr.message);
}// Get layouts by attribute(s)
try {
const response = await Livestory.getLayouts({
filter_query: {
myfield: {
in: 'value1,value2'
}
}
});
console.log(response.items);
}
catch (err) {
const lsErr = err as ILsError;
console.error('Error fetching layouts:', lsErr.status, lsErr.message);
}