> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markifact.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Backlinks

> List backlinks pointing to a domain, subfolder or URL from Ahrefs Site Explorer (all backlinks, live only, lost since a date, or the broken backlinks report), with referring page, anchor, Domain Ra...

List backlinks pointing to a domain, subfolder or URL from Ahrefs Site Explorer (all backlinks, live only, lost since a date, or the broken backlinks report), with referring page, anchor, Domain Rating, URL Rating, link attributes and dates. Use ahrefs\_get\_referring\_domains for the domain-level view and ahrefs\_get\_anchors for anchor text.

|                      |                        |
| -------------------- | ---------------------- |
| **App**              | Ahrefs                 |
| **Operation ID**     | `ahrefs_get_backlinks` |
| **Type**             | Action                 |
| **Connection**       | `ahrefs` (required)    |
| **Credits per run**  | Free                   |
| **Agent / MCP tool** | Yes                    |

## Inputs

| Field         | Type                                | Required | Default         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------- | ----------------------------------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `target`      | string                              | Yes      | -               | The domain, subdomain, subfolder or URL to list backlinks for (e.g. example.com, example.com/blog/post).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `mode`        | string or SelectableOption          | No       | `subdomains`    | How to interpret the target: 'subdomains' (domain and all subdomains, default), 'domain' (the exact host only), 'prefix' (every URL starting with the target), or 'exact' (the exact URL only).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `report`      | string or SelectableOption          | No       | `all`           | 'all' lists every backlink (live plus lost, see history); 'broken' lists only backlinks pointing to pages that return errors or redirects.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `history`     | string or SelectableOption          | No       | `all_time`      | 'live' returns only currently live backlinks; 'all\_time' also includes lost backlinks. Ignored for the broken report and when since\_date is set.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `since_date`  | string                              | No       | -               | Include backlinks lost since this date (YYYY-MM-DD) in addition to live ones. Overrides history. Ignored for the broken report.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `aggregation` | string or SelectableOption          | No       | `similar_links` | How to group backlinks: 'similar\_links' (group near-duplicate links, default), '1\_per\_domain' (one link per referring domain), or 'all' (every link).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `metrics`     | array of string or SelectableOption | No       | -               | Columns to return (url\_from is always included). Available for both reports: url\_to, anchor, title, alt, snippet\_left, snippet\_right, domain\_rating\_source, url\_rating\_source, ahrefs\_rank\_source, traffic, traffic\_domain, refdomains\_source, positions, links\_external, links\_internal, is\_dofollow, is\_nofollow, is\_sponsored, is\_ugc, is\_redirect, is\_spam, is\_content, is\_image, is\_text, link\_type, http\_code, first\_seen, first\_seen\_link, last\_seen, last\_visited, languages, page\_type\_source, name\_source, root\_name\_source, name\_target, root\_name\_target, link\_group\_count, url\_redirect, redirect\_code, powered\_by. Only for report 'all': is\_lost, is\_new, lost\_reason, drop\_reason, discovered\_status. Only for report 'broken': http\_code\_target, last\_visited\_target. Ahrefs API unit cost per row: traffic and traffic\_domain cost 10 units, refdomains\_source 5, the rest 1. Defaults to url\_to, anchor, title, domain\_rating\_source, url\_rating\_source, is\_dofollow, link\_type, first\_seen, last\_seen. |
| `filters`     | array of FilterItem                 | No       | -               | Filters on the available columns, e.g. domain\_rating\_source GREATER\_THAN 30 or is\_dofollow EQUALS true. Filter fields count towards the unit cost per row.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `orders`      | array of OrderItem                  | No       | -               | Sort by one or more columns.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `limit`       | integer                             | No       | `100`           | Maximum number of rows to return. Defaults to 100. Your Ahrefs plan caps rows per request (Lite 100, Standard 250, Advanced 500).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

### FilterItem

| Field      | Type                       | Required | Default | Description                                                                                                                                                                             |
| ---------- | -------------------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `field`    | string or SelectableOption | Yes      | -       | The field to filter on, must be one of the current selected metrics or dimensions.                                                                                                      |
| `operator` | string                     | Yes      | -       | The operator to use for filtering. Must be one of the supported values. Use REGEXP\_MATCH to search/filter by multiple OR values like '.*(summer\|holiday).*'                           |
| `value`    | string                     | Yes      | -       | The value to filter by, always as a string: text, a number, or a regex. For IN\_LIST and NOT\_IN\_LIST, pass the values as one comma-separated string such as 'a,b,c', not as an array. |

### OrderItem

| Field       | Type                       | Required | Default | Description                                                                      |
| ----------- | -------------------------- | -------- | ------- | -------------------------------------------------------------------------------- |
| `field`     | string or SelectableOption | Yes      | -       | The field to sort by. must be one of the current selected metrics or dimensions. |
| `direction` | string                     | Yes      | -       | The order to sort by, must be one of 'ASC', 'DESC'                               |

### SelectableOption

| Field   | Type   | Required | Default | Description |
| ------- | ------ | -------- | ------- | ----------- |
| `value` | string | Yes      | -       |             |
| `label` | string | Yes      | -       |             |

## Output

**Type**: `List[Dict]`

Returns one row per backlink with the selected Ahrefs fields: url\_from, url\_to, anchor, title, domain\_rating\_source, url\_rating\_source, traffic, traffic\_domain, is\_dofollow, is\_nofollow, is\_sponsored, is\_ugc, is\_lost, is\_new, link\_type, http\_code, first\_seen, last\_seen and more (http\_code\_target and last\_visited\_target for the broken report).

**Fields**: `url_from`, `url_to`, `anchor`, `title`, `domain_rating_source`, `url_rating_source`, `is_dofollow`, `link_type`, `first_seen`, `last_seen`

**Example**:

```json theme={"dark"}
[
  {
    "url_from": "https://www.example.org/seo-tools",
    "url_to": "https://ahrefs.com/",
    "anchor": "Ahrefs",
    "title": "Best SEO tools",
    "domain_rating_source": 72.0,
    "url_rating_source": 18.0,
    "is_dofollow": true,
    "link_type": "text",
    "first_seen": "2024-03-02T10:15:00Z",
    "last_seen": null
  }
]
```
