How to get the Styles from a Figma document using their API with Nodejs

Posted on October 3, 2021

Once you have the JSON document from a first Figma API call, here the code to get the style definitions, if they have been defined in the document:

// assuming `file` is the JSON document already retrieved from the Figma API

const styleNodes = Object.keys(file.styles).toString()

axios(`${docId}/nodes/?ids=${styleNodes}`, options).then(data => {

The above fetch return the list of all the styles and their CSS properties as well.