{"id":14981572,"url":"https://github.com/didoo/figma-api","last_synced_at":"2025-05-15T04:05:29.961Z","repository":{"id":38443085,"uuid":"141642918","full_name":"didoo/figma-api","owner":"didoo","description":"Figma REST API implementation with TypeScript, Promises \u0026 ES6","archived":false,"fork":false,"pushed_at":"2025-03-07T21:43:00.000Z","size":872,"stargazers_count":226,"open_issues_count":4,"forks_count":42,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-14T05:55:40.792Z","etag":null,"topics":["figma","figma-api","figma-js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/didoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-20T00:14:09.000Z","updated_at":"2025-04-06T04:40:41.000Z","dependencies_parsed_at":"2024-06-18T13:49:34.725Z","dependency_job_id":"cad96d7f-95d9-4513-9fcd-1c13c9fb1c2d","html_url":"https://github.com/didoo/figma-api","commit_stats":{"total_commits":125,"total_committers":15,"mean_commits":8.333333333333334,"dds":0.608,"last_synced_commit":"8f659d148ee13127be1d13dfe2e6015ea09a4de3"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didoo%2Ffigma-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didoo%2Ffigma-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didoo%2Ffigma-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didoo%2Ffigma-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/didoo","download_url":"https://codeload.github.com/didoo/figma-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270643,"owners_count":22042859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["figma","figma-api","figma-js"],"created_at":"2024-09-24T14:03:52.126Z","updated_at":"2025-05-15T04:05:24.940Z","avatar_url":"https://github.com/didoo.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![NPM Version](https://badge.fury.io/js/figma-api.svg?style=flat)](https://www.npmjs.com/package/figma-api)\n\n\u003e [!IMPORTANT]\n\u003e **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.\n\n# figma-api\n\nJavaScript client-side implementation of the [Figma REST API](https://www.figma.com/developers/api#intro).\n\nThin 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)) \u0026 ES6.\n\nSupports both browser \u0026 Node.js implementations.\n\n## Install\n\n`npm i figma-api`\n\nor browser version:\n\n`https://raw.githubusercontent.com/didoo/figma-api/master/lib/figma-api.js`\n`https://raw.githubusercontent.com/didoo/figma-api/master/lib/figma-api.min.js`\n\nIf you have CORS limitation, import the `figma-api[.min].js` file in your codebase via the npm package.\n\n## Usage\n\nIn a Node.js script:\n\n```ts\nimport * as Figma from 'figma-api';\n\nexport async function main() {\n    const api = new Figma.Api({\n        personalAccessToken: 'my-token',\n    });\n\n    const file = await api.getFile({ file_key: 'my-file-key'});\n    // ... access file data ...\n}\n```\n\nIn a browser script:\n\n```js\nconst api = new Figma.Api({ personalAccessToken: 'my-personal-access-token' });\n\napi.getFile({ file_key: 'my-file-key'}).then((file) =\u003e {\n    // access file data\n});\n```\n\nIn this case, the `Figma` object is gloabl and all the API methods are associated with it.\n\n## Api\n\nWe 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.\n\n### Authentication\n\n```ts\nnew Api ({ personalAccessToken, oAuthToken })\n```\n\nCreates 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)\n\n```ts\nfunction oAuthLink(\n    client_id: string,\n    redirect_uri: string,\n    scope: 'file_read',\n    state: string,\n    response_type: 'code',\n): string;\n```\n\nReturns link for OAuth auth flow. Users should open this link, allow access and they will be redirected to `redirect_uri?code=\u003ccode\u003e`. Then they should use `oAuthToken` method to get an access token.\n\n```ts\nfunction oAuthToken(\n    client_id: string,\n    client_secret: string,\n    redirect_uri: string,\n    code: string,\n    grant_type: 'authorization_code',\n): Promise\u003c{\n    access_token: string,\n    refresh_token: string,\n    expires_in: number,\n}\u003e\n```\nReturns the access token from oauth code (see `oAuthLink` method).\n\nOther helpers:\n\n- `Api.appendHeaders(headers)` - Populate headers with auth.\n- `Api.request(url, opts)` - Make request with auth headers.\n\n### Endpoints\n\nAll 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).\n\n\u003e [!IMPORTANT]\n\u003e 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.\n\n#### Files\n\nSee: https://www.figma.com/developers/api#files-endpoints\n\n- `Api.getFile(pathParams,queryParams)`\n- `Api.getFileNodes(pathParams,queryParams)`\n- `Api.getImages(pathParams,queryParams)`\n- `Api.getImageFills(pathParams)`\n\n#### Comments\n\nSee: https://www.figma.com/developers/api#comments-endpoints\n\n- `Api.getComments(pathParams)`\n- `Api.postComment(pathParams,requestBody)`\n- `Api.deleteComment(pathParams)`\n- `Api.getCommentReactions(pathParams,queryParams)`\n- `Api.postCommentReaction(pathParams,requestBody)`\n- `Api.deleteCommentReactions(pathParams)`\n\n#### Users\n\nSee: https://www.figma.com/developers/api#users-endpoints\n\n- `Api.getUserMe()`\n\n#### Version History (File Versions)\n\nSee: https://www.figma.com/developers/api#version-history-endpoints\n\n- `Api.getFileVersions(pathParams)`\n\n#### Projects\n\nSee: https://www.figma.com/developers/api#projects-endpoints\n\n- `Api.getTeamProjects(pathParams)`\n- `Api.getProjectFiles(pathParams,queryParams)`\n\n#### Components and Styles (Library Items)\n\nSee: https://www.figma.com/developers/api#library-items-endpoints\n\n- `Api.getTeamComponents(pathParams,queryParams)`\n- `Api.getFileComponents(pathParams)`\n- `Api.getComponent(pathParams)`\n- `Api.getTeamComponentSets(pathParams,queryParams)`\n- `Api.getFileComponentSets(pathParams)`\n- `Api.getComponentSet(pathParams)`\n- `Api.getTeamStyles(pathParams,queryParams)`\n- `Api.getFileStyles(pathParams)`\n- `Api.getStyle(pathParams)`\n\n#### Webhooks\n\nSee: https://www.figma.com/developers/api#webhooks_v2\n\n- `Api.getWebhook(pathParams)`\n- `Api.postWebhook(requestBody)`\n- `Api.putWebhook(pathParams,requestBody)`\n- `Api.deleteWebhook(pathParams)`\n- `Api.getTeamWebhooks(pathParams)`\n- `Api.getWebhookRequests(pathParams)`\n\n#### Activity Logs\n\nSee: https://www.figma.com/developers/api#activity-logs-endpoints\n\n\u003e [!TIP]\n\u003e [TODO] Open to contributions if someone is needs to use these endpoints\n\n\n#### Payments\n\nSee: https://www.figma.com/developers/api#payments-endpoints\n\n\u003e [!TIP]\n\u003e [TODO] Open to contributions if someone is needs to use these endpoints\n\n#### Variables\n\n\u003e [!NOTE]\n\u003e These APIs are available only to full members of Enterprise orgs.\n\nSee: https://www.figma.com/developers/api#variables-endpoints\n\n- `Api.getLocalVariables(pathParams)`\n- `Api.getPublishedVariables(pathParams)`\n- `Api.postVariables(pathParams,requestBody)`\n\n#### Dev Resources\n\nSee: https://www.figma.com/developers/api#dev-resources-endpoints\n\n- `Api.getDevResources(pathParams,queryParams)`\n- `Api.postDevResources(requestBody)`\n- `Api.putDevResources(requestBody)`\n- `Api.deleteDevResources(pathParams)`\n\n#### Analytics\n\nSee: https://www.figma.com/developers/api#library-analytics-endpoints\n\n- `Api.getLibraryAnalyticsComponentActions(pathParams,queryParams)`\n- `Api.getLibraryAnalyticsComponentUsages(pathParams,queryParams)`\n- `Api.getLibraryAnalyticsStyleActions(pathParams,queryParams)`\n- `Api.getLibraryAnalyticsStyleUsages(pathParams,queryParams)`\n- `Api.getLibraryAnalyticsVariableActions(pathParams,queryParams)`\n- `Api.getLibraryAnalyticsVariableUsages(pathParams,queryParams)`\n\n## Types\n\nThe 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.\n\nAlternatively, you can refer to the official Figma REST API documentation (see links above).\n\n## Development\n\n```\ngit clone https://github.com/didoo/figma-api.git\ncd figma-api\ngit checkout main\nnpm i\nnpm run build\n```\n\n## Release\n\n```\nnpm version [\u003cnewversion\u003e | major | minor | patch]\n#if not yet logged in\nnpm login\nnpm publish\n```\n\n(notice: tags are created automatically after a few minutes from the publishing)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidoo%2Ffigma-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidoo%2Ffigma-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidoo%2Ffigma-api/lists"}