Skip to content

TypeScript API Actor

An Actor that stays running, ready to respond to HTTP requests. Good for APIs and real-time services.

Create it locally

$scrapely create my-actor --template ts-standby

Main file

.TS
src/main.ts
import http from 'http';
import { Actor } from 'scrapely';

// this is ESM project, and as such, it requires you to specify extensions in your relative imports
// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
// note that we need to use `.js` even when inside TS files
// import { router } from './routes.js';

// The init() call configures the Actor to correctly work with the platform-provided environment - mainly the storage infrastructure. It is necessary that every Actor performs an init() call.
await Actor.init();

// Create a simple HTTP server that will respond with a message
const server = http.createServer((req, res) => {
    // Handle Scrapely standby readiness probe
    if (req.headers['x-scrapely-standby-readiness-probe']) {
        res.writeHead(200);
        res.end('ok');
        return;
    }
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello from Actor Standby!\n');
});

// Listen on the standby port
server.listen(Actor.config.get('standbyPort'));

TypeScript API Actor

An Actor that stays running, ready to respond to HTTP requests. Good for APIs and real-time services.

Included features

  • Scrapely SDK — Actor lifecycle, input, storage and proxies
  • Input schema — define and validate the Actor's input (.actor/input_schema.json)
  • Dataset schema — structured results with a preview view (.actor/dataset_schema.json)
  • Standby mode — the Actor stays running and answers HTTP requests at its standby URL

Getting started locally

npm install
npm run start      # run the Actor
npm run build      # compile to dist/

Deploying to Scrapely

Create an Actor from this template in the Scrapely Console (Develop new → template → Git). Scrapely creates a repository in your account, pushes this code, and builds the Actor. Every push to your repository triggers a new build.

G2
4.7/5
Excellent
Trustpilot

The internet is full of data.
Start owning yours.

Scrape.ly gives you the infrastructure, the tooling, and the team to extract, process, and operationalize web data at any scale. Setup takes minutes. The advantage lasts forever.

No credit card. No setup calls.