Where can I find the REST API Schema?

Where can I find the REST API Schema?

2 Likes

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
}

2 Likes

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.

1 Like

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

But, not a schema, I know.

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. :sweat_smile:

1 Like

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

It doesn’t

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.

Precisely. It’s speaks to the programmers prowess designing (any API), but certainly RESTful ones. The design appears to makes assumptions about the user language choices (e.g., javascript - the loosey-goosey 4th generation language that accepts all, rejects nothing language).

Hi all, thank you for your patience here!

We’re excited to announce the beta release of the OpenAPI specification and Typescript types for the Figma REST API in the open source figma/rest-api-spec repository.

As you may know, OpenAPI is a specification for describing HTTP APIs in a language-agnostic manner. It has a large ecosystem of tools to let you generate API documentation, client SDKs, and more. We also provide custom Typescript types generated from the OpenAPI specification for those of you with Typescript codebases to make it easy to write type-safe code out of the box.