Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Helpers to simplify requests against the Figma API

Notifications You must be signed in to change notification settings

lyne-design-system/lyne-helper-figma-api

Repository files navigation

Build Status semantic-release GitHub tag (latest SemVer)

Lyne Helper Figma API

Helper methods to simplify requests to the Figma API.

Usage

Installation

Install the Figma API Helper with the following command:

npm install --save-dev lyne-helper-figma-api

Require

const figma = require('lyne-helper-figma-api');

Fetch document

figma.document('https://api.figma.com/v1/files/YOUR_FILE_ID', 'YOUR_FIGMA TOKEN')
  .then((document) => {
    console.log(document);
  })
  .catch((error) => {
    console.log(error);
  });

Get pages of a document

figma.pages() accepts 2 arguments:

figmaDocument: the data returned from figma.document()

ignorePattern: pages that include the ignorePattern in their name will be ignored and not returned.

const pages = figma.pages(figmaDocument, ignorePattern);

Get frames of a page

figma.frames() accepts 2 arguments:

page: one of the pages returned from figma.pages()

ignorePattern: frames that include the ignorePattern in their name will be ignored and not returned.

const page = pages[0];
const frames = figma.frames(page, ignorePattern);

Development

Conventional Commits

Please follow the Conventional Commits specification to make sure we can automatically determine the next release version if necessary.

Deployment

The package is automatically build and published to npm via Travis CI as soon as pushed to master.