Trouble retrieving large files using Figma API

Hey everyone, I’m working on a project that needs to go through all the Figma files in a project to find specific nodes. I’m using the Figma API with an npm package, but I’m running into issues with big files. When I try to get a large file, I get a 400 error. The weird thing is, the error message talks about a render timeout and suggests requesting fewer or smaller images. But I’m not even trying to get images! I’m just after the JSON data for the file structure. Has anyone else run into this problem? Is there a way to get the JSON for big Figma files? I’m thinking I might have to break it down and request nodes in smaller chunks, but that sounds like a pain. I’ve only tried the GET file endpoint so far. I thought it would give me the whole file structure in JSON format. Any ideas or workarounds would be super helpful. Thanks!

I’ve encountered similar issues when working with the Figma API for large files. From my experience, the 400 error you’re getting isn’t always related to image rendering - it can happen with complex JSON structures too.

One workaround I found effective is to use the ‘nodes’ parameter in your GET request. Instead of fetching the entire file, you can request specific node IDs. This approach lets you break down the retrieval process into smaller, more manageable chunks.

To implement this, you’d first need to get a list of top-level node IDs (usually the pages in your Figma file). Then, you can make separate API calls for each page or group of nodes. It’s a bit more work upfront, but it’s been reliable for me when dealing with massive files.

Also, make sure you’re not hitting API rate limits. Sometimes, what looks like a file size issue is actually a throttling problem. Implementing proper request spacing might help if that’s the case.