Skip to main content

Build actors

An actor is a program packaged as a Docker image that Lantfly runs on demand. It reads an input, does its work (crawl pages, call APIs, transform data) and writes its results to storages. You can run the actors in the Store, or write your own in Node.js or Python and run them on Lantfly the same way.

An actor has:

PartWhat it is
ImageA Docker image with your code. Lantfly builds it from your folder or a Git repository, or you push it yourself.
Input schemaA JSON description of the input. The Console builds the run form from it, and the API checks inputs against it.
VersionsNumbered builds (0.1, 1.0…), each pointing at an image tag, with its own schemas and environment variables. One version is the default.
README, title, categoriesWhat people see on the actor's page and in the Store.
Pricing (optional)What a run of the actor costs other accounts, per result or per event.

Each run of an actor gets its own storages: a default dataset for results, a default key-value store for the input, the OUTPUT record and files, and a default request queue.

Lifecycle of a run​

  1. Start. You (or a schedule, a task, a webhook, an integration) start a run with an input and options such as memory and timeout. The platform fills in the input schema's defaults, checks the input and stores it as the INPUT record of the run's key-value store.
  2. Ready. The run waits for a free slot and the image of the chosen version.
  3. Running. The container starts with LANTFLY_* environment variables: the API URL, the run token, the storage ids, the proxy, the memory and the timeout. Your code reads the input, pushes items, writes records and can set a status message and report pay-per-event charges.
  4. Stopping. When the run is aborted or reaches its timeout, the container gets SIGTERM and about 10 seconds to flush its data. The SDKs do this for you: they flush buffered items and write OUTPUT.
  5. Finished. The run ends as SUCCEEDED, FAILED, TIMED-OUT or ABORTED. Exit code 0 is a success. Webhooks and integrations fire, and the storages stay available for the retention period of your plan.

A finished run can be resurrected (started again on the same storages) and a running run can metamorph into a run of another actor on the same storages. See Runs.

Ways to write an actor​

You want toUse
Write an actor in JavaScript or TypeScriptActor SDK for Node.js and Crawlee
Write an actor in PythonPython SDK
Scaffold, push and run from your terminalLantfly CLI
Serve HTTP requests from a warm containerActor Standby
Earn from other accounts' runsMonetization and Publishing

In this section​

  • Quickstart: scaffold an actor, run it locally, push it and run it on Lantfly.
  • Actor definition: .actor/actor.json, the Dockerfile, the schemas and the output.
  • Input schema: fields, types, editors and validation.
  • Environment: environment variables, the run token and what an actor may call.
  • Builds and versions: build from a folder, from Git or from your own image.
  • Monetization: pay-per-result and pay-per-event pricing, earnings.
  • Standby: actors that answer HTTP requests.
  • Publishing: the Store, sharing and reviews.
  • Examples: the hello and web-scraper actors, line by line.