Swiftpack.co -  Package - memfrag/FigmaAPI
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Partial implementation of a Figma REST API client in Swift.
.package(url: "https://github.com/memfrag/FigmaAPI.git", from: "v1.1.0")

Figma API

This is a Swift implementation of a Figma REST API client.

License Info

This is free and unencumbered software released into the public domain. See UNLICENSE file for details.


import FigmaAPI

let accessToken: String = "<Your Figma access token goes here>"

let api: FigmaAPI = FigmaAPIFactory.makeAPI(accessToken: accessToken)

let fileID: String = "<The ID of your figma file goes here>"

api.getFile(fileID) { result in
    switch result {
    case .success(let figmaFile):
        print("Downloaded the Figma document \(figmaFile.name).")
    case .failure(let error):

File ID

The fileID used in the API is the long string of letters after file/ and before the name of the Figma document in the Figma URL in the browser:


In this example, it's PiTSISPbDVQueOIDyepzTm

API Request Tracing

In debug builds, the following enum is available:

public enum APILogType {
    case url
    case urlRequest
    case requestBody
    case responseCode
    case responseBody

To configure what should be logged:

FigmaAPI.apiLogTypes = [.url, .responseBody]

Figma Node Inheritance Hierarchy

 │  ├─FigmaComponentNode
 │  ├─FigmaGroupNode
 │  └─FigmaInstanceNode


Stars: 0
Last commit: 3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco