npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dsai-io/figma-tokens

v1.2.0

Published

Figma integration utilities and token synchronization for DSAi

Readme

@dsai-io/figma-tokens

Figma integration, token synchronization, and API client for the DSAi Design System

npm version

Beta -- DSAi is currently in active development and not yet generally available. APIs and interfaces may change between releases. For early access or collaboration inquiries, see the DSAi repository.

Installation

pnpm add -D @dsai-io/figma-tokens
# or
npm install -D @dsai-io/figma-tokens

Requires @dsai-io/tools as a dependency (installed automatically).

What This Package Does

  • Figma REST API client with 21 methods covering variables, published components/styles, library analytics, version history, and file metadata
  • Write support -- create, update, and delete variables via POST /v1/files/:key/variables
  • Library analytics -- query component, style, and variable usage/action data with cursor-based pagination
  • Fetches design token variables from the Figma REST API
  • Validates Figma token exports against the DTCG spec
  • Transforms Figma variable exports into Style Dictionary-compatible collections
  • Syncs tokens between Figma files and your local design system
  • Built-in rate limiter, circuit breaker, and retry logic

CLI

# Fetch variables from Figma
dsai-figma fetch --file YOUR_FILE_KEY

# Sync tokens between Figma and local collections
dsai-figma sync

# Validate exported tokens
dsai-figma validate

# Show all capabilities (for humans and AI agents)
dsai-figma info
dsai-figma info --json    # Structured JSON for agent consumption

Environment Variables

| Variable | Required | Description | |----------|----------|-------------| | FIGMA_TOKEN | Yes | Figma personal access token | | FIGMA_FILE_KEY | No | Default Figma file key (can also pass via --file) |

Configuration

Configure via dsai.config.mjs or set environment variables:

import { defineConfig } from '@dsai-io/tools';

export default defineConfig({
  tokens: {
    source: 'theme',
    sourceDir: './src/figma-exports',
    collectionsDir: './src',
    outputDir: './src/generated',
  },
});

Programmatic API

Validate Figma Exports

import { validateFigmaExports } from '@dsai-io/figma-tokens';

const result = await validateFigmaExports({
  exportsDir: './figma-exports',
  strict: true,
});

if (!result.valid) {
  console.error('Validation failed:', result.errors);
}

Transform Tokens

import { transformTokens } from '@dsai-io/figma-tokens';

await transformTokens({
  sourceDir: './figma-exports',
  outputDir: './tokens/collections',
});

Figma API Client

import { createFigmaClient } from '@dsai-io/figma-tokens';

const client = createFigmaClient({ accessToken: process.env.FIGMA_TOKEN });

// Variables
const variables = await client.getVariables(fileKey);
const published = await client.getPublishedVariables(fileKey);

// Write variables (create/update/delete -- atomic)
await client.postVariables(fileKey, {
  variables: [{ action: 'CREATE', id: 'temp-1', name: 'spacing/sm', variableCollectionId: 'coll-id', resolvedType: 'FLOAT' }],
  variableModeValues: [{ variableId: 'temp-1', modeId: 'mode-id', value: 8 }],
});

// Published library
const components = await client.getPublishedComponents(fileKey);
const styles = await client.getPublishedStyles(fileKey);

// Analytics (cursor-paginated)
const actions = await client.getComponentActions(fileKey, 'component', {
  startDate: '2025-01-01',
  endDate: '2025-12-31',
});

// File info
const versions = await client.getVersionHistory(fileKey);
const metadata = await client.getFileMetadata(fileKey);
const me = await client.getMe();

Figma REST API Coverage

| Category | Endpoints | |----------|-----------| | Files | GET file, GET nodes, GET metadata, GET versions | | Variables | GET local, GET published, POST create/update/delete | | Library | GET components, GET component_sets, GET styles, GET by key | | Analytics | GET component/style/variable actions/usages (6 endpoints) | | User | GET me |

Run dsai-figma info --json for the full machine-readable inventory.

Typical Workflow

# 1. Set your Figma token
export FIGMA_TOKEN=your_token_here

# 2. Fetch tokens from Figma
dsai-figma fetch --file YOUR_FILE_KEY

# 3. Transform to DTCG collections
dsai tokens transform

# 4. Build CSS, SCSS, JS, TS outputs
dsai tokens build

Dependencies

Resources

License

MIT