# AllTrails Scraper (`crawlerbros/alltrails-scraper`) Actor

Scrape AllTrails, the world's largest hiking, biking, and running trail database. Search trails by keyword/location; fetch full trail detail (difficulty, distance, elevation, GPS coordinates, photos, recent reviews); browse trails by park, city, or country.

- **URL**: https://apify.com/crawlerbros/alltrails-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 31 total users, 4 monthly users, 93.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## AllTrails Scraper

Scrape **AllTrails** — the world's largest hiking, biking, and running trail database — for trail detail, location-based browse, or keyword search. Returns full structured data including difficulty, distance, elevation profile, GPS coordinates, photos, ratings, and recent reviews.

### What this actor extracts

For every emitted trail record:

- `name`, `slug`, `url`, `trailId`, `mapId`
- `overview` — long-form trail description
- Geometry: `lengthMeters`, `lengthKm`, `lengthMiles`, `elevationGainMeters`, `elevationGainFeet`, `elevationStartMeters`, `elevationMaxMeters`
- Difficulty: `difficulty` (`easy`/`moderate`/`hard`), `difficultyScore` (1-7)
- `routeType` (`out_and_back`/`loop`/`point_to_point`)
- Location: `latitude`, `longitude`, `city`, `state`, `stateCode`, `country`, `countryCode`, `areaName`, `areaSlug`
- Ratings: `avgRating`, `reviewCount`, `ratingsBreakdown` (per-star counts), `popularity`, `visitorUsage`
- Counts: `photoCount`, `trackCount`, `completedCount`
- `activities[]` — primary activity slugs (hiking, mountain-biking, etc.)
- `features[]` — trail attributes (Forests, Rivers, Views, Waterfalls, etc.)
- `seasonStartMonth`, `seasonEndMonth`
- `coverPhoto` — `{id, url, title, username}` and top-level `coverUrl`
- `recentReviews[]` — recent review excerpts (rating, author, text, date) when available from the trail page

### Modes

| Mode                  | Input                                                  | Output |
|-----------------------|--------------------------------------------------------|--------|
| `byTrail`             | `url` or `country` + `state` + `trailSlug`             | One full trail record |
| `byUrl`               | `url` or `urls[]` — any alltrails.com URL              | Auto-routed (trail/park/city/country/search) |
| `searchTrails`        | `query` + optional `country`                           | Trails matching the query (Algolia API) |
| `byPark`              | `url` or `country` + `state` + `parkSlug`              | Trails inside a park (with detail) |
| `byCity`              | `url` or `country` + `state` + `city`                  | Popular trails near a city |
| `topTrailsByCountry`  | `url` or `country`                                     | Curated trail list for a country page |

### Filters

| Filter           | Description |
|------------------|-------------|
| `difficulty`     | `easy` / `moderate` / `hard` |
| `routeType`      | `out_and_back` / `loop` / `point_to_point` |
| `activity`       | One of 23 activity slugs (hiking, mountain-biking, …) |
| `minRating`      | Drop trails below this avgRating (0-5) |
| `minLengthKm`    | Drop trails shorter than this (km) |
| `maxLengthKm`    | Drop trails longer than this (km) |
| `maxItems`       | Hard cap on emitted records (1-1000) |

### Reliability

- HTTP-first via `curl_cffi` with **Safari iOS** TLS fingerprint (this is the only impersonation that bypasses AllTrails' Cloudflare-edge filter — Chrome/Firefox impersonations get 403'd).
- Auto-escalates to **Apify residential proxy** on 403 / 429 / Cloudflare-challenge if `autoEscalateOnBlock=true` (default).
- Retries with exponential backoff up to 4 attempts.
- Algolia search uses AllTrails' public client-facing keys — no auth gymnastics required.

### Multi-country support

The `country` enum exposes 48 of the most-trafficked AllTrails country slugs. Search uses the matching localized Algolia index when one exists (e.g. `germany` → `alltrails_primary_de-DE`). For all other countries, the global English index is used.

### FAQ

**Do I need an account or login?**
No. AllTrails' trail pages, park pages, country pages, and search index are all publicly accessible.

**Why is `recentReviews` shorter than `reviewCount`?**
AllTrails' trail page only embeds the most-recent ~5-10 reviews server-side; the rest are loaded client-side via API. To pull large review sets, use the `byTrail` mode with the canonical URL — the actor returns whatever the page exposes.

