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

# Page Load Settings

> Control when screenshots are captured

## Page Load Settings

Control when the screenshot is captured during page load. Some websites need more time to fully render content before capturing.

## Wait condition

The `waitUntil` parameter determines when to consider the page "loaded" before capturing:

| Condition          | Description                                              | Best For                  |
| ------------------ | -------------------------------------------------------- | ------------------------- |
| `load`             | Wait for full page load event                            | Simple static pages       |
| `domcontentloaded` | Wait until HTML is fully parsed                          | Pages with fast rendering |
| `networkidle0`     | Wait until no network connections (at least 0.5s)        | Pages with minimal AJAX   |
| `networkidle2`     | Wait until at most 2 network connections (at least 0.5s) | Most pages (default)      |

## Using wait conditions

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&waitUntil=domcontentloaded" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    waitUntil: 'domcontentloaded'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'waitUntil' => 'domcontentloaded'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("waitUntil", "domcontentloaded")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

### Choosing the right condition

* **networkidle2** (default) - Best for most websites. Waits for page to be mostly loaded.
* **networkidle0** - Use for pages with minimal JavaScript or known tracking scripts.
* **domcontentloaded** - Use for fast-capturing when content renders quickly.
* **load** - Use only for simple, static pages without dynamic content.

## Timeout

The `timeout` parameter sets the maximum wait time before aborting the screenshot.

| Value   | Description            |
| ------- | ---------------------- |
| Minimum | 1000ms (1 second)      |
| Default | 30000ms (30 seconds)   |
| Maximum | 120000ms (120 seconds) |

## Setting timeout

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&timeout=60000" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    timeout: '60000'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'timeout' => '60000'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("timeout", "60000")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

### When to adjust timeout

* **Increase timeout** for slow-loading pages, heavy content, or complex web applications
* **Decrease timeout** for fast, lightweight pages to fail quickly on errors

## Combining settings

For complex pages, combine wait condition with custom timeout:

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&waitUntil=networkidle0&timeout=60000" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    waitUntil: 'networkidle0',
    timeout: '60000'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'waitUntil' => 'networkidle0',
    'timeout' => '60000'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("waitUntil", "networkidle0")
      params.Set("timeout", "60000")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Troubleshooting

| Problem                        | Solution                                   |
| ------------------------------ | ------------------------------------------ |
| Screenshot is blank/incomplete | Increase timeout or use `networkidle2`     |
| Screenshot takes too long      | Use `domcontentloaded` or decrease timeout |
| Dynamic content not visible    | Use `networkidle0` or increase timeout     |

## Parameters

| Parameter   | Type   | Default        | Description                                                                 |
| ----------- | ------ | -------------- | --------------------------------------------------------------------------- |
| `waitUntil` | string | `networkidle2` | When to capture: `load`, `domcontentloaded`, `networkidle0`, `networkidle2` |
| `timeout`   | number | `30000`        | Maximum wait time in milliseconds (1000-120000)                             |

## See also

* [Full Page Screenshots](/guides/screenshots/full-page) - Capture entire page length
* [Viewport Presets](/guides/screenshots/viewports) - Device sizes and dimensions
