Figma Support Forum

Where can I find the REST API Schema?

Where can I find the REST API Schema?

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.

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
}

1 Like

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

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

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 :slight_smile:

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.