Skip to contents

This function uses the /v1/files/ endpoint of Figma API to get all of the document metadata of a particular Figma file, and fit it into a R object.

Usage

get_document_info(file_key, token, .output_format = "list")

Arguments

file_key

A string with the key of the Figma File you want to get;

token

A string with your personal Figma token to authenticate in the API;

.output_format

The output format. Options are "list" and "tibble". Defaults to "list";

Value

By default, get_document_info() returns a raw R list with all of the document metadata of your Figma file. But you can change this behavior with .output_format = "tibble", which gives you a tibble::tibble object.

Details

You may not be interested in the contents of a Figma file, but in the metadata of this file instead. That is, you want to know the "name" of a particular Figma file, the last time it was modified, which version it uses, etc.

That is why get_document_info() exists. It collects just the metadata of your Figma file, and ignores all canvas and objects data.

By default, get_document_info() fits the metadata into a raw R list. But you can change this behavior with the .output_format argument. With .output_format = "tibble", get_document_info() will fit the metadata into a tibble::tibble object.

Be aware of possible HTTP errors

To get the data of your Figma file, the functions from figma package make a HTTP request to the Figma API. But this request can fail for a number of reasons, and if this does happen, get_document_info() will use report_http_error() to raise an error and report to the user, what kind of error message the Figma API returned. See vignette("http-errors") for more details.

Examples

if (FALSE) {
library(figma)
file_key <- "hch8YlkgaUIZ9raDzjPvCz"
token <- "my figma token secret ... "
# Returns a list with the metadata:
result <- figma::get_document_info(file_key, token)
# Returns a `tibble` object:
result <- figma::get_document_info(
  file_key, token,
  .output_format = "tibble"
)
}