# Intercept XHR Request

Source: https://docs.scrappey.com/docs/intercept-xhr

> Use `interceptFetchRequest` to capture and return the responses of specific `fetch()` or XHR requests made during a page load.

## Command

`"interceptFetchRequest"` — monitor network activity and return specific XHR/fetch responses. URL matching uses `.includes()`; if more than one request matches the string, all are returned as an array.

## Parameters

| Parameter | Type | Required | Description |
| ----------------------- | ------ | -------- | ---------------------------------------------------------------------- |
| `interceptFetchRequest` | array | Yes | List of strings to match against outgoing request URLs |
| `url` | string | Yes | URL to be loaded and monitored |
| `browserActions` | array | No | Browser interactions (e.g., captcha solving) to perform during request |

## Example

```bash
curl -X POST "https://publisher.scrappey.com/api/v1?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "request.get",
    "url": "https://ahrefs.com/website-authority-checker/?input=ahrefs.com",
    "interceptFetchRequest": [
      "https://ahrefs.com/v4/stGetFreeWebsiteOverview"
    ],
    "browserActions": [
      {
        "type": "solve_captcha",
        "captcha": "turnstile"
      }
    ]
  }'
```

You will receive an array of JSON responses from all fetch/XHR requests that matched the string(s) provided.

## Notes

Great for:

- Sites that dynamically load content via JavaScript
- Skipping complex DOM parsing by getting direct API responses
- Interacting with protected or hidden endpoints

Leverage `interceptFetchRequest` to unlock rich backend data directly from dynamic web apps.
