Helper methods to simplify requests to the Figma API.
Install the Figma API Helper with the following command:
npm install --save-dev lyne-helper-figma-api
const figma = require('lyne-helper-figma-api');
figma.document('https://api.figma.com/v1/files/YOUR_FILE_ID', 'YOUR_FIGMA TOKEN')
.then((document) => {
console.log(document);
})
.catch((error) => {
console.log(error);
});
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);
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);
Please follow the Conventional Commits specification to make sure we can automatically determine the next release version if necessary.
The package is automatically build and published to npm via Travis CI as soon as pushed to master.