Skip to main content

Hey there, I was hoping to get some guidance.


I call this async function to get a list of team libraries used with the team file where i’ve enabled them in the UI beforehand. It returns a list of 3 which is great but I was expecting 6 libraries?

Are there any gotchas i’m not seeing like a max return or even just naivety whilst resolving the promise?


async function getLibraries() {
const libraries =
await figma.teamLibrary.getAvailableLibraryVariableCollectionsAsync();
return libraries;
}

figma.showUI(__html__);
figma.ui.onmessage = async (msg) => {
const libraries = await getLibraries();
console.log(libraries);

figma.closePlugin();
};

My end goal is, within our team projects, to get a list of the full team libraries to get the key for a specific one and then retrieve a particular component set using the key.


Any help would be awesome, thanks!


You can’t get component keys from remote files anyway. You can only get variable keys.


Thanks for responding @Gleb. I see what you mean. Explains why I am only retrieving 3 libraries as they only have their variables coming back.


Is it possible to do what I am intending?


We have a specific commonly used component with many variables within a core team library. I want the plugin to show a form with inputs to quickly insert the component into the current page the user is working on. The library is enabled as a team library for all whichever file/project they’re working in.


It’s possible to get component keys in two ways:




  1. Using REST API




  2. By opening the plugin the desired file and saving the keys from there into ClientStorage.




Awesome, thank you. I’ll give them both a try now 🙌


Works a treat. Thank you again.


Reply