Figma Support Forum

getLocalPaintStyles() but for libraries?

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?

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.

1 Like

Thanks for the info Gavin! Appreciate the help.

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.

1 Like