A Swift client for the Figma REST API with async/await, rate limiting, and automatic retry with exponential backoff.
- Full Figma REST API coverage (46 endpoints) — files, components, styles, variables, comments, webhooks, dev resources, analytics, and more
- Token-bucket rate limiting with fair round-robin scheduling
- Exponential backoff retry with jitter and
Retry-Aftersupport - Figma Variables API (read local, read published, write codeSyntax)
- Support for both API v1 and v2 (webhooks)
- GitHub Releases endpoint (for version checking)
- Swift 6 strict concurrency
- Swift 6.1+
- macOS 13+ / Linux (Ubuntu 22.04+)
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/DesignPipe/swift-figma-api.git", from: "0.1.0"),
]Then add FigmaAPI to your target dependencies:
.target(
name: "YourTarget",
dependencies: [
.product(name: "FigmaAPI", package: "swift-figma-api"),
]
)import FigmaAPI
// Create a client
let figma = FigmaClient(accessToken: "your-figma-token", timeout: nil)
// Wrap with rate limiting and retry
let rateLimiter = SharedRateLimiter()
let client = RateLimitedClient(
client: figma,
rateLimiter: rateLimiter,
configID: "default"
)
// Fetch components from a file
let components = try await client.request(
ComponentsEndpoint(fileId: "your-file-id")
)
// Fetch variables
let variables = try await client.request(
VariablesEndpoint(fileId: "your-file-id")
)
// Export images as SVG
let images = try await client.request(
ImageEndpoint(fileId: "your-file-id", nodeIds: ["1:2", "3:4"], params: SVGParams())
)
// Get current user
let me = try await client.request(GetMeEndpoint())
// Post a comment
let comment = try await client.request(
PostCommentEndpoint(
fileId: "your-file-id",
body: PostCommentBody(message: "Looks great!")
)
)
// List webhooks (v2 API)
let webhooks = try await client.request(GetWebhooksEndpoint())MIT