Skip to main content
Solved

Is it possible to get an image for a specific node id with the rest api?

  • January 23, 2025
  • 3 replies
  • 121 views

Jesse Andrews

I’m able to get an image with the image rest api (GET https://api.figma.com/v1/images/:key?ids=:node_id), but it doesn’t crop the result to the provided node id. Instead, it renders everything below the top layer the node is nested under.

This is what I receive from the api.

This is what I want from the api roughly.

 

Is it possible to get the desired result from this api, or do I need to explore alternatives? The node ids I’m using are derived from the url after clicking on the node in the figma viewer (www.figma.com/design/{file_id}/{file_name}?node-id={node_id}).

Best answer by tank666

You need to use the correct node ID. As far as I understand, you got the ID of the top-level frame (the node that is directly on the canvas), so the output is a link to the full frame image. Note that the URL does not change when selecting nested (child) layers, it displays the ID of exactly the top-level node. So get the ID you need using other REST API endpoints or Plugin API.

View original

3 replies

tank666
  • 4859 replies
  • Answer
  • January 23, 2025

You need to use the correct node ID. As far as I understand, you got the ID of the top-level frame (the node that is directly on the canvas), so the output is a link to the full frame image. Note that the URL does not change when selecting nested (child) layers, it displays the ID of exactly the top-level node. So get the ID you need using other REST API endpoints or Plugin API.


Jesse Andrews
  • Author
  • New Member
  • 1 reply
  • January 23, 2025

Ah. That was the issue. I was clicking layers and saw it changing, but didn’t look closely enough to notice that the id wasn’t changing when switching between sub layers. Confirmed that the image is returned as expected after using the correct id provided by the api.


RKE2
  • New Member
  • 1 reply
  • January 27, 2025

Yes, it is possible! You can use the REST API to query specific node details, including images, by including the node ID in the request. Just make sure you're using the correct endpoint and parameters to fetch the image data.


Reply


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