Scrape npm Package Data (and PyPI, crates.io, Docker Hub)

Pull npm package data plus PyPI, crates.io and Docker Hub metadata from public JSON APIs. One command per registry, real outputs, gotchas tested Nov 2026.

MMotherlode Lab10 min read
Magpie title card: Scrape npm Package Data (and PyPI, crates.io, Docker Hub)

Package registries are the polite end of the scraping world. All four majors publish JSON APIs that hand over the npm package data and registry metadata you’re after: no login, no key, no renderer. I pulled typed records from npm, PyPI, crates.io and Docker Hub in one command apiece on November 2, 2026; this guide shows the commands, the real outputs, and the four spots where each registry bites.

The registries publish JSON APIs. Skip the HTML.

The HTML pages get redesigned. The JSON endpoints are contracts that client tooling depends on. Every npm install hits these endpoints, so they are not going anywhere. The same logic applies to the other three, which is why every recipe below targets JSON and none of them parse a page.

Here is the whole cheat sheet. Left column is the URL you type; right column is where the data actually comes from.

Registry URL you type Endpoint actually queried Fields you get back
npm npmjs.com/package/express registry.npmjs.org/express (full packument) name, version, latest, description, url
PyPI pypi.org/project/flask/ pypi.org/pypi/flask/json name, version, summary, author, requires_python, url
crates.io crates.io/crates/serde crates.io/api/v1/crates/serde name, newest_version, description, downloads, url
Docker Hub hub.docker.com/r/library/alpine hub.docker.com/v2/repositories/library/alpine/ name, description, star_count, pull_count, last_updated

You could curl each endpoint and jq the fields yourself. The Magpie commands below do the same two-step for you and return the same shape for every registry, which pays off the moment you want one loop over all four. The registries are unusually honest about this: the good data sits in a documented endpoint, not the markup. When a site doesn’t hand you one, the hunt is its own skill; see find a website’s hidden API for the general case.

One caveat before Step 1: the Magpie CLI runs these as ordinary scrapes, so they count against the desktop app’s five free runs per install. The core CLI has no run counter. Every command below also works with plain curl against the endpoint in the table.

Step 1: npm package data lives at registry.npmjs.org

Don’t scrape npmjs.com. The site sits behind a Cloudflare managed challenge; my plain fetch of npmjs.com/package/left-pad died with quality blocked (empty) (exit 8). It doesn’t matter, because the npm vertical never touches the site. It calls the registry and returns:

$ magpie scrape https://www.npmjs.com/package/express --vertical npm
{
  "url": "https://www.npmjs.com/package/express",
  "vertical": "npm",
  "record": {
    "description": "Fast, unopinionated, minimalist web framework",
    "latest": "5.3.0",
    "name": "express",
    "url": "https://www.npmjs.com/package/express",
    "version": "5.3.0"
  }
}

Output abridged: the run also reports the page title and final URL. Expect 7 to 12 seconds per package (express took 6.9 s, left-pad 11.6 s in the same session). The endpoint returns the full packument, every version ever published, and the extractor picks dist-tags.latest out of it. A decade-old package means a chunky download. Budget one call per package.

Failure is typed, not silent. A name that doesn’t exist returns vertical: GET https://registry.npmjs.org/zzq-no-such-pkg: HTTP 404 and exit 1, which is what you want in a script.

Two npm-specific gotchas I hit live:

  • Scoped packages break through the site URL. magpie scrape https://www.npmjs.com/package/@types/node --vertical npm fails: the extractor reads the segment after /package/, asks the registry for @types alone, and gets HTTP 405. The workaround is to query the registry directly with the slash encoded:

    $ magpie scrape 'https://registry.npmjs.org/@types%2fnode/latest' --page-format raw
    {"name":"@types/node","version":"26.6.6","license":"MIT", ...}

    The /latest form returns one small manifest instead of the full packument. Bare JSON comes back unwrapped.

  • Weekly downloads are a separate endpoint. The packument doesn’t carry them. api.npmjs.org/downloads/point/last-week/express answered 196,630,276 for the week ending October 29, 2026.

One dry observation from testing: registry.npmjs.org/robots.txt is not a robots file. The registry treats it as a package name and returns the packument for an actual 2013 npm package called robots.txt. The registry has no robots directives at all; it’s an API, and npmjs.com’s HTML robots are behind the same Cloudflare wall that blocks the pages.

