原型 · 预览版:收录官方注册中心里的全部服务器,每 30 分钟同步一次。使用 Google 登录即可撰写评价。原型 · 每 30 分钟更新
PopNx MCP为使用 AI 的人准备的 MCP 服务器 · 用大白话讲清楚

API Screenshot

作者:matbrons版本 0.1.2i★ 0i电脑或云端官方网站 ↗
注册名称io.github.matbrons/api-screenshot

安装方法

What it does

Clean full-page screenshots of real sites: cookie banners, pop-ups, chat widgets and ads removed.

  • Connects 电脑或云端
  • Account or key Cloud: Needs Authorization · Local: Needs API_KEY
  • Category 网页与浏览器

可搭配使用

教 AI 做这类工作的 Skill,可与本项一起使用

timesfm

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

作者:google-research★ 35,6291 个 skill

Skill · 操作手册

Shadowbroker

Open-source intelligence for the global theater. Track everything from the corporate/private jets of the wealthy, and spy satellites, to seismic events in one unified interface. Hook an AI agent up to have it parse through data and find previously unseen correlations. The knowledge is available to…

作者:BigBodyCobain★ 11,6021 个 skill

Skill · 操作手册

google-maps-scraper

scrape data from Google Maps. Extracts data such as the name, address, phone number, website URL, rating, reviews number, latitude and longitude, reviews,email and more for each place

作者:gosom★ 8,2091 个 skill

Skill · 操作手册

为什么排在这里

列表按使用分(满分 100)排序,由以下部分组成

热度0/80GitHub 星标或每周下载量:较大的计 60,较小的计 20
新鲜度12/1230 天内有发布或代码更新得满分
仍在响应0/8上次检查时云端端点有响应
使用分12/100

质量: 基础检查通过 3/3 项(仅展示,不用于排序) · 上升势头: 暂无数据 (只用于“上升中”标签)

安装

选择你使用的 AI 应用,然后复制设置。

用一句话让 AI 帮你安装

请帮我安装 API Screenshot。按照 https://mcp.popnx.com/i/matbrons-api-screenshot.md 操作,先把命令给我看,等我同意后再运行。

粘贴到能在你电脑上工作的 AI(如 Claude Code、Cursor)。它会读取我们的步骤,先给你看命令,等你同意。无需密钥,无需注册。 · 查看 AI 会读取的全文

通过 3/3 项检查 · 你的提问会经过开发者的服务器({host}) · ✓ 命令已检查 2026年11月16日

第一步:你用哪个 AI?

选择你用的应用,步骤会显示在下方。

可连接 Claude,但需要先准备

需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的 · 在 claude.ai 或桌面应用设置一次,即可在聊天中使用 · 免费账户可添加 1 个 · Team/Enterprise 方案由所有者(Owner)添加

  1. 注册并创建 API Screenshot 的密钥

    打开开发者网站,注册账户并创建 API 密钥,下一步要用。价格和免费方案请看开发者网站。

    打开 API Screenshot 网站 ↗

  2. 打开 Claude 的 Connectors 页面

    CustomizeConnectors

    CustomizeConnectors1Add2https://…3Add4
  3. 点击“Add” → “Custom” → “Web”,填写这 2 项

    把这里的内容复制到 Claude 中同名的输入框,然后点击 Continue

    Name · 名称API Screenshot
    Remote MCP server URL · 地址https://{host}/mcp

    在 Request headers 下添加这个名称和值

    Header 名称Authorization
    值Bearer <在这里粘贴你的密钥>

    只把密钥粘贴到应用的输入框里,不要粘贴到聊天中或发给任何人

    在 Claude 检测到的登录设置页点击 Continue · Authentication 按作者说明选择(Sign in now、Sign in when needed 或 No sign in),然后点击 Add

  4. 在聊天中开启

    +ConnectorsAPI Screenshot

  5. 试一试

    用 API Screenshot 告诉我你能帮我做什么,然后做一件给我看

    ✓ 如果 Claude 说正在使用 API Screenshot,或回答中出现 API Screenshot 的工具名称,就表示连接成功

菜单名称已于 2026年11月11日 对照 Anthropic 帮助页面核实 · 你的界面可能因版本略有不同

ChatGPT 暂时无法连接 API Screenshot

API Screenshot 连接时需要你自己的密钥,但 OpenAI 帮助页面只说明了 OAuth 登录,没有我们能核实的填密钥方式

你可以改用这些方式