**Are GPX track files included?**
No — the actor focuses on trail metadata. GPX/KML downloads are paywalled by AllTrails.

**Do I get photos?**
Yes — the cover photo URL is included as `coverUrl`. AllTrails CDN images are publicly accessible without referer headers.

**Can I scrape user profiles or saved lists?**
Not in v1 — those routes are mostly login-walled.

### Limitations

- AllTrails Pro-only fields (downloadable maps, real-time conditions API) are not exposed.
- Search results sometimes return `area` records (parks/regions) before trails; we filter to `type=trail` only.
- A handful of country slugs return 403 from datacenter IPs — auto-escalation kicks in transparently.

# Actor input Schema

## `mode` (type: `string`):

Which discovery axis to use.

## `url` (type: `string`):

An alltrails.com URL — trail, park, city, or country page. Used by mode=byTrail/byPark/byCity/byUrl/topTrailsByCountry.

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

Multiple alltrails.com URLs. Trail/park/city/country URLs are auto-routed.

## `query` (type: `string`):

Free-text query, e.g. `yosemite`, `coastal hike california`.

## `country` (type: `string`):

Country slug used by AllTrails URLs and for search index selection. `us` is the default.

## `state` (type: `string`):

State slug (e.g. `california`, `new-york`). Used with byPark/byCity/byTrail.

## `city` (type: `string`):

City slug (e.g. `san-francisco`, `los-angeles`).

## `trailSlug` (type: `string`):

Trail slug — the part after the state in the URL.

## `parkSlug` (type: `string`):

Park slug, e.g. `yosemite-national-park`.

## `difficulty` (type: `string`):

Filter by AllTrails difficulty band.

## `routeType` (type: `string`):

Filter by trail route type.

## `activity` (type: `string`):

Filter by primary activity. Trails matching this activity in their `activities` array pass.

## `minRating` (type: `number`):

Drop trails with avgRating below this (0-5).

## `minLengthKm` (type: `number`):

Drop trails shorter than this length (km).

## `maxLengthKm` (type: `number`):

Drop trails longer than this length (km).

## `fetchTrailDetails` (type: `boolean`):

For listing modes (byPark/byCity/topTrailsByCountry/byUrl-listing), fetch the full trail detail page for every trail. Disable to emit lightweight stubs faster.

## `useProxy` (type: `boolean`):

Route requests through Apify proxy. AllTrails works without a proxy in most cases; auto-escalation handles 403/429 transparently.

## `autoEscalateOnBlock` (type: `boolean`):

If direct fetches return 403/429/Cloudflare-challenge, retry through Apify (residential first) proxy automatically.

## `proxyConfiguration` (type: `object`):

Optional Apify proxy configuration override.

## `maxItems` (type: `integer`):

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "byTrail",
  "url": "https://www.alltrails.com/trail/us/california/half-dome-trail",
  "urls": [],
  "country": "us",
  "difficulty": "",
  "routeType": "",
  "activity": "",
  "fetchTrailDetails": true,
  "useProxy": false,
  "autoEscalateOnBlock": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": []
  },
  "maxItems": 25
}
```

# Actor output Schema

## `records` (type: `string`):

Dataset containing all scraped AllTrails records.

# 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 = {
    "mode": "byTrail",
    "url": "https://www.alltrails.com/trail/us/california/half-dome-trail",
    "urls": [],
    "country": "us",
    "fetchTrailDetails": true,
    "useProxy": false,
    "autoEscalateOnBlock": true,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": []
    },
    "maxItems": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/alltrails-scraper").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 = {
    "mode": "byTrail",
    "url": "https://www.alltrails.com/trail/us/california/half-dome-trail",
    "urls": [],
    "country": "us",
    "fetchTrailDetails": True,
    "useProxy": False,
    "autoEscalateOnBlock": True,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": [],
    },
    "maxItems": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/alltrails-scraper").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 '{
  "mode": "byTrail",
  "url": "https://www.alltrails.com/trail/us/california/half-dome-trail",
  "urls": [],
  "country": "us",
  "fetchTrailDetails": true,
  "useProxy": false,
  "autoEscalateOnBlock": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": []
  },
  "maxItems": 25
}' |
apify call crawlerbros/alltrails-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/alltrails-scraper"
        }
    }
}

```

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/jMt07eiVYGfj8QTIp/builds/Cuds6baHSlcYCXdlA/openapi.json
