# figma-api

> Thin typed wrapper around the Figma REST API

Latest version **2.2.1-beta** (published 2026-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install figma-api
pnpm add figma-api
yarn add figma-api
bun add figma-api
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.1-beta |
| Published | 2026-06-29 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 767.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 267 |
| Author | didoo |
| Maintainers | morglod, didoo |
| Keywords | figma, rest, api, typed |

## Links

- npm: https://www.npmjs.com/package/figma-api
- Repository: https://github.com/didoo/figma-api
- Homepage: https://github.com/didoo/figma-api#readme
- Issues: https://github.com/didoo/figma-api/issues
- npm.io page: https://npm.io/package/figma-api

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.18.1
- [@figma/rest-api-spec](https://npm.io/package/@figma/rest-api-spec.md) >=0.37.0 <1.0.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.2.1-beta (latest) — 2026-06-29
- 2.2.0-beta — 2026-04-22
- 2.1.4-beta — 2026-04-22
- 2.1.3-beta — 2026-04-22
- 2.1.2-beta — 2026-02-16
- 2.1.1-beta — 2026-02-13
- 2.1.0-beta — 2025-10-08
- 2.0.2-beta — 2025-04-16
- 2.0.1-beta — 2024-11-06
- 2.0.0-beta — 2024-11-05
- 1.12.0 — 2024-11-05
- 1.11.0 — 2022-10-29
- 1.10.1 — 2022-04-04
- 1.10.0 — 2022-04-04
- 1.9.2 — 2022-01-14
- … 31 more at https://npm.io/package/figma-api/versions

## README

[![NPM Version](https://badge.fury.io/js/figma-api.svg?style=flat)](https://www.npmjs.com/package/figma-api)

> [!IMPORTANT]
> **Version 2.0 Beta** - This version is a complete rewrite of the library, based on the [Figma REST API specifications](https://github.com/figma/rest-api-spec). Many endpoint methods have been renamed from version 1.x, and all the endpoint methods' arguments now match the [Figma REST API](https://www.figma.com/developers/api) documentation. If you were using the previous version, and intend to use the new one, **you will have to update your code accordingly**. The good news is that from now on they should always remain in sync, so no major disruptions in the future, with the benefit of a full alignment with the official Figma REST API documentation and specifications.

# figma-api

JavaScript client-side implementation of the [Figma REST API](https://www.figma.com/developers/api#intro).

Thin layer on top of the official [Figma REST API specifications](https://github.com/figma/rest-api-spec), fully typed with TypeScript, uses Promises (via [Axios](https://github.com/axios/axios)) & ES6.

Supports both browser & Node.js implementations.

## Install

`npm i figma-api`

or browser version:

`https://raw.githubusercontent.com/didoo/figma-api/master/lib/figma-api.js`
`https://raw.githubusercontent.com/didoo/figma-api/master/lib/figma-api.min.js`

If you have CORS limitation, import the `figma-api[.min].js` file in your codebase via the npm package.

## Usage

In a Node.js script:

```ts
import * as Figma from 'figma-api';

export async function main() {
    const api = new Figma.Api({
        personalAccessToken: 'my-token',
    });

    const file = await api.getFile({ file_key: 'my-file-key'});
    // ... access file data ...
}
```

In a browser script:

```js
const api = new Figma.Api({ personalAccessToken: 'my-personal-access-token' });

api.getFile({ file_key: 'my-file-key'}).then((file) => {
    // access file data
});
```

In this case, the `Figma` object is gloabl and all the API methods are associated with it.

## Api

We have followed the same organisation as the official [Figma API documentation](https://www.figma.com/developers/api) to describe our API methods, so it's easier to find the exact endpoint call you are looking for.

### Authentication

```ts
new Api ({ personalAccessToken, oAuthToken })
```

Creates new Api object with specified `personalAccessToken` or `oAuthToken`. For details about how to get these tokens, [see the documentation](https://www.figma.com/developers/api#authentication)

```ts
function oAuthLink(
    client_id: string,
    redirect_uri: string,
    scope: string | string[],
    state: string,
    response_type: 'code',
): string;
```

Returns link for OAuth auth flow. `scope` can be a single scope string (for example `file_content:read`) or an array of scope strings for multiple permissions. Users should open this link, allow access and they will be redirected to `redirect_uri?code=<code>`. Then they should use `oAuthToken` method to get an access token.

```ts
function oAuthToken(
    client_id: string,
    client_secret: string,
    redirect_uri: string,
    code: string,
    grant_type: 'authorization_code',
): Promise<{
    access_token: string,
    refresh_token: string,
    expires_in: number,
}>
```
Returns the access token from oauth code (see `oAuthLink` method).

Other helpers:

- `Api.appendHeaders(headers)` - Populate headers with auth.
- `Api.request(url, opts)` - Make request with auth headers.

### Endpoints

All these endpoints methods receive objects like `pathParams`, `queryParams`, `requestBody`, as arguments, and return a Promise. For details about the shape of these objects refer to the official Figma REST API documentation (see links below).

> [!IMPORTANT]
> Version 2.x differs considerably from version 1.x in that the arguments of the API endpoint methods are _always_ contained in these objects, while before they were passed singularly as values directly to the function.

#### Files

See: https://www.figma.com/developers/api#files-endpoints

- `Api.getFile(pathParams,queryParams)`
- `Api.getFileNodes(pathParams,queryParams)`
- `Api.getImages(pathParams,queryParams)`
- `Api.getImageFills(pathParams)`

#### Comments

See: https://www.figma.com/developers/api#comments-endpoints

- `Api.getComments(pathParams)`
- `Api.postComment(pathParams,requestBody)`
- `Api.deleteComment(pathParams)`
- `Api.getCommentReactions(pathParams,queryParams)`
- `Api.postCommentReaction(pathParams,requestBody)`
- `Api.deleteCommentReactions(pathParams)`

#### Users

See: https://www.figma.com/developers/api#users-endpoints

- `Api.getUserMe()`

#### Version History (File Versions)

See: https://www.figma.com/developers/api#version-history-endpoints

- `Api.getFileVersions(pathParams)`

#### Projects

See: https://www.figma.com/developers/api#projects-endpoints

- `Api.getTeamProjects(pathParams)`
- `Api.getProjectFiles(pathParams,queryParams)`

#### Components and Styles (Library Items)

See: https://www.figma.com/developers/api#library-items-endpoints

- `Api.getTeamComponents(pathParams,queryParams)`
- `Api.getFileComponents(pathParams)`
- `Api.getComponent(pathParams)`
- `Api.getTeamComponentSets(pathParams,queryParams)`
- `Api.getFileComponentSets(pathParams)`
- `Api.getComponentSet(pathParams)`
- `Api.getTeamStyles(pathParams,queryParams)`
- `Api.getFileStyles(pathParams)`
- `Api.getStyle(pathParams)`

#### Webhooks

See: https://www.figma.com/developers/api#webhooks_v2

- `Api.getWebhook(pathParams)`
- `Api.postWebhook(requestBody)`
- `Api.putWebhook(pathParams,requestBody)`
- `Api.deleteWebhook(pathParams)`
- `Api.getTeamWebhooks(pathParams)`
- `Api.getWebhookRequests(pathParams)`

#### Activity Logs

See: https://www.figma.com/developers/api#activity-logs-endpoints

> [!TIP]
> [TODO] Open to contributions if someone is needs to use these endpoints


#### Payments

See: https://www.figma.com/developers/api#payments-endpoints

> [!TIP]
> [TODO] Open to contributions if someone is needs to use these endpoints

#### Variables

> [!NOTE]
> These APIs are available only to full members of Enterprise orgs.

See: https://www.figma.com/developers/api#variables-endpoints

- `Api.getLocalVariables(pathParams)`
- `Api.getPublishedVariables(pathParams)`
- `Api.postVariables(pathParams,requestBody)`

#### Dev Resources

See: https://www.figma.com/developers/api#dev-resources-endpoints

- `Api.getDevResources(pathParams,queryParams)`
- `Api.postDevResources(requestBody)`
- `Api.putDevResources(requestBody)`
- `Api.deleteDevResources(pathParams)`

#### Analytics

See: https://www.figma.com/developers/api#library-analytics-endpoints

- `Api.getLibraryAnalyticsComponentActions(pathParams,queryParams)`
- `Api.getLibraryAnalyticsComponentUsages(pathParams,queryParams)`
- `Api.getLibraryAnalyticsStyleActions(pathParams,queryParams)`
- `Api.getLibraryAnalyticsStyleUsages(pathParams,queryParams)`
- `Api.getLibraryAnalyticsVariableActions(pathParams,queryParams)`
- `Api.getLibraryAnalyticsVariableUsages(pathParams,queryParams)`

## Types

The library is fully typed using the official [Figma REST API specifications](https://github.com/figma/rest-api-spec). You can see those types in the generated file here: https://github.com/figma/rest-api-spec/blob/main/dist/api_types.ts.

Alternatively, you can refer to the official Figma REST API documentation (see links above).

---

## Development

```
git clone https://github.com/didoo/figma-api.git
cd figma-api
git checkout main
npm install
npm run build
```

## Testing

```
npm run test
```

## Release

```
npm version [<newversion> | major | minor | patch]
#if not yet logged in
npm login
npm publish
```

(notice: tags are created automatically after a few minutes from the publishing)

---
_Source: https://npm.io/package/figma-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
