From figma-pack
Fetches Figma file via REST API with curl or Node.js/TypeScript and inspects node tree. Tests connectivity, explores structure for new integrations or learning.
npx claudepluginhub jeremylongshore/claude-code-plugins-plus-skills --plugin figma-packThis skill is limited to using the following tools:
Make your first Figma REST API call. Fetch a file's metadata and document tree, then inspect the node structure that represents every layer and object in a Figma design.
Provides typed TypeScript clients and patterns for Figma REST/Plugin APIs with error handling, for client wrappers, design tokens, node traversal.
Mandatory prerequisite skill for `use_figma` tool calls to execute JS in Figma files. Enables node create/edit/delete, variables/tokens setup, component building, auto-layout changes, property binding, and programmatic file inspection.
Extracts design data from Figma files via API and CLI. Gets design tokens, colors, typography, component specs, images, and exports for code generation.
Share bugs, ideas, or general feedback.
Make your first Figma REST API call. Fetch a file's metadata and document tree, then inspect the node structure that represents every layer and object in a Figma design.
figma-install-auth setupfigma.com/design/<FILE_KEY>/...)FIGMA_PAT environment variable set# Get the full document JSON for a file
curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \
"https://api.figma.com/v1/files/${FIGMA_FILE_KEY}" | jq '{
name: .name,
lastModified: .lastModified,
version: .version,
pages: [.document.children[] | .name]
}'
Expected output:
{
"name": "My Design File",
"lastModified": "2025-03-15T10:30:00Z",
"version": "1234567890",
"pages": ["Page 1", "Components", "Tokens"]
}
Every Figma file is a tree of typed nodes:
DOCUMENT (root)
├── CANVAS (page)
│ ├── FRAME (container / auto-layout)
│ │ ├── TEXT
│ │ ├── RECTANGLE
│ │ └── INSTANCE (component instance)
│ ├── GROUP
│ │ └── VECTOR
│ ├── COMPONENT (reusable master)
│ └── SECTION
Key node types: DOCUMENT, CANVAS, FRAME, GROUP, RECTANGLE, ELLIPSE, TEXT, VECTOR, COMPONENT, COMPONENT_SET, INSTANCE, LINE, SECTION, BOOLEAN_OPERATION.
// hello-figma.ts
const PAT = process.env.FIGMA_PAT!;
const FILE_KEY = process.env.FIGMA_FILE_KEY!;
interface FigmaNode {
id: string;
name: string;
type: string;
children?: FigmaNode[];
}
interface FigmaFileResponse {
name: string;
lastModified: string;
version: string;
document: FigmaNode;
components: Record<string, { key: string; name: string; description: string }>;
styles: Record<string, { key: string; name: string; style_type: string }>;
}
async function main() {
const res = await fetch(
`https://api.figma.com/v1/files/${FILE_KEY}`,
{ headers: { 'X-Figma-Token': PAT } }
);
if (!res.ok) {
throw new Error(`Figma API error: ${res.status} ${res.statusText}`);
}
const file: FigmaFileResponse = await res.json();
console.log(`File: ${file.name}`);
console.log(`Last modified: ${file.lastModified}`);
console.log(`Components: ${Object.keys(file.components).length}`);
console.log(`Styles: ${Object.keys(file.styles).length}`);
// Walk the first page and list top-level frames
const firstPage = file.document.children?.[0];
if (firstPage) {
console.log(`\nPage: ${firstPage.name}`);
for (const child of firstPage.children ?? []) {
console.log(` ${child.type}: ${child.name} (${child.id})`);
}
}
}
main().catch(console.error);
// Fetch only specific nodes by ID (faster for large files)
async function fetchNodes(fileKey: string, nodeIds: string[]) {
const ids = nodeIds.join(',');
const res = await fetch(
`https://api.figma.com/v1/files/${fileKey}/nodes?ids=${ids}`,
{ headers: { 'X-Figma-Token': PAT } }
);
const data = await res.json();
// data.nodes is a map: { "nodeId": { document: {...}, components: {...} } }
return data.nodes;
}
// Node IDs use the format "pageId:frameId" (e.g., "0:1", "123:456")
const nodes = await fetchNodes(FILE_KEY, ['0:1', '2:3']);
| Error | Status | Cause | Solution |
|---|---|---|---|
Not found | 404 | Invalid file key | Verify the key from the Figma URL |
Forbidden | 403 | No access to file | Check token scopes and file permissions |
Rate limited | 429 | Too many requests | Honor Retry-After header |
Empty document | 200 | File has no pages | Check if file was recently created |
# Count total nodes in a file
curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \
"https://api.figma.com/v1/files/${FIGMA_FILE_KEY}" \
| jq '[.. | .id? // empty] | length'
curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \
"https://api.figma.com/v1/files/${FIGMA_FILE_KEY}" \
| jq -r '.thumbnailUrl'
Proceed to figma-local-dev-loop for setting up a development workflow.