# URL Unshortener: Expand Short Links & Resolve Redirects (`data-done-right/url-unshortener`) Actor

URL unshortener for bulk short links. Expand bit.ly, t.co, tinyurl, ow.ly, lnkd.in and amzn.to links, or resolve any redirect, to the final destination URL. Returns the full redirect chain, hop count, status code, final domain, page title and a clean URL without utm and fbclid. Pay per URL resolved.

- **URL**: https://apify.com/data-done-right/url-unshortener.md
- **Developed by:** [Data Done Right](https://apify.com/data-done-right) (community)
- **Categories:** SEO tools, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.64 / 1,000 url resolveds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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?

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

## URL Unshortener: Expand Short Links & Resolve Redirects

This URL unshortener expands bit.ly, t.co, tinyurl, ow.ly, lnkd.in, amzn.to and any other redirecting link in bulk, so you see the real destination before you click, share or store it.

**What you get**

- The final destination URL, the final HTTP status code and the final domain for every link.
- The full redirect chain (each hop with URL, status code and Location), the hop count, and a `cleanUrl` without utm\_\*, fbclid, gclid and other tracking parameters.
- Clear statuses instead of silent failures: redirect loops, too many hops, timeouts, DNS and SSL errors, and blocked addresses each get their own status and message.

It follows redirects itself, hop by hop, with HEAD first and a GET fallback. It sends no cookies, uses an honest `UrlUnshortenerBot` User-Agent, and refuses private, loopback and cloud-metadata addresses on every hop. It does not defeat bot protection: if a site blocks the request, the row says so.

### How to unshorten a link (expand a short URL)

1. Open the Actor and paste your short links into **Short or redirecting URLs**, one per line (or paste a block into **Or paste URLs**).
2. Click Start. A typical link resolves in 1 to 3 seconds.
3. Open the **Overview** tab of the dataset. `finalUrl` is where the link really goes; `cleanUrl` is the same address without tracking parameters.
4. Download as JSON, CSV or Excel, or read the rows through the API.

### How to resolve redirects and see every hop

Each row has `redirectChain`: an ordered list of `{url, statusCode, location, type}`. `type` is `http` for normal 301/302/303/307/308 redirects. Turn on **Follow meta-refresh and JavaScript redirects** to also follow `<meta http-equiv="refresh">` and tiny interstitial pages that only set `window.location`; those hops get the type `meta-refresh` or `javascript`. The last response is not a hop: it is `finalUrl` with `finalStatusCode`.

### How to remove tracking parameters from a link

Leave **Remove tracking parameters** on (default). `cleanUrl` drops utm\_\*, fbclid, gclid, dclid, msclkid, mc_cid, mc_eid, igshid, yclid, twclid, ttclid, `_hsenc`, `_hsmi`, mkt_tok, srsltid and similar, the Amazon affiliate `tag` and `linkCode`, and the `#fragment`. Add your own names in **Extra parameters to remove**. `finalUrl` is never changed, and `trackingRemoved` tells you when `cleanUrl` differs.

### How to get the page title of a short link

Turn on **Fetch page title**. The Actor then does one extra GET for the final page (first 256 KB only) and returns the `<title>` in `title`. It works for HTML pages; PDFs, images and JSON get `null`.

### Input

```json
{
  "urls": ["http://github.com", "https://httpbin.org/redirect/2", "https://bit.ly/"],
  "cleanTracking": true,
  "fetchTitle": true,
  "maxHops": 10
}
```

| Field | Default | What it does |
|---|---|---|
| `urls` (required) | 3 sample links | Links to expand, one per line. Missing `https://` is added, duplicates removed. |
| `urlsText` | empty | Same, as one pasted block. |
| `cleanTracking` | `true` | Fill `cleanUrl` without tracking parameters and fragment. |
| `extraTrackingParams` | empty | More parameter names to strip from `cleanUrl`. |
| `fetchTitle` | `false` | Read the title of the final HTML page (one extra GET). |
| `followHtmlRedirects` | `false` | Also follow meta-refresh and tiny JavaScript `location=` pages. |
| `maxHops` | `10` | Stop after this many hops (1 to 20). |
| `timeoutSecs` | `20` | Total time per URL, all hops included (1 to 120). |
| `concurrency` | `20` | URLs in parallel (1 to 50); at most 10 against one website. |
| `maxUrls` | `1000` | Cap on unique URLs per run (1 to 20,000); also caps your cost. |
| `proxyConfiguration` | off | Optional Apify proxy. |

### Output

One dataset row per unique URL (real output of this Actor):

```json
{
  "inputUrl": "https://bit.ly/",
  "url": "https://bit.ly/",
  "status": "resolved",
  "finalUrl": "https://bitly.com/",
  "cleanUrl": "https://bitly.com/",
  "finalDomain": "bitly.com",
  "finalStatusCode": 200,
  "hopCount": 1,
  "redirectChain": [
    {"url": "https://bit.ly/", "statusCode": 302, "location": "https://bitly.com/", "type": "http"}
  ],
  "isShortener": true,
  "shortenerDomain": "bit.ly",
  "title": "Bitly | Short URLs, QR Codes, and More",
  "contentType": "text/html",
  "trackingRemoved": false,
  "hasRedirectLoop": false,
  "responseTimeMs": 631,
  "warning": null,
  "error": null,
  "resolvedAt": "2026-10-29T22:39:47+00:00"
}
```

A tracking link looks like this (`finalUrl` keeps the original, `cleanUrl` is clean):

```json
{
  "url": "https://httpbin.org/redirect-to?url=https%3A%2F%2Fexample.com%2F%3Futm_source%3Dnewsletter%26fbclid%3Dabc123&status_code=302",
  "status": "resolved",
  "finalUrl": "https://example.com/?utm_source=newsletter&fbclid=abc123",
  "cleanUrl": "https://example.com/",
  "trackingRemoved": true,
  "hopCount": 1
}
```

`status` is one of `resolved`, `not-redirected`, `redirect-loop`, `too-many-redirects`, `timeout`, `blocked-address`, `dns-error`, `ssl-error`, `error`, `invalid`. A `SUMMARY` record in the key-value store counts rows by status, shortener links found, average hops and top destination domains.

### How much does it cost

Pay per event: **$0.80 per 1,000 URLs resolved** (`url-resolved`, $0.0008 each). You are charged only for rows with status `resolved` or `not-redirected`. Loops, timeouts, DNS errors, blocked addresses and invalid entries are free. Duplicates are removed before anything is charged. There is no start fee. Apify proxy traffic, if you turn the proxy on, is billed separately by Apify.

| Run | URLs resolved | Cost |
|---|---|---|
| Small list | 1,000 | $0.80 |
| Campaign audit | 10,000 | $8.00 |
| Large export | 100,000 | $80.00 |

### Use cases

- Check where a short link goes before you click it or forward it (phishing and safety checks).
- Clean a spreadsheet of shortened social or newsletter links into stable, tracking-free URLs for analytics.
- Audit affiliate and campaign links: see whether an `amzn.to` or `bit.ly` link still lands on the intended page.
- Find redirect chains that are too long or loop after a site migration.
- Feed an AI agent or n8n/Make flow with the real destination domain of every link in a message, ticket or tweet export.

### FAQ

**Which shorteners work?** Any link that answers with an HTTP redirect, including bit.ly, t.co, tinyurl.com, ow.ly, lnkd.in, amzn.to, is.gd, cutt.ly, rebrand.ly and goo.gl-style links. `isShortener` is true for dozens of well-known shortener domains; unknown ones still resolve.

**Does it bypass bot protection or login pages?** No. If a hop or the destination answers 401, 403 or 429 or serves a bot-protection challenge, the row is still `resolved` up to that URL and `warning` explains it. Some sites (for example Amazon) may answer a datacenter request with a challenge page; the chain up to there is correct.

**Why is `title` empty?** The title is only read when Fetch page title is on, and only from HTML pages that answer 200. Pages that need JavaScript to set a title return `null`.

**Does it follow JavaScript redirects?** Only simple ones, and only if you turn on Follow meta-refresh and JavaScript redirects: `<meta http-equiv="refresh">` with a delay up to 10 seconds, and tiny pages (under about 4 KB) that only set `window.location`. Redirects built by complex scripts need a real browser and are not followed.

**Can it reach private or internal addresses?** No. Every hop is checked, and loopback, private, link-local, cloud-metadata and internal host names are blocked and reported as `blocked-address`. The connection is pinned to the address that passed the check.

**Is cookie or login data sent?** No cookies are stored or sent, no credentials are used, and the User-Agent says `UrlUnshortenerBot`. Some sites answer a bot differently than a browser; the Actor reports what it received.

### Use with the Apify API, MCP, n8n or Make

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("<username>/url-unshortener").call(run_input={"urls": ["https://bit.ly/", "http://github.com"], "fetchTitle": True})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["url"], "->", row["cleanUrl"], row["hopCount"])
```

JavaScript:

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

const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('<username>/url-unshortener').call({ urls: ['https://bit.ly/', 'http://github.com'] });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((r) => [r.url, r.finalUrl]));
```

