How to export element as PNG or JPEG using figma rest apis?

2.1k views Asked by At

I am able to export a Textbox rectangle as PNG or JPEG from figma screens Web App. However, couldn't find any way to export particular element as PNG/JPEG using figma APIs.

Figma API documentation doesn't help https://www.figma.com/developers/api#get-image-fills-endpoint

Here is my the image enter image description here

1

There are 1 answers

0
Abhishek Kulkarni On

Found the solution.

Any element can be exported as png or svg or pdf using API given below

https://api.figma.com/v1/images/<FILE_KEY>?ids=<ELEMENT_NODE_ID>&format=png

This api returns json response which contains the URL to download the image from figma s3 bucket

{ "err": null,
  "images": {
       "2265:3848": "https://s3-us-west-2.amazon.com/figma-alpha-api/img/xxxxx/yyyyy/randomMD5hashOfImageToBeDownloaded"
  }
}