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

# 同期スクリーンショット

> `screenshot` エンドポイントはブラウザセッションを実行し、JavaScript を実行して、1 回の同期リクエストで base64 エンコードされた画像を返します。

## はじめに

### ベース URL

```
https://screenshot.cleariflow.com/v1/screenshot
```

### リクエスト例

```bash theme={"system"}
curl -X POST 'https://screenshot.cleariflow.com/v1/screenshot' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://cleariflow.com",
    "capture_full_page": true,
    "export_format": "jpeg"
  }'
```

成功したリクエストは base64 形式のスクリーンショットとメタデータを返します：

```json theme={"system"}
{
  "ok": true,
  "image_base64": "/9j/4AAQSkZJRg...",
  "content_type": "image/jpeg",
  "meta": {
    "elapsed_ms": 4521
  }
}
```

`image_base64` をデコードして JPEG または PNG の生バイトを取得します。

### レンダリングオプション

`render` オブジェクトは、スクリーンショット取得前にブラウザがページを読み込む方法を制御します。すべてのフィールドはオプションです — 省略時はサーバーのデフォルト値が適用されます。

```json theme={"system"}
{
  "render": {
    "wait_until": "networkidle",
    "timeout_ms": 60000,
    "post_load_wait_ms": 2000,
    "ignore_https_errors": false,
    "full_page": true,
    "screenshot_format": "jpeg",
    "user_agent": "Mozilla/5.0 ...",
    "viewport": {
      "width": 1365,
      "height": 768
    }
  }
}
```

| フィールド | 型 | デフォルト | 説明 |
| - | - | - | - |
| `wait_until` | String | `domcontentloaded` | ナビゲーション完了とみなすタイミング。高速な結果には `domcontentloaded`；初期 HTML 後に XHR/fetch でデータを読み込むページには `networkidle`。 |
| `timeout_ms` | Integer | `60000` | ページ読み込み待機の最大時間（ミリ秒）。 |
| `post_load_wait_ms` | Integer | `0` | 取得前の `wait_until` 後の追加遅延（ミリ秒）。アニメーションや lazy-load コンテンツに有用。 |
| `ignore_https_errors` | Boolean | `false` | `true` の場合、ターゲットページの TLS 証明書エラーを無視します。 |
| `full_page` | Boolean | `true` | `true` の場合、スクロール可能なページ全体の高さをキャプチャします。 |
| `screenshot_format` | String | `jpeg` | 出力形式: `jpeg` または `png`。 |
| `user_agent` | String | — | ブラウザセッション用のカスタム User-Agent 文字列。 |
| `viewport` | Object | `1365×768` | ピクセル単位の `width` と `height` による viewport サイズ。 |

### 便利フィールド

これらのトップレベルフィールドは、後方互換性とシンプルなリクエストのために `render` と `actions` にマージされるエイリアスです：

| フィールド | マップ先 | 説明 |
| - | - | - |
| `capture_full_page` | `render.full_page` | フルページキャプチャの切り替え。 |
| `width` / `height` | `render.viewport` | ピクセル単位の viewport 寸法。 |
| `delay` | `render.post_load_wait_ms` | 取得前の遅延（**秒**）。 |
| `export_format` | `render.screenshot_format` | `jpeg` または `png`。 |
| `user_agent` | `render.user_agent` | カスタム User-Agent。 |
| `css_injection` | `inject_css` アクション | `inject_css` アクションがない場合に取得前に注入される CSS。 |

フラットフィールドの例：

```bash theme={"system"}
curl -X POST 'https://screenshot.cleariflow.com/v1/screenshot' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://cleariflow.com",
    "width": 1280,
    "height": 720,
    "delay": 2,
    "export_format": "png"
  }'
```

### リソースオプション

`resources` オブジェクトは、キャプチャ中にブラウザが読み込むアセットタイプを制御します。重いアセットをブロックすると、視覚的な忠実度が許す場合にリクエストが高速化されます。

