Skip to main content
Solved

Retrieving a list of Figma Team Libraries


Andy19

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!

Best answer by Gleb

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.

View original
This topic has been closed for replies.

5 replies

Gleb
  • Power Member
  • 4710 replies
  • June 17, 2024

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


Andy19
  • Author
  • 3 replies
  • June 17, 2024

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.


Gleb
  • Power Member
  • 4710 replies
  • Answer
  • June 17, 2024

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.


Andy19
  • Author
  • 3 replies
  • June 17, 2024

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


Andy19
  • Author
  • 3 replies
  • June 17, 2024

Works a treat. Thank you again.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings