The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The aim of figma
package is to provide an easy-to-use
client/wrapper for the Figma API. It allows you
to bring all data from a Figma file to your R session. This includes the
data of all objects that you have drawn in this file, and their
respective canvas/page metadata.
With this kind of data, you can maybe build a custom and automated layout for documents, or create an automated pipeline to build design content for your clients.
Key features of the package:
Get all data of a Figma file, or a specific canvas/page in the Figma file, or just the metadata about the file;
Functions from figma
package can output the data
into a tibble::tibble()
object;
Returns the raw contents of the HTTP response by default, to give more freedom and information to the user;
To get the current version from CRAN:
install.packages("figma")
To get the current development version from github:
::install_github("pedropark99/figma") devtools
A good place to start in the figma
package, is to read
the main vignette (which you can access with
vignette("figma")
). But let’s give you a brief summary of
its features, shall we?
In order to use the Figma API, you need to collect two key variables in the Figma platform, which are:
The file key is collected through the URL that appears when you
access this file in your web browser ( See
vignette("figma")
for more details), and you can create a
personal access token in the “Settings” section of the Figma platform
(See vignette("figma")
for more details).
After you collected these two variables, you can use
figma::get_figma_file()
to collect all data of your Figma
file, like this:
<- "hch8YlkIrYbU3raDzjPvCz"
file_key <- "My secret and personal access token ..."
token
# Returns a `response` object:
<- figma::get_figma_file(
result
file_key, token )
By default, figma::get_figma_file()
returns the raw
contents of the HTTP response. However, you can ask the function to fit
the data of your Figma file in a tibble object, if you prefer. Just pass
the .output_format = "tibble"
argument to the function,
like this:
# Returns a `tibble` object:
<- figma::get_figma_file(
result
file_key, token,.output_format = "tibble"
)
print(result)
# A tibble: 5 × 7
canvas_id canvas_name canvas_type object_id object_name object_type object_attributes
<chr> <chr> <chr> <chr> <chr> <chr> <list>
1 0:1 Page 1 CANVAS 1:2 Background RECTANGLE <named list [9]>
2 0:1 Page 1 CANVAS 5:2 Paragraph TEXT <named list [16]>
3 0:1 Page 1 CANVAS 5:3 Arrow VECTOR <named list [9]>
4 5:4 Page 2 CANVAS 5:5 BackgroundPagina2 RECTANGLE <named list [9]>
5 5:4 Page 2 CANVAS 5:6 Texto da página 2 TEXT <named list [16]>
Instead of getting the data from the entire Figma file, you might
need to collect the data from a specific page (or a specific set of
pages) of this file. If that’s your case, you can use the
figma::get_figma_page()
function.
But in order to use the function, you need to collect a third
variable, which is the node ID, or, in other words, the ID that
identifies the page that you are interested in (See
vignette("figma"
for more details on how to collect this
node ID). After you collected this node ID, you could get this data like
this:
<- "0%3A1"
node_id # Returns a `tibble` object:
<- figma::get_figma_page(
result
file_key, token, node_id,.output_format = "tibble"
)
print(result)
# A tibble: 3 × 7
canvas_id canvas_name canvas_type object_id object_name object_type object_attributes
<chr> <chr> <chr> <chr> <chr> <chr> <list>
1 0:1 Page 1 CANVAS 1:2 Background RECTANGLE <named list [9]>
2 0:1 Page 1 CANVAS 5:2 Paragraph TEXT <named list [16]>
3 0:1 Page 1 CANVAS 5:3 Arrow VECTOR <named list [9]>
On the other hand, for some reason, you might be not interested in
the contents of your Figma file, just the metadata of it. For this case,
you can use figma::get_document_info()
to get this kind of
information, like this:
<- figma::get_document_info(
result
file_key, token
)
print(str(result))
List of 13
$ id : chr "0:0"
$ type : chr "DOCUMENT"
$ name : chr "Untitled"
$ components : Named list()
$ componentSets: Named list()
$ styles : Named list()
$ schemaVersion: int 0
$ lastModified : chr "2022-10-29T23:35:08Z"
$ thumbnailUrl : chr "https://s3-alpha-sig.figma.com/thumbnails/446f0181-cfeb-49e7-aec2-36c71aa4b05e?Expires=1667779200&Signature=Mnj"| __truncated__
$ version : chr "2539463517"
$ role : chr "owner"
$ editorType : chr "figma"
$ linkAccess : chr "view"
See vignette("figma")
for more details and a more
complete introduction to the package.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.