$API_TOKEN=<YOUR_API_TOKEN>
$cat > input.json << 'EOF'
<{
< "code": "# `input` holds the job's JSON input. Set `result` to return data (any JSON-serializable value).\nimport statistics\n\nnums = input.get(\"numbers\", [])\nprint(f\"Got {len(nums)} numbers\")\nresult = {\n \"count\": len(nums),\n \"sum\": sum(nums),\n \"mean\": statistics.mean(nums) if nums else None,\n \"sorted\": sorted(nums),\n}\n",
< "inputJson": {
< "numbers": [
< 1,
< 2,
< 3
< ]
< },
< "jobs": [
< {
< "id": "python-stats",
< "input": {
< "numbers": [
< 4,
< 8,
< 15,
< 16,
< 23,
< 42
< ]
< }
< },
< {
< "id": "js-word-count",
< "language": "javascript",
< "code": "// `input` holds the job's JSON input. `return` a value (top-level await works).\nconst words = (input.text || '').toLowerCase().match(/[a-z']+/g) || [];\nconst counts = {};\nfor (const w of words) counts[w] = (counts[w] || 0) + 1;\nconsole.log(`Counted ${words.length} words`);\nreturn Object.entries(counts)\n .sort((a, b) => b[1] - a[1])\n .slice(0, 5)\n .map(([word, count]) => ({ word, count }));\n",
< "input": {
< "text": "The quick brown fox jumps over the lazy dog. The dog sleeps; the fox runs."
< }
< }
< ]
<}
<EOF
$curl "https://api.apify.com/v2/actors/gazidev~code-runner-sandbox/runs?token=$API_TOKEN" \
< -X POST \
< -d @input.json \
< -H 'Content-Type: application/json'