A · 使用能连接 API Screenshot 的应用

  • 需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的 · 在 claude.ai 或桌面应用设置一次,即可在聊天中使用 · 免费账户可添加 1 个 · Team/Enterprise 方案由所有者(Owner)添加
  • 需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的
  • 需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的
  • 需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的

B · 网页与浏览器 类中能连接 ChatGPT 的其他服务器

从同类中使用较多的里挑选,仅限用地址即可连接、无需密钥的

可连接 Claude Code,但需要先准备

需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的

  1. 注册并创建 API Screenshot 的密钥

    打开开发者网站,注册账户并创建 API 密钥,下一步要用。价格和免费方案请看开发者网站。

    打开 API Screenshot 网站 ↗

  2. 打开终端

    Mac:按 Command+空格,输入 Terminal · Windows:打开 PowerShell

  3. 粘贴这条命令并按 Enter

    claude mcp add --transport http --scope user api-screenshot 'https://{host}/mcp' --header 'Authorization: Bearer {api_key}'

    按 Enter 前,把“your-value”改成你的密钥

    只把密钥粘贴到应用的输入框里,不要粘贴到聊天中或发给任何人

  4. 在 Claude Code 中输入 /mcp

    应能看到 API Screenshot 在列表中并显示已连接

  5. 试一试

    用 API Screenshot 告诉我你能帮我做什么,然后做一件给我看

    ✓ 如果 Claude Code 说正在使用 API Screenshot,或回答中出现 API Screenshot 的工具名称,就表示连接成功

菜单名称已于 2026年11月11日 对照 Anthropic 帮助页面核实 · 你的界面可能因版本略有不同

可连接 Cursor,但需要先准备

需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的

  1. 注册并创建 API Screenshot 的密钥

    打开开发者网站,注册账户并创建 API 密钥,下一步要用。价格和免费方案请看开发者网站。

    打开 API Screenshot 网站 ↗

  2. 打开 Cursor 的 MCP 设置文件

    ~/.cursor/mcp.json

    粘贴这些设置,填写空着的值并保存

    {
      "mcpServers": {
        "api-screenshot": {
          "url": "https://{host}/mcp",
          "headers": {
            "Authorization": "Bearer {api_key}"
          }
        }
      }
    }
  3. 填写你的密钥

    在 API Screenshot 的设置中,Authorization 还是空的,填入你的密钥并保存

    只把密钥粘贴到应用的输入框里,不要粘贴到聊天中或发给任何人

  4. 在 Cursor 中以 Agent 模式打开 AI 聊天

  5. 试一试

    用 API Screenshot 告诉我你能帮我做什么,然后做一件给我看

    ✓ 如果 Cursor 说正在使用 API Screenshot,或回答中出现 API Screenshot 的工具名称,就表示连接成功

菜单名称已于 2026年11月11日 对照 Cursor 帮助页面核实 · 你的界面可能因版本略有不同

可连接 VS Code,但需要先准备

需要 API Screenshot 的密钥(在开发者网站创建) · 地址中有 {…} 部分,需要先改成你自己的

  1. 注册并创建 API Screenshot 的密钥

    打开开发者网站,注册账户并创建 API 密钥,下一步要用。价格和免费方案请看开发者网站。

    打开 API Screenshot 网站 ↗

  2. 打开 VS Code 的 MCP 设置文件

    MCP: Open User Configuration

    粘贴这些设置,填写空着的值并保存

    {
      "servers": {
        "api-screenshot": {
          "type": "http",
          "url": "https://{host}/mcp",
          "headers": {
            "Authorization": "Bearer {api_key}"
          }
        }
      }
    }
  3. 填写你的密钥

    在 API Screenshot 的设置中,Authorization 还是空的,填入你的密钥并保存

    只把密钥粘贴到应用的输入框里,不要粘贴到聊天中或发给任何人

  4. 在 VS Code 中以 Agent 模式打开 AI 聊天

  5. 试一试

    用 API Screenshot 告诉我你能帮我做什么,然后做一件给我看

    ✓ 如果 VS Code 说正在使用 API Screenshot,或回答中出现 API Screenshot 的工具名称,就表示连接成功

菜单名称已于 2026年11月11日 对照 VS Code 帮助页面核实 · 你的界面可能因版本略有不同

其他支持 MCP 的应用(如 Windsurf、Zed、Gemini CLI)添加方式各不相同,请在应用列表中查看

查看所有支持 MCP 的应用 →

