Skip to main content
Solved

Figma api: comments

  • February 29, 2024
  • 8 replies
  • 993 views

Regi
  • Active Member
  • 20 replies

Hi, does Figma in any way allow to interact with comments through it’s api? I.e. retrieve data?

Best answer by tank666

View original
This topic has been closed for replies.

8 replies

tank666
  • 4873 replies
  • Answer
  • February 29, 2024

Regi
  • Author
  • Active Member
  • 20 replies
  • February 29, 2024

thank you @tank666


Regi
  • Author
  • Active Member
  • 20 replies
  • March 4, 2024

Continuing this question - I am able to retrieve all comments for a file using REST api, I was however wondering if there is a way to only retrieve comments for a specific page? or perhaps filter comments using page ID somehow? As there might be a lot of comments 😕


tank666
  • 4873 replies
  • March 4, 2024

Use comment.client_meta.node_id to get the node and, if required, its parent.


Regi
  • Author
  • Active Member
  • 20 replies
  • March 4, 2024

My goal is to be able to specify a page (name or ID) and extract the comments from the given page.

Considering your reply - how does one return the parent of the comment.client_meta.node_id? I could filter the comments based on that, but I seem to be stumbling on that part.

The only solution I’m currently finding is making a separate request which looks through the document->page->children and then having to manually match the output of that to comment.client_meta.node_id to see if it’s on I page I want to check for comments.

Maybe I’m missing a simple keyword or something here… Thanks again!


tank666
  • 4873 replies
  • March 4, 2024
figma.getNodeById(comment.client_meta.node_id)

Or an asynchronous function (getNodeByIdAsync).

And if the node type is not page, check its parent.

node.parent

Regi
  • Author
  • Active Member
  • 20 replies
  • March 4, 2024

and I’m guessing there’s no REST api to do the same?


tank666
  • 4873 replies
  • March 4, 2024

The REST API has endpoints such as GET file and GET file nodes. Use them to find the required IDs in the JSON response.


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