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:
| Part | What it is |
|---|---|
| Image | A Docker image with your code. Lantfly builds it from your folder or a Git repository, or you push it yourself. |
| Input schema | A JSON description of the input. The Console builds the run form from it, and the API checks inputs against it. |
| Versions | Numbered 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, categories | What 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
- 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
INPUTrecord of the run's key-value store. - Ready. The run waits for a free slot and the image of the chosen version.
- 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. - 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. - Finished. The run ends as
SUCCEEDED,FAILED,TIMED-OUTorABORTED. 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 to | Use |
|---|---|
| Write an actor in JavaScript or TypeScript | Actor SDK for Node.js and Crawlee |
| Write an actor in Python | Python SDK |
| Scaffold, push and run from your terminal | Lantfly CLI |
| Serve HTTP requests from a warm container | Actor Standby |
| Earn from other accounts' runs | Monetization 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
helloandweb-scraperactors, line by line.