通过网页连接的应用使用的地址

地址https://{host}/mcp

JSON 设置在下方“开发者专用”中

卡住了?问问正在用 API Screenshot 的人💬 讨论 →
开发者专用:终端命令和 JSON 设置

通过网页连接

Claude Code

claude mcp add --transport http --scope user api-screenshot 'https://{host}/mcp' --header 'Authorization: Bearer {api_key}'

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "api-screenshot": {
      "url": "https://{host}/mcp",
      "headers": {
        "Authorization": "Bearer {api_key}"
      }
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "api-screenshot": {
      "type": "http",
      "url": "https://{host}/mcp",
      "headers": {
        "Authorization": "Bearer {api_key}"
      }
    }
  }
}

安装在电脑上

Claude Code

claude mcp add --scope user api-screenshot --env API_KEY=your-value -- docker run -i --rm -e API_KEY ghcr.io/matbrons/api-screenshot:0.1.2

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "api-screenshot": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "API_KEY",
        "ghcr.io/matbrons/api-screenshot:0.1.2"
      ],
      "env": {
        "API_KEY": "your-value"
      }
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "api-screenshot": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "API_KEY",
        "ghcr.io/matbrons/api-screenshot:0.1.2"
      ],
      "env": {
        "API_KEY": "your-value"
      }
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "api-screenshot": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "API_KEY",
        "ghcr.io/matbrons/api-screenshot:0.1.2"
      ],
      "env": {
        "API_KEY": "your-value"
      }
    }
  }
}

需要你填写的值

  • API_KEY 机密 必填 env
    每个请求都必须携带的密钥,长度至少 16 个字符。生成方法:openssl rand -hex 32
    查看英文原文Key every request must carry, 16 characters or more. Make one with: openssl rand -hex 32
  • PORT env
    API 监听的端口
    查看英文原文Port the API listens on
  • Authorization 机密 必填 HTTP header

说明为自动翻译,变量名保持原样;不确定时请查看原文。

这些设置是根据作者在注册中心的条目生成的。如果 README 的写法不同,请以 README 为准。

一览

每周下载量i
不在 npm/PyPI 上
连接方式
电脑或云端
传输方式
streamable-http
最新版本i
0.1.2
发布到注册中心i
2026年11月16日
代码最后更新i
2026年11月16日
最近检查
2026年11月16日
作者
matbrons
软件包
oci: ghcr.io/matbrons/api-screenshot:0.1.2
注册状态
活跃

哪些应用可以使用它

依据这个服务器的连接方式和各应用自己的文档,检查于 2026年11月10日。

通过互联网连接,适用于

ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatOpen WebUIRaycast

在你的电脑上运行,适用于

ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast

全部应用及其优缺点 →

它能做什么

这个地址需要填入你自己的值,所以我们无法替你读取工具列表。

基础检查i

我们检查的是任何人都能看到的信息;我们没有阅读代码。不适用的检查项不计入总数。 · 检查于 2026年11月19日

  • ✓ 通过

    作者与仓库一致

    注册名称已通过 GitHub 账户 matbrons 验证,该账户拥有此仓库

  • ✓ 通过

    仍在维护

    代码最后更新于3天前

  • ✓ 通过

    有许可证

    使用 MIT

  • – 不适用

    端点有响应

    这个地址需要填入你自己的账户信息,所以我们无法替你检查

  • – 不适用

    使用 OAuth 登录

    这个地址需要填入你自己的账户信息,所以我们无法替你检查

  • … 尚未检查

    工具描述中没有隐藏指令

    尚未检查;我们会在检查端点时读取工具列表

已公开的漏洞(OSV.dev)

未检查:只能检查标明版本的 npm 和 PyPI 包

我们检查什么 → · JSON

作者:申请重新检查或报告信息错误
给作者:在 README 中加徽章

如果你是作者,可把这段代码贴到 README。徽章会链接回本页。

