Search by

turkeryildirim / figma-api

turkeryildirim

PHP library for Figma API

Package info

github.com/turkeryildirim/php-figma-api

pkg:composer/turkeryildirim/figma-api

Statistics

Installs: 53

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v3.0.0 2026-11-30 14:14 UTC

This package is auto-updated.

Last update: 2026-11-30 14:21:56 UTC


README

A PHP library for Figma's REST API covering files, teams, folders, components, styles, users, version history, comments, reactions, webhooks, variables, dev resources, library analytics, activity logs, developer logs, AI usage, payments, and oEmbed endpoints.

Description

This library provides typed PHP endpoints, response models, and DTOs (>= 8.1) for the Figma REST API.

Due to inconsistencies in property naming across various Figma API endpoints (e.g., style_type and styleType), property names used across response objects and DTOs in this library are standardized to camelCase.

Supported API endpoints

  • Files (including node rendering, image fills, metadata, and file duplication)
  • Teams (create, fetch, and invite members)
  • Folders v1/v2 (replaces deprecated Projects endpoints)
  • Version History
  • Comments & Reactions
  • Users (me)
  • Components & Component Sets
  • Styles
  • Webhooks v2
  • Activity Logs
  • Developer Logs
  • AI Usage
  • Payments
  • Variables (local, published, and bulk mutations)
  • Dev Resources
  • Library Analytics
  • oEmbed
  • Projects (deprecated — kept for ProjectsEndpoint compatibility; use FoldersEndpoint instead)

Installation

You can install this library using Composer (requires PHP >=8.1 and ext-curl >=7.60.0):

composer require turkeryildirim/figma-api

Then include Composer's autoloader in your application:

require 'vendor/autoload.php';

Documentation

You can read full details about Figma API endpoints and properties in the official Figma REST API documentation.

All fields are populated with response data received from the API endpoint and normalized to consistent types:

  • Boolean strings (such as "false") are converted to native booleans.
  • Empty response strings ("") and empty collections are normalized to null.
  • Missing fields defined on a response or DTO are marked as null.

By default, GET responses are cached in memory (ArrayCache) for 5 minutes (300 seconds) and invalidated on POST, PUT, and DELETE calls to the same endpoint. You can pass any PSR-16 CacheInterface driver (see samples/CustomCacheSample.php).

Actions and errors are logged using Monolog (ErrorLogHandler) by default. You can pass any PSR-3 LoggerInterface driver (see samples/CustomLoggerSample.php).

Breaking Changes (Upgrading from 1.x to 2.x)

If you are upgrading an existing integration from 1.x, review the following behavioral and type changes:

  • FileKeyTrait::$filekey renamed to $fileKey: Affects CommentType, ComponentType, ComponentSetType, and StyleType (snake_case file_key and legacy filekey keys in input payloads are still accepted).
  • TypeStyleType::$hyperlink type changed: Changed from ?string to ?HyperlinkType (Turker\FigmaAPI\Types\File\HyperlinkType with type, url, and nodeID) to match the Figma REST API object schema.
  • CanvasNodeType::$flowStartingPoints type changed: Changed from ?FlowStartingPointsType to FlowStartingPointsType[]|null (?array) to match the Figma REST API array schema.
  • PaintType::$filters type changed: Changed from ImageFiltersType[]|null (?array) to ?ImageFiltersType to match the Figma REST API object schema.
  • Map keys preserved (preserveKeys: true): FileNodesResponse::$nodes, StylesTrait::$styles, ComponentNodeType::$componentPropertyDefinitions, and InstanceNodeType::$componentProperties now preserve the Figma node ID, style ID, or property name keys instead of re-indexing to 0, 1, 2....
  • CommentsEndpoint::fetchComments() query parameter fixed: Now sends as_md instead of ad_md.
  • Boolean query parameter serialization: BaseEndpoint::filterParams() now serializes boolean query parameters (e.g., branch_data, use_absolute_bounds, as_md) as 'true' / 'false' strings instead of '1' / '0'.
  • ProjectsEndpoint deprecated: ProjectsEndpoint (teams/{teamId}/projects, projects/{projectId}/files) is marked @deprecated in favor of FoldersEndpoint (/v2/teams/{teamId}/folders, /v2/folders/{folderId}/files).
  • HttpClient TLS verification enabled by default: Guzzle 'verify' defaults to true (use $httpClient->setVerifySsl(false) only if local development requires disabling TLS checks).
  • HttpClient exception codes preserved: FigmaAPIException::getCode() now retains the HTTP status code (such as 400, 403, 404, 429, 500) instead of 0.
  • Unknown Figma node/action types: ChildrenTrait and InteractionType now ignore unrecognized type values instead of throwing UnhandledMatchError.

How to use

Check out samples and tests.

License

PHP library for Figma REST API is licensed under MIT.