# URL Resolver & Enricher (`dvorzhik/url-resolver-enricher`) Actor

Resolves redirects, strips tracking parameters, and enriches URLs with Open Graph metadata, language, and content type. Bulk-ready and proxy-capable.

- **URL**: https://apify.com/dvorzhik/url-resolver-enricher.md
- **Developed by:** [Aleksandr Dvorzhitckii](https://apify.com/dvorzhik) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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.

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

## URL Resolver & Enricher

**URL Resolver & Enricher** is a high-performance, cost-effective Apify Actor that expands shortened links, resolves complex multi-hop redirect chains, cleans invasive tracking parameters, and enriches URLs with page metadata (Open Graph tags, content type, language, favicon) — all in a single pass.

***

### 🎯 Why You Need This

When building web scrapers, data pipelines, CRM integrations, or marketing analytics datasets, you frequently encounter raw, "dirty" URLs:

- **Shortened links:** `bit.ly`, `t.co`, `tinyurl.com`, `youtu.be`, `amzn.to` that hide the real destination.
- **Tracking & Affiliate bloat:** invasive query strings like `utm_*`, `fbclid`, `gclid`, Amazon affiliate tags, social media referrer IDs that break deduplication and privacy.
- **Search engine wrappers:** `google.com/url?q=...` redirects that don't need real HTTP roundtrips.
- **Missing context:** raw links lack title, preview image, language, or content classification.

**URL Resolver & Enricher** solves all of this automatically: it normalizes URLs, strips unwanted parameters, and turns links into rich, structured content cards.

***

### ✨ Key Features

1. **Lightweight & Fast (HEAD-first):**
   - Follows HTTP redirects using lightweight `HEAD` requests without downloading page bodies.
   - Falls back to `GET` only when encountering HTML `meta refresh` or JavaScript redirects.
2. **Instant Google Redirect Unpacking:**
   - Detects `google.com/url?q=...` links and resolves them instantly in-memory with zero network overhead.
3. **Deep Parameter Sanitization:**
   - Strips **180+ known tracking, analytics, and affiliate parameters**:
     - Google Analytics / Ads (`utm_*`, `gclid`, `gbraid`, `wbraid`)
     - Meta / Facebook (`fbclid`, `fb_action_*`, `fb_source`)
     - Social trackers (Twitter, TikTok, Reddit, Medium, LinkedIn)
     - Affiliate & Marketplace tags (Amazon `tag`, `ref_`, `pd_rd_*`, `creative`, `qid`, eBay, ShareASale)
   - Preserves all legitimate application parameters (e.g. `v` for YouTube videos, search queries, pagination).
4. **Smart Metadata Enrichment:**
   - Downloads only the first 64 KB (configurable) of HTML to extract `<head>` tags without loading full pages or media.
   - Extracts:
     - Open Graph: `og:title`, `og:description`, `og:image`, `og:site_name`, `og:type`
     - Page language from `<html lang>`, `og:locale`, or linguistic heuristics
     - Inferred content type: `article`, `video`, `product`, `social`, `audio`, or `webpage`
     - Publication time (`article:published_time`)
     - Website favicon
5. **Apify Residential Proxy Integration:**
   - One-click toggle (`use_proxy: true`) routes requests through Apify Residential Proxies with optional country selection (`proxy_country: "US"`).
6. **Anti-Bot Browser Impersonation:**
   - Built-in support for TLS fingerprint mimicry (`curl_cffi` Chrome/Safari impersonation) to resolve antibot-protected websites (Cloudflare, Akamai).

***

### 📥 Input Parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `url` | `string` | — | Single URL to process |
| `urls` | `array` | — | List of URLs to process (automatically deduplicated) |
| `enrich` | `boolean` | `true` | Extract Open Graph tags and page metadata |
| `use_proxy` | `boolean` | `false` | Enable Apify Residential Proxy |
| `proxy_country` | `string` | — | 2-letter ISO country code for proxy (e.g. `US`, `DE`, `GB`) |
| `concurrency` | `integer` | `10` | Number of simultaneous concurrent requests (1–50) |
| `max_redirects` | `integer` | `5` | Maximum redirect hops to follow per URL |
| `timeout_sec` | `integer` | `15` | Request timeout per URL in seconds |
| `head_bytes` | `integer` | `65536` | Maximum bytes to fetch for `<head>` parsing (default: 64 KB) |
| `impersonate` | `boolean` | `false` | Use browser TLS fingerprint impersonation |

#### Example Input (`INPUT.json`)

```json
{
  "urls": [
    "https://youtu.be/dQw4w9WgXcQ?feature=shared",
    "https://www.google.com/url?q=https://www.apify.com/",
    "https://www.amazon.com/dp/B08N5WRWNW?tag=myaffiliate-20&ref_=as_li_ss_tl",
    "https://www.bbc.com/news/world-us-canada-68542388?at_medium=custom7"
  ],
  "enrich": true,
  "use_proxy": false,
  "concurrency": 10
}
```

***

### 📤 Output Dataset Format

Every resolved URL is pushed to the default Apify Dataset in structured format:

```json
{
  "input_url": "https://youtu.be/dQw4w9WgXcQ?feature=shared",
  "final_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "clean_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "http_status": 200,
  "redirect_chain": [
    "https://youtu.be/dQw4w9WgXcQ?feature=shared",
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "redirect_count": 1,
  "removed_params": ["feature"],
  "removed_count": 1,
  "og_title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
  "content_type": "video",
  "lang": "en"
}
```

#### Output Schema Fields

- `input_url`: The original input URL.
- `final_url`: The destination URL after following all redirect hops.
- `clean_url`: The destination URL with all tracking/affiliate parameters stripped.
- `http_status`: HTTP response status code (e.g. `200`, `404`, `301`).
- `redirect_chain`: Full list of intermediate URLs in the redirect chain.
- `redirect_count`: Total number of redirects followed.
- `removed_params`: List of query parameter names removed.
- `removed_count`: Number of removed query parameters.
- `og_title`: Page Open Graph title.
- `og_description`: Page Open Graph description.
- `og_image`: Primary preview image URL.
- `og_site_name`: Website name.
- `og_type`: Raw Open Graph type.
- `content_type`: Inferred category (`article`, `video`, `product`, `social`, `audio`, `webpage`).
- `lang`: Detected language code (e.g. `en`, `ru`, `es`).
- `published_time`: Article publication timestamp if available.
- `favicon`: Website favicon URL.
- `fetch_error`: Non-fatal error during enrichment (e.g. `http_404`, `timeout`).
- `error`: Fatal error during URL resolution.

***

### 💰 Monetization & Pricing

- **Pay per event:** **$0.001 per resolved URL** ($1.00 per 1,000 URLs).
- Only successfully resolved and enriched URLs are charged.
- Zero extra fees for uncharged or failed links.

***

### 🛠️ Usage via Apify API / Python Client

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {
    "urls": [
        "https://t.co/example",
        "https://bit.ly/example"
    ],
    "enrich": True
}

run = client.actor("dvorzhik/url-resolver-enricher").call(run_input=run_input)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["clean_url"], item.get("og_title"))
```

# Actor input Schema

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

A single URL to resolve and enrich. Use this for one-off links.

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

A list of URLs for batch processing. Duplicates are removed automatically.

## `enrich` (type: `boolean`):

Fetch the page head to extract Open Graph tags, language, and content type. Disable for maximum speed (redirects and tracking removal only).

## `use_proxy` (type: `boolean`):

Route requests through Apify Proxy to avoid blocks on protected sites. Disabled by default to save costs.

## `proxy_country` (type: `string`):

Two-letter country code for the proxy (e.g. 'US', 'DE'). Leave empty for no country preference. Only used when 'Use Apify Proxy' is enabled.

## `concurrency` (type: `integer`):

Number of URLs processed simultaneously. Higher values are faster but may trigger rate limits.

## `max_redirects` (type: `integer`):

Maximum length of the redirect chain to follow.

## `timeout_sec` (type: `integer`):

Timeout for a single HTTP request.

## `head_bytes` (type: `integer`):

How many bytes of the page to download for metadata extraction. 64 KB is enough for the <head> section.

## `impersonate` (type: `boolean`):

Use curl\_cffi to mimic browser TLS fingerprints. Helps against anti-bot protection (Cloudflare, Akamai).

## Actor input object example

```json
{
  "url": "https://bit.ly/3xample",
  "urls": [
    "https://t.co/example",
    "https://example.com/article?utm_source=newsletter&fbclid=abc123"
  ],
  "enrich": true,
  "use_proxy": false,
  "concurrency": 10,
  "max_redirects": 5,
  "timeout_sec": 15,
  "head_bytes": 65536,
  "impersonate": false
}
```

# 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 = {
    "url": "https://bit.ly/3xample",
    "urls": [
        "https://t.co/example",
        "https://example.com/article?utm_source=newsletter&fbclid=abc123"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dvorzhik/url-resolver-enricher").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 = {
    "url": "https://bit.ly/3xample",
    "urls": [
        "https://t.co/example",
        "https://example.com/article?utm_source=newsletter&fbclid=abc123",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("dvorzhik/url-resolver-enricher").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 '{
  "url": "https://bit.ly/3xample",
  "urls": [
    "https://t.co/example",
    "https://example.com/article?utm_source=newsletter&fbclid=abc123"
  ]
}' |
apify call dvorzhik/url-resolver-enricher --silent --output-dataset

```

## MCP server setup

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

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/zQUv0rChuxM97PhkB/builds/1u1AY55W0ne6ghb0o/openapi.json
