npm API

Get npm data as clean JSON with one key: 7 endpoints, 1 to 5 credits per call, the same response shape as every other platform.

What you get#

Onekey exposes npm as 7 endpoints behind one API key: 4 endpoints return one record (data is an object) and 3 endpoints return a list (data is an array). Every answer uses the same envelope (success, data, metadata, error), the cost is reported in metadata.credits_charged, and fields are mapped onto the unified schema so the code you write for npm also works for the rest of the developer platforms category.

Endpoints#

EndpointWhat it doesParametersCreditsStatus
dist_tagsDist-tags (latest, next, beta...) of an npm package.name*1stable
downloadsDownload count of an npm package over a period.name*, period1stable
downloads_rangeDaily download counts of an npm package for a period.name*, period5stable
packageLatest published metadata of an npm package.name*1stable
searchSearch the npm registry (with popularity and quality scores).q*5stable
user_packagesPackages maintained by an npm user.user*5stable
versionMetadata of one specific published npm version.name*, version*1stable

A * marks a required parameter. Each endpoint name links to its reference page with the full parameter table, caching window and a recorded response.

Make a request#

This calls npm.dist_tags (1 credit, stable). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/npm/dist_tags?name=react" \
  -H "x-api-key: YOUR_API_KEY"

Fields you get back#

These unified fields come back from npm, with the same names as on every other platform. The count is how many of its 7 mapped endpoints return the field; a field the source lacks is null, never missing. 10 platform-specific fields (ext.<name>) come on top, documented on each endpoint page.

FieldTypeEndpoints
package.versionstring5
entity.namestring4
entity.descriptionstring3
author.usernamestring2
entity.updatedAtISO 8601 date2
entity.urlURL2
author.displayNamestring1
content.createdAtISO 8601 date1
content.idstring1
content.textstring1
content.titlestring1
content.urlURL1
engagement.viewsinteger1
entity.stats.downloadsinteger1
entity.stats.scorenumber1
package.dependencieslist of strings1
package.deprecatedboolean1
package.homepageUrlURL1
package.licensestring1
package.repositoryUrlURL1

The full schema is in Unified schema.

Pricing#

npm calls cost 1 to 5 credits, flat per endpoint. Free when served from cache (0.2 credit for a cached response over 100 KB). Invalid, failed or not-found calls are not charged. See pricing for credit packs.