Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/figma/rest-api-spec
OpenAPI specification and types for the Figma REST API
https://github.com/figma/rest-api-spec
Last synced: about 1 month ago
JSON representation
OpenAPI specification and types for the Figma REST API
- Host: GitHub
- URL: https://github.com/figma/rest-api-spec
- Owner: figma
- License: mit
- Created: 2023-12-14T21:27:57.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-10-02T20:36:22.000Z (about 2 months ago)
- Last Synced: 2024-10-05T07:35:05.434Z (about 2 months ago)
- Homepage: https://www.figma.com/developers/api
- Size: 126 KB
- Stars: 61
- Watchers: 8
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# rest-api-spec
This repository contains the OpenAPI specification and Typescript types for the [Figma REST API](https://www.figma.com/developers/api).
[Changelog](https://www.figma.com/developers/api#changelog)
Note: this specification is currently in beta. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues) in this repository.
## Usage
The OpenAPI (v3.1.0) specification is located in the `openapi/` directory. This specification can be used with a [wide variety of tools](https://tools.openapis.org/) to generate API documentation, client SDKs, and more.
The Typescript types are generated from the OpenAPI specification and are located in `dist/`.
We use a custom code generator to convert the OpenAPI spec to TypeScript. While there are a number of existing OpenAPI-to-Typescript code generators, we adopted a custom solution that produces output that we believe is more optimal for the Figma REST API. In particular:
- All OpenAPI schemas, responses, and request parameters are exported as named types. This exposes named types inside complex node properties (e.g. `Paint`, `VariableAlias`, etc...).
- Types directly associated with API endpoints are prefixed with the OpenAPI operation ID (e.g. `getFile` -> `GetFilePathParams`, `GetFileQueryParams`, `GetFileResponse`). For API endpoints expecting a request body, the types are suffixed with `RequestBody` (e.g. `postComments` -> `PostCommentsRequestBody`).To use these types in your Typescript code, install the package:
```sh
npm install --save-dev @figma/rest-api-spec
```Then import the types that you need:
```ts
import { type GetFileResponse } from '@figma/rest-api-spec'// Many popular HTTP clients let you annotate response types
const result = await axios.get(url);
result.data // This has type GetFileResponse
```