Get values associated with styles with files/styles API call

If I hit the file styles endpoint:
https://api.figma.com/v1/files/<key>/styles

I get an array of objects like so:

{
  "created_at": "2021-03-18T10:57:00.885Z",
  "description": "",
  "file_key": "…",
  "key": "…",
  "name": "red",
  "node_id": "2:5",
  "sort_position": "\"",
  "style_type": "FILL",
  "thumbnail_url": "…",
  "updated_at": "2021-03-18T10:57:00.885Z",
  "user": {
    …
  }
}

However what I also need is the value of that style. E.g. "value": "#ff0000"

Is there a way to get this? If not, can this be added?

15 Likes

Same problem. I see the way, but this way will be dumb.
As the first query → getting styles using https://api.figma.com/v1/files/:file/styles.
As other queries → Getting properties from each style using https://www.figma.com/file/:key/:pageNames?node-id=:node_id

Same issue here, I was trying to use GET style, but there is no values either
https://www.figma.com/developers/api#get-style-endpoint

I was also wondering about this. It feels like the most important thing that you’re looking for in a style object would be its value. Is there a plan to include them going forward?

Just bumping this. Would really love to see this implemented - the API is really limited if we can’t get the style value.

I am bumping this once again. Has anyone heard anything from Figma regarding this discrepancy in the styles data object?

I think you can get the style values by querying for the nodes associated with it.
files/<key>/styles will give all the styles and in particular will give you the node_id of the node associated with that style.
You then do files/<key>/nodes?ids=<node_id-1>,<node_id-2>,<node_id-n> to get the information of all the nodes associated with the styles.
From the node you should be able to get the fills, effects, etc. which are the style values you’re looking for.

Bump. Even if the answer to this is “this is not he way we intended for the API to be used” that would be helpful, but apart from this just seems like a strange oversight.

1 Like

+1

I will also be very happy when there is an API endpoint to get the styles and typography properties. E.G. with the ability to define a style format like “CSS”, “JSON”, “RESX” etc.

I our case it is the styles in a library that we need to extract.
image

The solution Nuna_Ferreira mentions requires the style to be use on a node to extract the style information and makes for unnecessary API calls and “jumping” in the JSON tree.