The Actor has two small, typed inputs for agents (`urls` is the only required field) and works through the Apify MCP server and the n8n and Make Apify modules: call the Actor with `urls`, then read the dataset.

### Related tools

- HTTP Status Code Checker: Bulk URL, Website & Redirect Chains
- Meta Tags & Open Graph Extractor: Title, SEO, Twitter Cards
- Sitemap Parser & Extractor: Sitemap to CSV, URLs & New Pages

# Actor input Schema

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

The links to expand, one per line (use Bulk edit to paste a long list). Works with bit.ly, t.co, tinyurl.com, ow.ly, lnkd.in, amzn.to, goo.gl-style links and any other URL that redirects. A missing https:// is added and duplicates are removed. Example: https://bit.ly/3abcDEF.

## `urlsText` (type: `string`):

Alternative to the list above: paste a block of links, one per line. Added after the list; duplicates across both are removed. Example: a column copied from a spreadsheet.

## `cleanTracking` (type: `boolean`):

Fill the cleanUrl field with the final URL minus tracking parameters (utm\_\*, fbclid, gclid, msclkid, mc_cid, igshid, Amazon tag and similar) and without the #fragment. finalUrl always keeps the exact URL the redirects ended on.

## `extraTrackingParams` (type: `array`):

Additional query parameter names to strip from cleanUrl, one per line, not case sensitive. Example: ref_campaign, affiliate_id.