Step 2: PyPI answers in two seconds, minus one field

PyPI is the fastest of the four because the JSON API is a small document, not a packument:

$ magpie scrape https://pypi.org/project/flask/ --vertical pypi
{
  "record": {
    "author": "",
    "name": "Flask",
    "requires_python": ">=3.9",
    "summary": "A simple framework for building complex web applications.",
    "version": "3.1.3"
  }
}

1.8 seconds, flask 3.1.3. The record’s author field is always empty: PyPI’s JSON API has returned author: None since the Author-email migration, and I confirmed it on flask and requests on the same day. If your pipeline keys on maintainer names, PyPI will disappoint you at the source, not in your parser.

The robots nuance matters if you scale up. pypi.org/robots.txt disallows /pypi/*/json and /pypi/*/*/json to crawlers, while /project/ pages and the per-project feeds (/rss/project/<name>/releases.xml) are allowed. A one-off point query is ordinary tooling. If you’re crawling thousands of project pages, point the crawl at /project/ URLs and leave the JSON path to single lookups. Magpie enforces the split for you: crawl reads robots.txt and refuses disallowed seeds, while a single scrape is a user-directed fetch that doesn’t consult it.

The vertical always returns the latest version. For a pinned version, the raw API takes one: pypi.org/pypi/flask/3.1.2/json returns that release’s metadata.

Step 3: crates.io puts its limits in writing

crates.io is the one registry with an explicit usage contract, published at crates.io/data-access: maximum 1 request per second, and a User-Agent header that identifies your application. Magpie sends github.com/motherlodelab/magpie/1.0, which satisfies both halves; keep the same courtesy if you roll your own client.

$ magpie scrape https://crates.io/crates/serde --vertical crates_io
{
  "record": {
    "description": "A generic serialization/deserialization framework",
    "downloads": 1630306991,
    "name": "serde",
    "newest_version": "1.0.229",
    "url": "https://crates.io/crates/serde"
  }
}

8.2 seconds, and note what’s in the record: serde crossed 1.63 billion downloads, and newest_version tracks the repo’s actual release cadence. The run fetches both the crate page and the API; a direct API call from the same machine took about 2 seconds, so if you only want the record, the endpoint alone is faster and the vertical’s value is the typed shape.

Note where the protection sits: on the HTML, not the contract. crates.io/robots.txt answered 403 to plain curl on my connection while the API answered fine with an identifying User-Agent.

Step 4: Docker Hub pull counts without pulling an image

The dockerhub vertical calls Hub’s public v2 API, no token, no login:

$ magpie scrape https://hub.docker.com/r/library/alpine --vertical dockerhub
{
  "record": {
    "description": "A minimal Docker image based on Alpine Linux ...",
    "last_updated": "2026-10-23T05:24:50.064348Z",
    "name": "alpine",
    "pull_count": 12451767485,
    "star_count": 11579
  }
}

3.4 seconds. Alpine: 12.45 billion cumulative pulls, 11,579 stars, last pushed October 23, 2026. Read pull_count as cumulative pulls, not installs; registry mirrors and proxy caches inflate it. last_updated is the useful field for maintenance checks, since an image that hasn’t pushed in a year is a dependency risk no star count offsets.

Official images live under the library owner, so type the /r/library/<name> form. Typing hub.docker.com/r/alpine (no owner) fails the pattern by design; the bare /_/alpine shortcut isn’t a valid vertical URL. robots.txt on hub.docker.com allows everything and declares a sitemap, so robots poses no constraint at any scale here.

A fifth vertical: Hugging Face

The same registry code ships a Hugging Face extractor for models and datasets. magpie scrape https://huggingface.co/google-bert/bert-base-uncased --vertical huggingface returned downloads: 29234461, likes: 3060, pipeline_tag: fill-mask plus the tag list. If your use case is model metadata rather than packages, the Hugging Face scrape guide goes deeper.

Batch all four in one loop

magpie batch can’t fire verticals (it has no --vertical flag and returns url/title/markdown only), so a scrape loop is the honest tool. One URL per line, mixed registries, sleep 2 to clear crates.io’s one-request-per-second rule:

