# Fetch Strategy Router (`70peterson/fetch-strategy-router`) Actor

Lightweight fetch strategy router for AI agents and scraping pipelines. Classifies each URL as direct HTTP, browser, proxy likely needed, browser + proxy, retry later, or skip based on HTTP status, anti-bot signals, JavaScript shell detection, redirects, response content, and access conditions.

- **URL**: https://apify.com/70peterson/fetch-strategy-router.md
- **Developed by:** [pierre-luc Rheaume-cyr](https://apify.com/70peterson) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Fetch Strategy Router

A lightweight machine-to-machine router that helps AI agents, crawlers, and automation pipelines choose the cheapest viable way to fetch a URL before spending money on a browser or proxy.

Give it one or many public URLs. For each URL, it performs a bounded direct HTTP probe and returns a routing recommendation.

### Routing outcomes

- `direct_http` — static HTTP is likely sufficient.
- `browser` — the response looks like a JavaScript shell or nearly empty app page.
- `proxy_likely_needed` — the site returned a block such as HTTP 403 without a strong browser-challenge signal.
- `browser_plus_proxy` — challenge / anti-bot signals suggest both browser rendering and alternate network egress may be required.
- `retry_later` — rate limit, transient server error, or timeout.
- `skip` — invalid URL, private target, missing resource, authentication requirement, or another condition where escalation is unlikely to help.

### Why use it

Browser scraping can be orders of magnitude heavier than a simple HTTP request. This Actor is designed to run first and help downstream agents decide whether to:

1. use Cheerio / HTTP,
2. escalate to Playwright or Puppeteer,
3. add proxy infrastructure,
4. retry later,
5. skip the target.

Typical uses include:

- web-crawling orchestration
- AI-agent tool routing
- scraper cost optimization
- bulk URL triage
- anti-bot preflight checks
- ETL and enrichment pipelines
- crawler fallback logic

### What it inspects

- HTTP status
- redirect chain
- response time
- response content type
- bounded response body
- visible static text density
- JavaScript shell indicators
- empty application-root indicators
- Cloudflare signals
- Akamai signals
- DataDome signals
- PerimeterX signals
- Imperva signals
- Sucuri signals
- generic bot/challenge text
- rate-limit headers

### Example input

```json
{
  "urls": [
    "https://apify.com",
    "https://www.cloudflare.com"
  ],
  "requestTimeoutSecs": 12,
  "maxConcurrency": 25,
  "maxHtmlBytes": 500000
}
```

### Example output

```json
{
  "requestedUrl": "https://example.com/",
  "finalUrl": "https://example.com/",
  "domain": "example.com",
  "statusCode": 200,
  "responseTimeMs": 184,
  "recommendedRoute": "direct_http",
  "confidence": 0.94,
  "reasons": [
    "substantial_static_text",
    "healthy_static_text_density"
  ],
  "antiBotDetected": false,
  "antiBotVendor": null,
  "antiBotSignals": [],
  "staticSignals": {
    "textChars": 7842,
    "textDensity": 0.118,
    "scriptCount": 9,
    "scriptRatio": 0.12,
    "hasAppRootSignal": false,
    "hasNoscriptJsMessage": false,
    "metaRefresh": false,
    "likelyJsShell": false,
    "htmlLooksValid": true
  },
  "error": null
}
```

### Cost-conscious design

This Actor deliberately does not launch a browser, solve CAPTCHAs, call an LLM, or use residential proxies. It reads a bounded amount of public response data and makes one main request per URL, following only a small redirect chain.

That makes it suitable as a first-stage router before more expensive Actors.

### Security

Only public HTTP and HTTPS targets are accepted. Hostnames are resolved before requests and again before redirects. Loopback, private, link-local, and reserved IP ranges are rejected to reduce SSRF risk.

### Interpretation

A routing recommendation is a heuristic, not a guarantee. Websites can vary responses by geography, IP reputation, cookies, TLS fingerprint, user agent, and time. The Actor is intended to choose a sensible next step cheaply, not to prove that a specific scraping technique will always work.

### Output

One dataset item is produced for every submitted URL, including blocked or failed URLs. This makes the output convenient for APIs, MCP tools, n8n, Make, Zapier, custom crawlers, and autonomous agents.

# Actor input Schema

## `urls` (type: `array`):

Public HTTP/HTTPS URLs or domains to classify.

## `requestTimeoutSecs` (type: `integer`):

Maximum time allowed for each direct HTTP probe.

## `maxConcurrency` (type: `integer`):

Maximum number of URLs inspected in parallel.

## `maxHtmlBytes` (type: `integer`):

Maximum bytes read from each response body for classification.

## `userAgent` (type: `string`):

User-Agent used for the lightweight HTTP probe.

## Actor input object example

```json
{
  "urls": [
    "https://apify.com",
    "https://www.cloudflare.com"
  ],
  "requestTimeoutSecs": 12,
  "maxConcurrency": 25,
  "maxHtmlBytes": 500000,
  "userAgent": "Mozilla/5.0 (compatible; FetchStrategyRouter/1.0; +https://apify.com/70peterson/fetch-strategy-router)"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("70peterson/fetch-strategy-router").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("70peterson/fetch-strategy-router").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call 70peterson/fetch-strategy-router --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,70peterson/fetch-strategy-router"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/BtHX9HLLXBQUfgZgu/builds/H6VHRmGwS3m5sgnt4/openapi.json