## `fetchTitle` (type: `boolean`):

Download the first 256 KB of the final page with one extra GET request and return its <title> in the title field. Slower, so it is off by default.

## `followHtmlRedirects` (type: `boolean`):

Also follow <meta http-equiv="refresh"> redirects and very small pages that only set window.location (interstitials used by some shorteners). Real pages with scripts are never treated as redirects. Needs one extra GET per hop.

## `maxHops` (type: `integer`):

Stop with the status too-many-redirects after this many hops for one URL (1 to 20). Redirect loops are detected earlier and reported as redirect-loop. Example: 10.

## `timeoutSecs` (type: `integer`):

Total time allowed for one URL, all hops included (1 to 120 seconds). A slow URL gets status timeout and still produces a row. Example: 20.

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

URLs resolved in parallel (1 to 50). At most 10 run in parallel against the same website, whatever this is set to. Example: 20.

## `maxUrls` (type: `integer`):

Upper limit of unique URLs resolved in this run (1 to 20,000); it also caps what you can be charged. Extra URLs are skipped and counted in SUMMARY. Example: 1000.

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

Off by default. Use an Apify proxy when a link only opens from a certain country or a site blocks datacenter IPs. Example: {"useApifyProxy": true}.

## Actor input object example

```json
{
  "urls": [
    "http://github.com",
    "https://httpbin.org/redirect/2",
    "https://bit.ly/"
  ],
  "cleanTracking": true,
  "fetchTitle": false,
  "followHtmlRedirects": false,
  "maxHops": 10,
  "timeoutSecs": 20,
  "concurrency": 20,
  "maxUrls": 1000,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

One row per URL: final destination, clean URL, redirect chain, hop count, status and error (all result items of this run, as JSON, CSV, Excel and more).

## `summary` (type: `string`):

SUMMARY record: counts by status, shortener links found, top destination domains, number charged and any notes.

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

Key-value store records of this run (SUMMARY and any other files).

# 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 = {
    "urls": [
        "http://github.com",
        "https://httpbin.org/redirect/2",
        "https://bit.ly/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-done-right/url-unshortener").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 = { "urls": [
        "http://github.com",
        "https://httpbin.org/redirect/2",
        "https://bit.ly/",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("data-done-right/url-unshortener").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 '{
  "urls": [
    "http://github.com",
    "https://httpbin.org/redirect/2",
    "https://bit.ly/"
  ]
}' |
apify call data-done-right/url-unshortener --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-done-right/url-unshortener"
        }
    }
}
```

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/URUPSRFzOwC89TfIR/builds/VY2VNJea0B88dr0Ex/openapi.json