[![Featured on PopNx MCP](https://mcp.popnx.com/badge/matbrons-api-screenshot.svg)](https://mcp.popnx.com/en/servers/matbrons-api-screenshot)

讨论

提问、分享技巧或报告无法使用。按“有帮助”数量排序。

还没有帖子,欢迎第一个提问或分享。

此处内容由用户撰写,不代表 PopNx 团队。

登录后发帖

用户评价

还没有评价

登录后写评价

与“网页与浏览器”中的其他服务器比较i

  • 星标数多于此分类中其他 1613 个服务器的 0%
  • 发布到注册中心的时间比此分类中其他 1613 个服务器的 88% 更新
  • 基础检查结果等于或优于此分类中其他 1613 个服务器的 99%

与注册中心里这个分类中所有活跃的服务器比较。只有当发布者拥有该仓库时,星标数才计入。

常见问题

API Screenshot 安全吗?

它在 3 项适用的基础检查中通过了 3 项。我们没有阅读代码。在添加密钥或令牌之前,请先看看这个服务器要求哪些权限,并使用只具备所需权限的密钥。

它需要哪些密钥或代码?

你需要填写:Authorization, API_KEY

它在我的电脑上运行还是在云端?

两种方式都可以:安装在你的电脑上,或者连接云端版本。

它还在维护吗?

GitHub 仓库最后更新于3天前,最新版本(0.1.2)于3天前进入注册中心。

哪些应用可以使用它?

支持 MCP 的应用,例如 Claude Desktop、Claude Code、Cursor 和 VS Code。它通过 URL 连接,因此也能用于接受远程 MCP 的应用,例如网页版 ChatGPT(Business 及以上为完整 MCP;Pro 为只读)。

有什么可以替代它?

同一分类中有:Browser Use, changedetection.io (official), Apify MCP Server, Pomerado, Actionbook

功能相近的其他选择

同一分类、其他作者、命令已通过检查。官方的排在前面,再按星标排序。

如何看卡片:↓ 每周下载量i★ GitHub 星标i三大支柱:评价 · 检查 · 使用情况i更新 = 最新版本发布到注册中心的时间i

Browser Use

Browser agents and stealth cloud browsers for AI: run web tasks, fill forms, extract data.

作者:browser-use广泛使用↓ 167.3万/周★ 12.1万29天前更新

电脑或云端✓ 服务方 · browser-use.com

Apify MCP Server

Extract data from any website with thousands of scrapers, crawlers, and automations on Apify Store ⚡

作者:apify广泛使用★ 1.7万前天更新

在云端运行✓ 服务方 · apify.com

Pomerado

Connect your agents to any website. The cheaper, faster and more reliable alternative to browser use

作者:Pomerado正在增长★ 1798昨天更新

在云端运行✓ 服务方 · pomerado.ai

Actionbook

Let your AI agent operate any website through a real, logged-in browser session.

作者:actionbook正在增长★ 163131天前更新

在云端运行✓ 服务方 · actionbook.app
与相似项目对比
本项
API Screenshot
Browser Usechangedetection.io (official)Apify MCP ServerPomeradoActionbook
运行位置云端或安装在电脑上都可以云端或安装在电脑上都可以在云端运行,无需安装在云端运行,无需安装在云端运行,无需安装在云端运行,无需安装
需要密钥是是否是否否
可在 Claude 中按 + 添加否是否否否否
基础检查3/35/53/34/44/44/4
许可证MITMITApache-2.0MITMITApache-2.0
价格登记中未列出费用登记中未列出费用登记中未列出费用登记中未列出费用登记中未列出费用登记中未列出费用

作者的 README

打开 README

按原文从作者的仓库复制。PopNx MCP 没有审查或背书其内容。HTML、图片和脚本已被移除。链接会离开本站。

api-screenshot

A screenshot API you run yourself. It takes full-page shots of real sites with the cookie banners, pop-ups, chat widgets and ads removed. It runs on your own Cloudflare account or on any server with Docker.

Examples and docs: apiscreenshot.com. Measured: how many shots Cloudflare's free plan gives and what a server needs to run it.

curl -H "Authorization: Bearer $API_KEY" \

"https://api-screenshot.your-subdomain.workers.dev/screenshot?url=https://www.theguardian.com&full_page=true" -o shot.png

  • Cookie banners, pop-ups, chat widgets and ads removed by default.
  • A captcha, bot check or error page comes back as an error that says so, never as a picture of it.
  • Safe to put on the internet: its own API key, a guard against requests to private addresses, and limits.
  • One API, on your Cloudflare account or on any server with Docker.

Contents: Run it (Cloudflare, your own server, safe by default) · Use it (JSON, signed URLs, caching, options, errors) · Use it from an AI agent · Settings · Ads, trackers and filter lists · Sites that block bots (retries) · Safety · Limits · Develop

Run it

On Cloudflare

The button asks you to sign in to Cloudflare and connect GitHub, then copies this repo to your GitHub account and deploys it to your Cloudflare account. It asks for one secret, API_KEY: paste a long random string, for example from openssl rand -hex 32, and keep it. Your API is then at https://api-screenshot. .workers.dev.

Or from a clone:

git clone https://github.com/matbrons/api-screenshot && cd api-screenshot

npm install npx wrangler login npx wrangler deploy API_KEY=$(openssl rand -hex 32); echo "Your API key: $API_KEY" echo "$API_KEY" | npx wrangler secret put API_KEY

On a new account, the first deploy asks you to pick your workers.dev subdomain. It also creates the KV namespace for the cache and writes its id into wrangler.jsonc, so that file shows as changed afterwards; keep the change. To check it all works (this takes one real shot):

APISHOT_TEST_URL=https://api-screenshot.<your-subdomain>.workers.dev APISHOT_TEST_KEY=$API_KEY ops/watch.sh

It uses Browser Rendering, which the free Workers plan includes with a daily limit (see Limits).

On your own server
API_KEY=$(openssl rand -hex 32); echo "Your API key: $API_KEY"

docker run -d --restart unless-stopped -p 3000:3000 -e API_KEY="$API_KEY" ghcr.io/matbrons/api-screenshot

The image runs on amd64 and arm64. It is published when a version is tagged, so it appears after the first release. To build it yourself instead: docker build -t api-screenshot .

Or without Docker, with Node 22.19 or newer and Chrome or Chromium installed:

npm install

API_KEY=$(openssl rand -hex 32); echo "Your API key: $API_KEY" API_KEY="$API_KEY" HOST=127.0.0.1 npm start

It finds Chrome or Chromium on its own; set CHROME_PATH if it doesn't. HOST=127.0.0.1 keeps it to your own machine; leave it out on a server, where it listens on every address.

The server path uses a real Chromium. Whether it gets past more bot walls than the Worker depends mostly on your server's IP address: see Sites that block bots.

Safe by default

A screenshot API on a public URL lets anyone spend your browser time. So until API_KEY (or SIGNING_SECRET, for signed URLs) is set, every screenshot request is refused with not_configured, and so is a key shorter than 16 characters or one copied from an example. If you really want it open, for example on a private network, set ALLOW_PUBLIC_ACCESS=true.

Use it

# GET with query options

curl -H "Authorization: Bearer $API_KEY" \ "http://localhost:3000/screenshot?url=https://example.com&full_page=true&format=jpeg" -o shot.jpg

POST with a JSON body

curl -X POST http://localhost:3000/screenshot \ -H "Authorization: Bearer $API_KEY" -H "content-type: application/json" \ -d '{"url": "https://example.com", "viewport_width": 390, "viewport_mobile": true}' -o shot.png

The key can also go in an X-API-Key header. It is never taken from the URL, where it would end up in logs and browser history: a request with access_key in the query is refused. To put a shot in an tag or a link, use a signed URL.

A shot comes back as the image (or PDF) itself, with these headers:

HeaderValue
x-final-urlThe URL after redirects
x-target-statusThe HTTP status the site answered with
x-removed-elementsHow many things were removed from the shot: the cookie banner, whether it was answered or hidden, plus each pop-up, backdrop, chat widget or ad that was showing. A banner and its own parts count as one. 0 when there was nothing to remove.
x-consent-managerThe consent tool behind the cookie banner that was removed (see below). Not sent when no banner was removed.
x-page-heightThe page's full height in CSS pixels
x-truncatedtrue when the shot was cut off: the page (or the selector element) was taller than full_page_max_height, or than 16384 device pixels (see Limits)
x-cacheHIT when the shot came from the cache, MISS when it was taken now and kept, BYPASS when the cache wasn't read (fresh, or caching off). See Caching.
ageOn a HIT: seconds since the shot was taken
x-overlay-remainingcookie_banner or popup when one is still on screen in the shot, after every attempt to remove it. Not sent when the shot is clean.

x-consent-manager is one of:

  • The tool's name, for the common ones: OneTrust, Cookiebot, Didomi, Usercentrics, Sourcepoint, TrustArc, Quantcast, consentmanager, CookieYes, Complianz, iubenda, Osano, Shopify and others.
  • For a site with a banner of its own, the name of autoconsent's rule for it, usually the site (airbnb).
  • generic: a banner recognised by its look and words, not by a known tool.

Before the shot, a last check looks for a cookie banner or pop-up that is still covering part of the screen. If it finds one, it presses Escape, then the banner's reject or close button (never accept), and cleans up again. One that survives all that is left in the shot and named in x-overlay-remaining, so you can retry or flag it. A site's own sticky header or menu doesn't count, even when it has a "Sign up" link.

JSON and page details

With response_type=json the answer is JSON instead of the file: the page's details plus the image or PDF in base64. response_type=metadata gives the details alone and skips the shot, which is quicker.

{

"url": "https://example.com/", "final_url": "https://example.com/", "status": 200, "title": "Example Domain", "description": null, "icon": "https://example.com/favicon.ico", "open_graph": { "title": "...", "image": "https://..." }, "page_height": 800, "removed_elements": 0, "consent_manager": null, "overlay_remaining": null, "truncated": false, "content_type": "image/png", "size": 18734, "image": "iVBORw0KGgo..." }

open_graph holds the page's og: tags without the prefix. icon is the page's own icon link, or /favicon.ico when it has none (which may not exist).

Signed URLs

To put a shot straight into an or og:image tag without giving away your key, sign the URL instead. Set a second secret, SIGNING_SECRET (16 characters or more, for example from openssl rand -hex 32; on Cloudflare echo "$SIGNING_SECRET" | npx wrangler secret put SIGNING_SECRET, or add it under the Worker's settings), then add a signature to each URL:

  1. Take every parameter, including expires if you want the link to stop working at some point (a Unix time in seconds).
  2. Sort them by name, percent-encode names and values (everything except A-Z a-z 0-9 - _ . ~) and join them as name=value&name=value.
  3. signature is the HMAC-SHA256 of that string with SIGNING_SECRET, in hex.

Anyone can read a signed URL, but changing, adding or removing any parameter breaks it. A wrong signature gets unauthorized with reason: signature_invalid, an expired one reason: signature_expired. Only GET requests can be signed. Make signed URLs on your server, never in the browser, so the secret stays with you.

In Node.js:

import { createHmac } from 'node:crypto';

const encode = (s) => encodeURIComponent(s).replace(/[!'()*]/g, (c) => %${c.charCodeAt(0).toString(16).toUpperCase()});

function signedUrl(base, options, secret) { const query = Object.keys(options).sort() .map((name) => ${encode(name)}=${encode(String(options[name]))}) .join('&'); const signature = createHmac('sha256', secret).update(query).digest('hex'); return ${base}/screenshot?${query}&signature=${signature}; }

signedUrl('https://api-screenshot.your-subdomain.workers.dev', { url: 'https://example.com', full_page: true, expires: Math.floor(Date.now() / 1000) + 7 * 24 * 3600, // optional: valid for a week }, process.env.SIGNING_SECRET);

In a shell, with the query already sorted and encoded:

QUERY='full_page=true&url=https%3A%2F%2Fexample.com'

SIG=$(printf '%s' "$QUERY" | openssl dgst -sha256 -hmac "$SIGNING_SECRET" -r | cut -d' ' -f1) echo "https://api-screenshot.your-subdomain.workers.dev/screenshot?$QUERY&signature=$SIG"

With only SIGNING_SECRET set and no API_KEY, the API takes signed URLs and nothing else.

Caching

A finished shot is kept for a day, so the same request again comes back at once and costs no browser time. Requests count as the same when their options are, after defaults are filled in: url=example.com and url=https://example.com/ share one shot. Only real shots are kept. A blocked, blank or any other error is never cached, so the next request tries again.

The cache is checked after the key or signature, so a cached shot never goes to someone who couldn't have asked for it. The x-cache header says whether a shot came from the cache. cache-control tells browsers how long they may keep it too: private for requests with the key, public for signed URLs (never past their expires), so a CDN in front can serve them.

On Cloudflare, shots are kept in Workers KV; the deploy creates the namespace for you. On a server they are kept in a folder, CACHE_DIR, up to CACHE_MAX_MB, and the shots used longest ago make room for new ones. In Docker that folder is /var/cache/api-screenshot; add -v api-screenshot-cache:/var/cache/api-screenshot to docker run to keep the shots when the container is replaced.

Options

Option names match the ones common to hosted screenshot APIs, so most requests written for one of those work here unchanged. An unknown option is refused, so a typo doesn't fail silently.

OptionDefaultWhat it does
urlrequiredThe page to shoot. https:// is added when missing.

| html | | Markup to

只显示了开头部分;其余内容请在仓库中阅读