npm Registry API
Query npm package metadata, versions and download stats.
What it does
The public npm registry is a read API for JavaScript package metadata: full version history, dependencies, maintainers, dist-tags, tarball URLs and README for any published package, plus a search endpoint and (on a separate host) download-count statistics.
Base URL
Authentication
None for public reads. A token is only needed to publish or to read private packages. Send a User-Agent identifying your tool.
Code examples
# Full metadata (the "packument") curl -s https://registry.npmjs.org/react | head -c 300 # One version only curl -s https://registry.npmjs.org/react/18.3.1 # Weekly downloads (different host) curl -s https://api.npmjs.org/downloads/point/last-week/react
import requests
p = requests.get("https://registry.npmjs.org/express", timeout=10).json()
latest = p["dist-tags"]["latest"]
print(latest, p["versions"][latest]["dependencies"])Rate limits & quotas
No formal published rate limit, but the registry is CDN-fronted and abusive traffic gets blocked — cache aggressively, request one package at a time, and prefer the abbreviated metadata document (send Accept: application/vnd.npm.install-v1+json) when you don’t need every field. The downloads API on api.npmjs.org allows date ranges up to 18 months and bulk queries of up to 128 packages.
Key response fields
| dist-tags.latest | Current published version |
| versions | Object keyed by version number, each with full package.json |
| versions[v].dist.tarball | Download URL for that version’s tarball |
| time | Publish timestamp per version, plus created/modified |
| maintainers | Publishers with access |
Common errors
| 404 | Package name does not exist (or is a private/unpublished name). |
| 429 / 403 | You are being rate-limited or blocked for hammering the CDN — back off and cache. |
| 405 | You tried a write method without auth. |
When to use it (and alternatives)
Use it to build dependency dashboards, license/security scanners, ‘is this package maintained?’ checks, or version badges. For the equivalent in other ecosystems: PyPI’s JSON API, crates.io, and Packagist all follow the same idea.
FAQ
How do I get download counts?
Use the separate host: https://api.npmjs.org/downloads/point/last-week/<package> for a total, or /downloads/range/ for a daily series. Scoped packages need URL-encoding of the /.
The metadata document is huge — can I get a smaller one?
Yes. Send Accept: application/vnd.npm.install-v1+json for the abbreviated packument, which drops fields npm doesn’t need at install time and is much smaller for popular packages.
Is there an official rate limit?
npm does not publish one for reads, but it will throttle or block clients that generate excessive traffic. Treat it as a shared resource: cache, and don’t crawl the whole registry.
New to APIs?
Short guides for working with this API — and any other.