Endpoints
Files endpoints allow for a wide range of functionality to get information about files. With a specific file key, you can get the JSON and image representations of the whole file or individual nodes within the file.
GET file
Returns the document referred to by :key
as a JSON object. The file key can be parsed from any Figma file url: https://www.figma.com/:file_type/:file_key/:file_name
. The name
, lastModified
, thumbnailUrl
, editorType
, linkAccess
, and version
attributes are all metadata of the retrieved file. The document
attribute contains a Node of type DOCUMENT.
The components
key contains a mapping from node IDs to component metadata. This is to help you determine which components each instance comes from.
This is a Tier 1 endpoint and requires the file_content:read
scope.
HTTP endpoint
GET /v1/files/:key
Return value
{
"name": String,
"role": String,
"lastModified": String,
"editorType": String,
"thumbnailUrl": String,
"version": String,
"document": Node,
"components": Map<String, Component>,
"componentSets": Map<String, ComponentSet>,
"schemaVersion": 0,
"styles": Map<String, Style>
"mainFileKey": String,
"branches": [
{
"key": String,
"name": String,
"thumbnail_url": String,
"last_modified": String,
"link_access": String,
}
]
}
Path parameters | Description |
---|---|
key |
|
Query parameters | Description |
---|---|
version |
|
ids |
|
depth |
|
geometry |
|
plugin_data |
|
branch_data |
|
Error codes | Description |
---|---|
403 | The developer / OAuth token is invalid or expired |
404 | The specified file was not found |
Examples
To get the JSON for specific nodes, their subtrees, and all the nodes in their ancestor chains:
GET /v1/files/:key?ids=1:2,1:3
To get the JSON for the document tree stopping at the top-level nodes on each page (all pages live at depth 1):
GET /v1/files/:key?depth=2
GET file nodes
Returns the nodes referenced to by :ids
as a JSON object. The nodes are retrieved from the Figma file referenced to by :key
.
The node id and file key can be parsed from any Figma node url: https://www.figma.com/:file_type/:file_key/:file_name?node-id=:id
.
The name, lastModified, thumbnailUrl, editorType, and version attributes are all metadata of the specified file.
The linkAccess
field describes the file link share permission level. There are 5 types of permissions a shared link can have: inherit
, view
, edit
, org_view
, and org_edit
. inherit
is the default permission applied to files created in a team project, and will inherit the project's permissions. org_view
and org_edit
restrict the link to org users.
The document
attribute contains a Node of type DOCUMENT.
The components key contains a mapping from node IDs to component metadata. This is to help you determine which components each instance comes from.
By default, no vector data is returned. To return vector data, pass the geometry=paths
parameter to the endpoint.
Each node can also inherit properties from applicable styles. The styles
key contains a mapping from style IDs to style metadata.
Important: the nodes map may contain values that are null . This may be due to the node id not existing within the specified file.
This is a Tier 1 endpoint and requires the file_content:read
scope.
HTTP endpoint
GET /v1/files/:key/nodes
Return value
{
"name": String,
"role": String,
"lastModified": String,
"editorType": String,
"thumbnailUrl": String,
"err": String,
"nodes": {
"id": {
"document": Node,
"components": Map<String, Component>,
"componentSets": Map<String, ComponentSet>,
"schemaVersion": 0,
"styles": Map<String, Style>
...
}
}
}
Path parameters | Description |
---|---|
key |
|
Query parameters | Description |
---|---|
ids |
|
version |
|
depth |
|
geometry |
|
plugin_data |
|
Error codes | Description |
---|---|
400 | Invalid parameter, the err property will indicate which parameter is invalid |
403 | The developer / OAuth token is invalid or expired |
404 | The specified file was not found |
Examples
To get the JSON for specific nodes and their subtrees:
GET /v1/files/:key/nodes?ids=1:2,1:3
To get the JSON for specific nodes and their direct children without any further descendants:
GET /v1/files/:key/nodes?ids=1:2,1:3&depth=1
GET image
Renders images from a file.
If no error occurs, images
will be populated with a map from node IDs to URLs of the rendered images, and status
will be omitted. The image assets will expire after 30 days. Images up to 32 megapixels can be exported. Any images that are larger will be scaled down.
Important: the image map may contain values that are null. This indicates that rendering of that specific node has failed. This may be due to the node id not existing, or other reasons such has the node having no renderable components. For example, a node that is invisible or has 0% opacity cannot be rendered. It is guaranteed that any node that was requested for rendering will be represented in this map whether or not the render succeeded.
To render multiple images from the same file, use the ids query parameter to specify multiple node ids.
GET /v1/images/:key?ids=1:2,1:3,1:4
This is a Tier 1 endpoint and requires the file_content:read
scope.
HTTP endpoint
GET /v1/images/:key
Return value
{
"err": String,
"images": Map<String, String>,
"status": Number
}
Path parameters | Description |
---|---|
key |
|
Query parameters | Description |
---|---|
ids |
|
scale |
|
format |
|
svg_outline_text |
|
svg_include_id |
|
svg_include_node_id |
|
svg_simplify_stroke |
|
contents_only |
|
use_absolute_bounds |
|
version |
|
Error codes | Description |
---|---|
400 | Invalid parameter, the err property will indicate which parameter is invalid |
403 | The developer / OAuth token is invalid or expired |
404 | The specified file was not found |
500 | Unexpected rendering error, render could not be completed |
GET image fills
Returns download links for all images present in image fills in a document. Image fills are how Figma represents any user supplied images. When you drag an image into Figma, we create a rectangle with a single fill that represents the image, and the user is able to transform the rectangle (and properties on the fill) as they wish.
This endpoint returns a mapping from image references to the URLs at which the images may be download. Image URLs will expire after no more than 14 days. Image references are located in the output of the GET files endpoint under the imageRef
attribute in a Paint.
This is a Tier 2 endpoint and requires the file_content:read
scope.
HTTP endpoint
GET /v1/files/:key/images
Return value
{
"images": {
"$(imageRef)": String,
...
},
}
Path parameters | Description |
---|---|
key |
|
Error codes | Description |
---|---|
403 | The developer / OAuth token is invalid or expired |
404 | The specified file was not found |
GET file metadata
Returns the metadata for the file referred to by :key
. The file key can be parsed from any Figma file url: https://www.figma.com/:file_type/:file_key/:file_name
.
This is a Tier 3 endpoint and requires the file_metadata:read
scope.
HTTP endpoint
GET /v1/files/:key/meta
Return value
{
"file": {
"name": String,
"folder_name": String,
"last_touched_at": String,
"creator": User,
"last_touched_by": User,
"thumbnail_url": String,
"editorType": String,
"version": String,
"role": String,
"link_access": String,
"url": String,
}
}
Path parameters | Description |
---|---|
key |
|
Error codes | Description |
---|---|
403 | The developer / OAuth token is invalid or expired |
404 | The specified file was not found |