```json theme={"system"}
{
  "resources": {
    "block": ["images", "fonts", "media"]
  }
}
```

| 値 | ブロック対象 |
| - | - |
| `images` | 画像（`<img>`、CSS 背景） |
| `fonts` | Web フォント |
| `media` | 動画・音声ストリーム |

### レガシー GET エンドポイント

`GET /v1/` は JSON の代わりに生の画像バイト（JPEG または PNG）を返します。パラメータはクエリ文字列で渡します：

```
https://screenshot.cleariflow.com/v1/?api_key=YOUR_UNIQUE_API_KEY&url=https://cleariflow.com&capture_full_page=true&export_format=jpeg
```

サポートされるクエリパラメータ: `url`, `api_key`, `session_id`, `fingerprint`, `capture_full_page`, `width`, `height`, `delay`, `css_injection`, `user_agent`, `export_format`.

### リクエストパラメータ

**url** `String` *required*

キャプチャ対象の URL。公開 HTTP または HTTPS URL である必要があります。localhost およびプライベート IP アドレスへのリクエストは SSRF 保護によりブロックされます。

**api\_key** `String` *required*

固有の API キー。

**session\_id** `String`

複数リクエスト間でブラウザ状態（Cookie、local storage）を再利用するためのオプションのセッション識別子。

**fingerprint** `String`

ブラウザフィンガープリントプリセット。サポート値: `desktop_en_us`, `desktop_ru_ru`, `mobile_en_us`.

**render** `Object`

ブラウザセッションのレンダリングおよびキャプチャオプション。

**render.wait\_until** `String`

ナビゲーション完了とみなすタイミング。値: `domcontentloaded`, `networkidle`. デフォルト: `domcontentloaded`.

**render.timeout\_ms** `Integer`

ページ読み込み待機の最大時間（ミリ秒）。デフォルト: 60000.

**render.post\_load\_wait\_ms** `Integer`

ページ読み込みイベント後、キャプチャ前の追加遅延（ミリ秒）。

**render.ignore\_https\_errors** `Boolean`

`true` の場合、ターゲットページの TLS 証明書エラーを無視します。

**render.full\_page** `Boolean`

`true` の場合、スクロール可能なページ全体をキャプチャします。デフォルト: `true`.

**render.screenshot\_format** `String`

出力形式: `jpeg` または `png`. デフォルト: `jpeg`.

**render.user\_agent** `String`

ブラウザセッション用のカスタム User-Agent。

**render.viewport** `Object`

ピクセル単位の `width` と `height` による viewport サイズ。

**resources** `Object`

リソース読み込み制御。

**resources.block** `Array`

ブロックするリソースタイプ。サポート値: `images`, `fonts`, `media`.

**actions** `Array`

キャプチャ前に実行するブラウザアクションの順序付きリスト。各アクションは `type` フィールドを持つオブジェクトです。

**actions\[].type** `String` *required*

アクションタイプ。サポート値: `wait`, `wait_for`, `click`, `type`, `scroll`, `inject_css`.

**actions\[].selector** `String`

`wait_for`、`click`、`type` アクション用の CSS セレクタ。

**actions\[].text** `String`

`type` アクションで入力するテキスト。

**actions\[].css** `String`

`inject_css` アクション用の CSS 文字列。

**actions\[].to** `String`

`scroll` アクションのスクロール先（例: `bottom`）。

**actions\[].wait\_ms** `Integer`

`wait` アクションの持続時間（ミリ秒）。

**cookies** `Array`

ナビゲーション前に注入する Cookie。各 Cookie オブジェクトには `name` と `value` が必要；オプション: `domain`, `path`.

**capture\_full\_page** `Boolean`

`render.full_page` の便利エイリアス。

**width** `Integer`

`render.viewport.width` の便利エイリアス。

**height** `Integer`

`render.viewport.height` の便利エイリアス。

**delay** `Integer`

キャプチャ前の遅延（秒）。`render.post_load_wait_ms` にマップされます。

**css\_injection** `String`

`actions` に `inject_css` がない場合に `inject_css` アクション経由で注入される CSS。

**export\_format** `String`

`render.screenshot_format` の便利エイリアス。値: `jpeg`, `png`.

### レスポンスパラメータ

API レスポンスは汎用的で軽量な [JSON 形式](https://www.json.org/json-en.html) で返されます。

**ok** `Boolean`

スクリーンショットが正常に完了したかどうか。

**image\_base64** `String`

Base64 エンコードされた画像データ。デコードして JPEG または PNG の生バイトを取得します。

**content\_type** `String`

画像の MIME タイプ（`image/jpeg` または `image/png`）。

**meta** `Object`

経過時間（ミリ秒）を含むキャプチャに関するメタデータ。

**error** `Object`

`ok` が `false` の場合のエラー詳細。


## OpenAPI

````yaml openapi/screenshot.json POST /v1/screenshot
openapi: 3.0.3
info:
  title: Cleariflow Website Screenshot API
  version: 1.0.0
  description: Capture website screenshots via GET or POST.
servers:
  - url: https://screenshot.cleariflow.com
security: []
paths:
  /v1/screenshot:
    post:
      summary: Synchronous screenshot (JSON response with base64 image)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScreenshotRequest'
      responses:
        '200':
          description: Screenshot result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScreenshotResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '429':
          description: Rate limit exceeded
components:
  schemas:
    ScreenshotRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
        api_key:
          type: string
        session_id:
          type: string
        fingerprint:
          type: string
        render:
          $ref: '#/components/schemas/RenderOptions'
        resources:
          $ref: '#/components/schemas/ResourceOptions'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/Action'
        cookies:
          type: array
          items:
            $ref: '#/components/schemas/Cookie'
        capture_full_page:
          type: boolean
          description: Convenience alias for render.full_page
        width:
          type: integer
          description: Convenience alias for render.viewport.width
        height:
          type: integer
          description: Convenience alias for render.viewport.height
        delay:
          type: integer
          description: Delay in seconds; mapped to render.post_load_wait_ms
        css_injection:
          type: string
          description: Injects CSS via inject_css action when not already present
        user_agent:
          type: string
          description: Convenience alias for render.user_agent
        export_format:
          type: string
          enum:
            - jpeg
            - png
          description: Convenience alias for render.screenshot_format
    ScreenshotResponse:
      type: object
      properties:
        ok:
          type: boolean
        image_base64:
          type: string
        content_type:
          type: string
        meta:
          type: object
          additionalProperties: true
        error:
          type: object
          additionalProperties: true
    RenderOptions:
      type: object
      properties:
        wait_until:
          type: string
          enum:
            - domcontentloaded
            - networkidle
        timeout_ms:
          type: integer
        post_load_wait_ms:
          type: integer
        ignore_https_errors:
          type: boolean
        full_page:
          type: boolean
        screenshot_format:
          type: string
          enum:
            - jpeg
            - png
        user_agent:
          type: string
        viewport:
          $ref: '#/components/schemas/ViewportOptions'
    ResourceOptions:
      type: object
      properties:
        block:
          type: array
          items:
            type: string
            enum:
              - images
              - fonts
              - media
    Action:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - wait
            - wait_for
            - click
            - type
            - scroll
            - inject_css
        selector:
          type: string
        text:
          type: string
        attr:
          type: string
        to:
          type: string
        wait_ms:
          type: integer
        css:
          type: string
    Cookie:
      type: object
      required:
        - name
        - value
      properties:
        path:
          type: string
        value:
          type: string
        name:
          type: string
        domain:
          type: string
    ViewportOptions:
      type: object
      properties:
        width:
          type: integer
        height:
          type: integer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.