async/await, and stream results. This quickstart walks you from an empty project to running your first task in a handful of lines.
Prerequisites
- Swift 6.0 or later
- macOS 13, iOS 16, tvOS 16, or watchOS 9 deployment target
- A running Figranium instance (
http://localhost:11345by default) - An API key generated from the Figranium web UI
1
Install the SDK
Add the package in Xcode or Swift Package Manager. See Installation for the full manifest snippet.
Package.swift
2
Create a client
Store your API key securely (for example, in the Keychain or environment) so it never lands in source control.See Client configuration for every constructor option and Authentication for API key setup.
quickstart.swift
3
Define and save a task
Use See Actions for every helper and Variables for typed variable declarations.
Actions helpers to describe the browser workflow. variable("query") produces the template token {$query} that is replaced at runtime.quickstart.swift
The SDK’s model type
Task shadows Swift’s concurrency Task. Use Swift.Task { } or Figranium.Task to disambiguate when necessary.4
Run the task
Use
runTask (a shortcut for client.tasks.run) and pass runtime variable overrides in ExecuteTaskOptions.quickstart.swift
5
Watch the execution
Poll the execution and yield only when the status changes. The stream finishes when the run reaches a terminal state.See Streaming for
quickstart.swift
executions.stream() and browser.selectorStream().6
Handle errors
Every HTTP, transport, and timeout failure throws See Errors for the full list of codes.
FigraniumError. Inspect code and status to branch on the failure kind.quickstart.swift
Complete example
quickstart.swift
Direct execution without saving
For one-off runs, skiptasks.save and call client.scrape, client.agent, or client.headful directly. These use the same task shape, but the server does not persist them.
direct.swift
Next steps
Action helpers
Every helper you can use to build a task, from navigation to CAPTCHA solving.
Streaming
Iterate over live executions with
client.executions.stream().Handle errors
FigraniumError fields, codes, and cancellation semantics.Tasks resource
Save, version, list, and run tasks programmatically.