spa-api-extract: Extracting Data from Internal SPA JSON APIs When WebFetch Fails

Introduction

When performing web-related tasks in DeepSeek Harness (DSH), the common approach is to use WebFetch to pull pages into readable text. However, when encountering client-side rendered Single Page Applications (SPAs) built with React, Vue, Next, Nuxt, etc., this path often fails: it times out, returns only bundled and obfuscated JS, or leaves an empty shell in the HTML. The real data is often located in JSON APIs behind the page, rather than in the initial HTML.

Below is the community plugin spa-api-extract (Maintainer: sunwindy91, Category: Web Tool). It embeds a reproducible CLI pipeline into an Agent Skill. When WebFetch fails, it switches to using curl, grep, and Python to locate and read-only call the JSON interfaces used internally by the page, then saves the structured results to a UTF-8 file. The plugin itself only registers skill knowledge; it does not initiate network requests or expose host tools upon loading.

What is this

spa-api-extract is an Agent Skill plugin with the npm package name @sunwindy91/dsh-spa-api-extract (version 0.1.2 in current materials) and an MIT license. The repository follows the open Agent Skills convention (root SKILL.md + frontmatter) and can also be placed as a whole directory into other harness skill directories that support this format.

On the DSH side, the skill is mounted to ctx.skills via a Cordis patch; index.js injects the skills module, and lib/skills.js registers the root SKILL.md. Detailed commands are in SKILL.md, while grep regexes and common SPA data forms (REST, GraphQL, __NEXT_DATA__, window.__*, etc.) are in the on-demand loaded reference.md.

Core Features

The capabilities described by the plugin can be summarized as a fixed pipeline (steps from the original material):

  1. Confirm failure signals — Timeout, only JS, or empty shell → Determine it is an SPA scenario.
  2. curl-probe — Use -sS -m to fetch response headers and the raw HTML skeleton.
  3. grep — Find fetch(), /api/ endpoints, <script src>, and BASE path derivation clues in the HTML/JS.
  4. Reconstruct and request JSON API — Read-only GET, carrying necessary authentication queries from the URL (e.g., ?t=xxxx).
  5. Python Parsing — Check structure first, then extract to a UTF-8 file (to avoid GBK garbled text on Windows).
  6. Validation — Record counts, field integrity, and ensure output is non-empty.

When to use (listed in materials):

  • The target page is a client-side rendered SPA.
  • Real data is in a JSON API, not in the initial HTML.
  • The URL contains token-like query parameters.
  • WebFetch has timed out or only returned scripts.

Security & Compliance (emphasized in materials):

  • Read-only by default, using only GET; write operations require explicit user authorization.
  • Tokens are treated as secrets and must not be written to final outputs, commit logs, or shared files.
  • Only access targets you are authorized to access; comply with ToS, robots, and rate limits.
  • No telemetry, no listening, no callbacks; the body consists of pure instructions and placeholder examples (HOST / PATH / TOKEN).

Installation & Activation

Before installation, @deepseek-ai/dsh-base (which mounts the skill registry) must be present. Run the following in your dsh deployment (command from the repo README):

dsh plugin --profile web add github:sunwindy91/spa-api-extract

The repository includes cordis.patch.yml, which is automatically mounted by dsh after installation, requiring no manual patching. The installation process forwards parameters to pnpm within the profile directory and requires access to github.com. If your local git is configured with a proxy but the proxy is not running, you may encounter ECONNREFUSED; ensure the proxy is available or temporarily unset the git global http.proxy.

yaml is a peerDependency (usually provided by the host); if missing in the environment, the plugin degrades to a built-in minimal frontmatter parser and will not fail to load due to missing dependencies.

You can also use it without dsh by placing the directory in an Agent skill path, for example:

~/.qwenworkcn/skills/spa-api-extract/

Typical Usage

After activating the plugin, the model should load the spa-api-extract skill and execute it step-by-step according to SKILL.md. The overall approach is: first confirm that the WebFetch failure is an SPA scenario, then use curl to get the raw page, use grep to dig out API paths and parameters from bundles or inline scripts, construct a read-only GET request consistent with the browser, and finally use Python to explore the JSON structure and write the result to a UTF-8 file.

The materials do not provide a complete copy-paste example bound to a specific real site; placeholders, regex libraries, authentication variants, and troubleshooting tables are found in reference.md. The execution environment uses curl and python under the current dsh process permissions, which is equivalent to manually running the same commands in your terminal.

Use Cases & Notes

Suitable for: Developers who need to stably extract structured data from SPA backend APIs within Agent workflows where HTML scraping has clearly failed; this aligns with DSH’s “everything is a plugin” skill extension approach.

Notes:

  • The plugin has 0 GitHub Stars (as noted in materials); it is recommended to read the source code and LICENSE on GitHub before installation.
  • It only registers knowledge and does not replace your judgment regarding authorization and compliance for target sites.
  • The community catalog SkillHub Plugin Page and GitHub are independent information sources and have no official affiliation with DeepSeek / High-Flyer.

Links

  • Catalog Page: https://www.skillhub.cn/plugins/sunwindy91/spa-api-extract
  • GitHub: https://github.com/sunwindy91/spa-api-extract

Through the steps above, when WebFetch cannot handle an SPA, you can solidify “finding internal JSON APIs + read-only fetching + saving to UTF-8” into a repeatable skill flow, rather than guessing interface paths in the bundle every time.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye