MostlyRender

スクリーンショット

POST /v1/screenshots は、テンプレートを必要とせず、任意の公開ウェブページを画像またはPDFとしてキャプチャします。

# リクエスト

bash
curl https://api.mostlyrender.com/v1/screenshots \
  -H "Authorization: Bearer mr_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://stripe.com",
    "fullPage": true,
    "output": "png"
  }'
フィールド 注記
url string 必須。 公開 http(s) URL。
width integer ビューポート幅。デフォルト 1200(16–2400)。
height integer ビューポート高さ。デフォルト 630(16–2400)。
fullPage boolean スクロール全体の高さをキャプチャ。デフォルト false
scale number デバイススケールファクター(Retina)。最大 3
output string png(デフォルト)、jpegwebp、または pdf
async boolean キューに追加して 202 を返却。
webhookUrl string 完了時の署名付きコールバック(async を意味)。

# レスポンス

json
{
  "id": "shot_abc123",
  "url": "https://img.mostlyrender.com/mostlyrender/screenshots/shot_abc123.png",
  "output": "png"
}

# URL安全性

スクリーンショットは 公開 http(s) URLのみを受け入れます。プライベート範囲、ループバック、リンクローカル、またはクラウドメタデータホストへのリクエストは 400 で拒否されます。ガードはリダイレクト後も再チェックするため、公開URLは内部URLにバウンスできません。

# SDK

python
shot = mr.screenshot("https://stripe.com", full_page=True)
print(shot["url"])

大規模なページは遅い可能性があります。これらの場合は、async + webhooks を使用してください。