cat > packages.txt <<'EOF'
https://www.npmjs.com/package/express
https://pypi.org/project/requests/
https://crates.io/crates/serde
https://hub.docker.com/r/library/alpine
EOF

while read -r url; do
  magpie scrape "$url" --vertical auto >> registry.json 2>> registry.err
  sleep 2
done < packages.txt

jq '.record | {name, version}' registry.json

--vertical auto matches each URL against the vertical list, so one loop covers every registry. jq reads the appended JSON stream as-is and prints {"name":"express","version":"5.3.0"} and friends. A dead package writes its typed 404 to registry.err and exits 1 for that iteration; the loop continues. If you’d rather fail the whole run on any miss, check the exit code inside the loop.

What the typed records leave out

Five or six fields per registry is deliberately small. No license, no dependencies, no repo link, no keywords, no maintainer list. Those live one level down, in the same APIs:

You want Endpoint Notes
One npm manifest (license, deps, engines) registry.npmjs.org/<name>/latest Kilobytes, not the whole packument
Full npm history (versions, maintainers, timestamps) registry.npmjs.org/<name> The packument the vertical uses
PyPI full info block (license, requires_dist, project_urls) pypi.org/pypi/<name>/json Same author: None quirk
crates.io per-version manifests crates.io/api/v1/crates/<name>/versions serde: 316 versions, latest carries license: "MIT OR Apache-2.0", yanked flags
Docker Hub tag list hub.docker.com/v2/repositories/<owner>/<repo>/tags/?page_size=100 alpine: 228 tags, latest, 3.24.3, 3.24 …

Beyond the four, two services aggregate across registries and will beat any scraper at their job. deps.dev’s API is free, unauthenticated, and returns dependency and advisory data for npm, PyPI, crates and more. libraries.io’s API covers the same ground with a free key under a 60-requests-per-minute limit. For a license-compliance sweep across thousands of dependencies, start there; scraping is for the fields and registries they don’t cover.

When versions change without you

A one-shot record goes stale the moment you close the terminal. If the actual job is knowing when a package ships, that’s watch mode, not scraping: registry.npmjs.org/-/package/<name>/dist-tags cleans to exactly {"latest":"1.3.0"} and PyPI publishes per-project release feeds. npm killed its push-based Hooks API (the endpoint now returns 410 Gone), so polling is the only option there. Full setups, including webhook delivery, are in get alerts for new npm and PyPI package versions; for the GitHub-release side of the same problem, see track GitHub releases.

FAQ

Is scraping npm, PyPI, crates.io or Docker Hub allowed? The registries publish these APIs for client tooling, and crates.io states its terms (1 req/s, identifying User-Agent) in writing. PyPI’s robots.txt disallows the JSON path to crawlers while allowing project pages. Keep rates sane and don’t repackage a full catalog as a competing index.

Why is my npm lookup slower than the other registries? The npm endpoint returns the full packument, every published version, before the extractor picks out dist-tags.latest. Measured 7 to 12 seconds per package; scrape the /latest path directly and you get one small manifest instead.

How do I get npm weekly download numbers? A separate endpoint: api.npmjs.org/downloads/point/last-week/<name> for the last seven days, or /range/<period>/<name> for series. express showed 196,630,276 for the week ending October 29, 2026.

Can I watch several hundred packages for version changes? Yes, politely. The dist-tags and release-feed URLs are tiny, so a cron loop at one request per package per hour is a rounding error. The watch recipes with webhooks are in the package-release-alerts guide linked above.

Do the verticals need an API key or LLM? No. Registry verticals are zero-LLM: the CLI fetches public JSON and parses it offline, no provider key, no cost per record. The LLM parts of Magpie (schema extraction) are separate and optional.

Start with the endpoint, keep the vertical

Bookmark the first table. If you need one field from one package, curl the endpoint in the table and be done. If this is a daily job across registries (dependency audits, competitor release tracking, supply-chain checks), the loop in this guide gets you typed, uniform records without touching a page selector, and the watch guide turns it into alerts. Rate limits, not markup, are the only thing between you and the data; the rate-limiting glossary entry covers the mechanics if you’re scheduling large runs.

Stop renting credits.

One flat price, your machine, your keys.

Download free for Windows, macOS and Linux

Windows · macOS · Linux $49/mo flat, cancel anytime