Skip to main content
Regi
Active Member
February 29, 2024
Solved

Figma api: comments

  • February 29, 2024
  • 8 replies
  • 1753 views

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

This topic has been closed for replies.
Best answer by tank666

8 replies

tank666
tank666Solution
February 29, 2024
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Regi
RegiAuthor
Active Member
February 29, 2024

thank you @tank666

Regi
RegiAuthor
Active Member
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
March 4, 2024

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

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Regi
RegiAuthor
Active Member
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
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
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Regi
RegiAuthor
Active Member
March 4, 2024

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

tank666
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.

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank