Trawl

Parameters

Parameters are the values your script reads as TRAWL.<name>, so one scrap can run with many inputs. Set them in Settings → Parameters, or send your own with the run call.

The TRAWL.* namespace

The script gets a TRAWL object:

  • TRAWL.url: always the scrap's URL setting. Nothing can change it: not a parameter, not the call body.
  • Your parameters: each key becomes TRAWL.<name>. A scheduled run or the Run button uses the values in Settings → Parameters; a run call from your code uses the body you send instead (see below). A run never mixes the two.

A TRAWL. key you never set stays undefined. The old @variable form no longer works.

Scenarios and helpers

You can store several sets of values, called scenarios: each run (the schedule and the web app's Run button) picks one stored set at random.

A value can use a helper, worked out before the run (the script only sees the result):

  • DATE(delta, unit, format): DATE(-1, days, YYYY-MM-DD) is yesterday as YYYY-MM-DD.
  • RANDOM(a, b, c, ...): one value picked at random from the list.
JSON
[
  { "TRAWL.query": "javascript frameworks", "TRAWL.limit": 20 },
  { "TRAWL.query": "rust webassembly",      "TRAWL.limit": 20 }
]

Run with your own values

POST /api/scraps/worker/<scrap_id> with your values in the body runs the scrap on them and answers with its data. The keys are the ones in the scrap's first stored set (Settings → Parameters):

The answer:

  • The exact keys, all of them. One flat object with the keys of the scrap's first stored set, written as stored (TRAWL.<name> on current scraps), each with the same type: a number stays a number, a text cannot be empty. Other keys are dropped.
  • A wrong body is a 422: an empty body, a missing key or a wrong type. With ?wait=false the body is checked too, before the run is queued.
  • TRAWL.url and the account cannot be sent. They always come from the scrap; the login is TRAWL.account.*, set in Settings → Account (see Account & sessions).
  • When your values find nothing. A run on your own values that comes back empty or fails is kept as is. If Auto-fix is on, Trawl then runs one stored set again (at most once a day per scrap) to see whether the script is really broken, before any fix. Keep a schedule on the scrap: it runs your stored sets and watches the scrap's health.

See also: Advanced scraping · Account & sessions · API keys

Next step → Account & sessions

curl -X POST "https://api.trawl.me/api/scraps/worker/<scrap_id>" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{ "TRAWL.query": "machine learning", "TRAWL.limit": 20 }'
Response
{ "type": "success", "message": "scrap loaded", "data": { "result": [{ "title": "Machine learning in 2026" }] } }