Skip to main content
The Figranium Kotlin SDK lets you drive a Figranium server from Kotlin: build tasks with typed action helpers, run them with coroutines, and stream results as Flow. This quickstart walks you from an empty project to running your first task in a handful of lines.

Prerequisites

  • Kotlin 2.2 or later
  • A JVM toolchain of 17 (or Android minSdk 23)
  • A running Figranium instance (http://localhost:11345 by default)
  • An API key generated from the Figranium web UI
1

Install the SDK

Add the Gradle dependency. See Installation for the full manifest snippet.
build.gradle.kts
2

Create a client

Store your API key securely (for example, in environment variables or Android Keystore) so it never lands in source control.
quickstart.kt
See Client configuration for every constructor option and Authentication for API key setup.
3

Define and save a task

Use Actions helpers to describe the browser workflow. variable("query") produces the template token {\$query} that is replaced at runtime.
quickstart.kt
See Actions for every helper and Variables for typed variable declarations.
4

Run the task

Use runTask (a shortcut for client.tasks.run) and pass runtime variable overrides in ExecuteTaskOptions.
quickstart.kt
5

Watch the execution

Poll the execution and emit only when the status changes. The flow finishes when the run reaches a terminal state.
quickstart.kt
See Streaming for executions.stream() and browser.selectorStream().
6

Handle errors

Every HTTP, transport, and timeout failure throws FigraniumException. Inspect status and code to branch on the failure kind.
quickstart.kt
See Errors for the full list of codes.

Complete example

quickstart.kt

Direct execution without saving

For one-off runs, skip tasks.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.kt

Next steps

Action helpers

Every helper you can use to build a task, from navigation to CAPTCHA solving.

Streaming

Collect live executions with client.executions.stream().

Handle errors

FigraniumException fields, codes, and cancellation semantics.

Tasks resource

Save, version, list, and run tasks programmatically.