Skip to main content
Alayna_Truttmann
March 1, 2021
Question

getLocalPaintStyles() but for libraries?

  • March 1, 2021
  • 7 replies
  • 3252 views

I’m trying to get all the paint styles from a team library in my personal file. I see that there is getLocalPaintStyles() to get local styles but I’m not sure how to use this same behavior to grab all the library styles. Is there an equivalent for getting shared library styles?

This topic has been closed for replies.

7 replies

Gavin
Active Member
March 1, 2021

Unfortunately there isn’t the equivalent API method for libraries. To accomplish this you’ll need to find a way to get the keys of all the paint styles you want from the file which is your library and import them using importStyleByKeyAsync().

You could hardcode these keys into your plugin or you could host them on a server. It’s a bit of a faff but the only way I’m aware of at the moment.

Alayna_Truttmann
March 2, 2021

Thanks for the info Gavin! Appreciate the help.

Finch
March 3, 2021

You can fetch those keys via the REST API, from the end point
https://api.figma.com/v1/files/<FILE KEY>/styles
You’ll need authentication, via an API key, for a user with view access to that file.

David_Bonnet
New Participant
October 10, 2021

It is very unpractical to make authenticated Figma REST API calls from a plugin (unless I’m missing something). Is there a particular reason plugins cannot easily access library styles? Is there an ETA to provide an API method?

IMHO, this is critical to enable plugins to reuse styles and enable their configuration through styles. The Figma plugin development experience is already quite limited, but this even prevents basic modularity and reuse principles which contradicts Figma’s user experience.

For example, a plugin could provide the construction of a specific set of nodes based on some styles available in the document (colors, font styles), which could be (and mostly are) referenced from a library. Without an easy way to access them, plugin developers have to provide a setup UI (colors, font styles) that forces users to repeat their styling.

Benoit_Rajalu
March 1, 2022

Having to perform the REST API call when the current file already has the info available is also fairly weird in a plugin context. A getRemotePaintStyles(FILE_KEY) (same for text etc…) method would be much better for plugin creation.

FlorianModel
New Participant
March 21, 2023

Really a shame to be honest. @Figma_Support Is there a timeline on an API update?

vernikr
New Participant
January 27, 2024

So how do plugins like Style Organizer https://www.figma.com/community/plugin/816627069580757929 manage to get all remote library styles?