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
paper string output: "pdf" の場合、このペーパーサイズ (A4A3A5LetterLegalTabloidLedger) のドキュメントにマージン付きでページネーションします。単一のフル高さキャプチャの代わりに。
async boolean キューに追加して 202 を返します。
webhookUrl string 完了時に署名されたコールバック (async を含みます)。
notifyEmail 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"])

大きなページは遅くなる可能性があります。その場合は、非同期 + ウェブフックを使用してください。