Skip to content

gerard-figma/figma-library-analytics-api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Figma Library Analytics API Examples

A simple Python script demonstrating the Figma Library Analytics API to extract data to a CSV. In a more mature data pipeline, this could instead be inserted directly into a Data Warehouse such as Snowflake or BigQuery.

Prerequisites

To use the Figma Library Analytics API workflow, you must be a full member of an Enterprise org in Figma.

You'll also need to install the following Python packages using pip:
pip3 install requests
pip3 install python-dotenv
pip3 install pandas

Usage

Define two environment variables in your .env file(see Python dotenv if you're new to this)

  • FIGMA_ACCESS_TOKEN: This is your unique Figma Personal Access Token. It can be generated from Settings-Account-Personal access tokens. You will need to generate a new token to inherit the new Library Analytics permissions.
  • FILE_KEY: The file key you wish to connect to. This is found in the Figma URL after file/

Addtionally, define the start and end dates in the script. Figma stores 365 days worth of data.

Then run python3 extract-library-data.py on the command line.

By default this will create three directories in output/ for the given date range, for components, variables and styles, and save four CSV files into each:

Components

-actions by componant
-actions by team -usages by component -usages by file

Variables

-actions by variable
-actions by team -usages by variable -usages by file

Styles

-actions by style
-actions by team -usages by style -usages by file

About

A simple Python demonstration of the Figma Libraries API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages