Skip to main content
Richard_Catlin
February 26, 2021
Question

Where can I find the REST API Schema?

Where can I find the REST API Schema?

This topic has been closed for replies.

12 replies

Gleb
Power Member
February 27, 2021

I’m not entirely sure what schema is but the documentation with interactive examples can be found here: https://www.figma.com/developers/api. I don’t think there are any other materials available about the REST API.

Richard_Catlin
February 27, 2021

Hi Gleb,

The json that is returned by the Figma REST API, can be defined and validated against a schema. A schema define all possible valid responses by the REST API. There is probably a better explanation than that. https://json-schema.org/

I noticed in your link that an example Figma REST response (see below) the schema is version 0, which may mean they have not taken the time to create one or even want to since it may be a moving target.

A schema would allow a programmer to create valid classes in the language of their choice programmatically from the json-schema. Otherwise the classes need to be hand coded by looking at your link. Using the json-schema for this is faster, and guarantees its complete.

Thanks for the response.

Regards,
Richard

$ curl -sH ‘X-Figma-Token: 29-206…’
‘https://api.figma.com/v1/files/…’
| python -m json.tool
{
“components”: {},
“document”: {
“children”: [
{
“backgroundColor”: {
“a”: 1,
“b”: 0.8980392156862745,
“g”: 0.8980392156862745,
“r”: 0.8980392156862745
},
“children”: ,
“exportSettings”: ,
“id”: “0:1”,
“name”: “Page 1”,
“type”: “CANVAS”,
“visible”: true
}
],
“id”: “0:0”,
“name”: “Document”,
“type”: “DOCUMENT”,
“visible”: true
},
“schemaVersion”: 0
}

Gleb
Power Member
February 28, 2021

That makes sense, thanks for the explanation! I don’t think there is an existing schema for it.

Cristiano_Rastelli
April 16, 2021

@Richard_Catlin in which format do you need the schema? Typescript types?

Isaiah_Taylor
November 17, 2021

Hi, I’d also love to see a machine-readable version of the documentation at https://www.figma.com/developers/api. That documentation appears to be generated from something, so it would be awesome to get access to the source 🙂

My use case is getting programmatic access to the default values. I’m trying to construct tokens from the REST API, but it appears default attributes do not get returned. For example, if you create a rectangle and add a stroke, it automatically gets strokeJoin: "MITER" and strokeAngle: 28.96. You can see those default values in the REST docs. However, if you query for that node, no attributes are returned for strokeJoin or strokeAngle.

This is fine as long as we can get access to those defaults and fill them when they aren’t returned. But ideally, the REST API would just return the defaults like the Plugin API does.

Steve_Mato
September 13, 2022

Maybe the plug-in docs can help a little too?

figma.com

But, not a schema, I know.

Yrobot
September 26, 2022

Same here, i am using typescript to build a figma plugin, and i need to get the comment list by calling the REST API, but i dont know where to get the ts type define for the comment object. I could not find the define in @figma/plugin-typings. 😅

xrv
February 2, 2023

Almost two years and I still don’t know if an OpenAPI schema exists for Figma REST API.

Gleb
Power Member
February 2, 2023

It doesn’t

Jeffrey_Dunn
September 12, 2023

Is there still no publicly available schema definition? Has anyone tried to generate one? I’m not sure if that’s a viable alternative but I’m curious.