# npm on Onekey > 7 endpoints for npm (7 stable, 0 beta), 1 to 5 credits each. Category: Developer platforms. One key, one JSON shape. Base URL: https://api.onekey.dev Auth: header `x-api-key: `. Call shape: `GET /v1/{platform}/{endpoint}?{params}`. Every response is `{success, data, metadata, error}`; check `success` first. Cost is in `metadata.credits_charged`. Free when served from cache (0.2 credit for a cached response over 100 KB). Failed and not-found calls are refunded. Status: stable = verified against the live source; beta = not yet verified, fields may be missing. Page: https://onekey.dev/platforms/npm Reference (Markdown): https://onekey.dev/docs/api/npm.md All docs: https://onekey.dev/llms.txt ## Canonical fields returned Unified-schema fields (same names on every platform), with how many of the 7 mapped npm endpoints return each: - `package.version` (string): 5 - `entity.name` (string): 4 - `entity.description` (string): 3 - `author.username` (string): 2 - `entity.updatedAt` (ISO 8601 date): 2 - `entity.url` (URL): 2 - `author.displayName` (string): 1 - `content.createdAt` (ISO 8601 date): 1 - `content.id` (string): 1 - `content.text` (string): 1 - `content.title` (string): 1 - `content.url` (URL): 1 - `engagement.views` (integer): 1 - `entity.stats.downloads` (integer): 1 - `entity.stats.score` (number): 1 - `package.dependencies` (list of strings): 1 - `package.deprecated` (boolean): 1 - `package.homepageUrl` (URL): 1 - `package.license` (string): 1 - `package.repositoryUrl` (URL): 1 - plus 10 platform-specific fields under `ext.` ## Endpoints ### npm.dist_tags Dist-tags (latest, next, beta...) of an npm package. - Price: 1 credit per fresh call. Status: stable. Returns: one record. - Request: `GET https://api.onekey.dev/v1/npm/dist_tags?name=react` with header `x-api-key: YOUR_API_KEY` - Parameters: - `name` (string, required): npm package name, e.g. react or @babel/core - Fields returned: `package.version`, `ext.distTags` - Reference: https://onekey.dev/docs/api/npm/dist_tags.md ### npm.downloads Download count of an npm package over a period. - Price: 1 credit per fresh call. Status: stable. Returns: one record. - Request: `GET https://api.onekey.dev/v1/npm/downloads?name=react` with header `x-api-key: YOUR_API_KEY` - Parameters: - `name` (string, required): npm package name, e.g. react or @babel/core - `period` (string, optional, default last-week): last-day, last-week, last-month or last-year - Fields returned: `entity.name`, `entity.stats.downloads`, `ext.periodStart`, `ext.periodEnd` - Reference: https://onekey.dev/docs/api/npm/downloads.md ### npm.downloads_range Daily download counts of an npm package for a period. - Price: 5 credits per fresh call. Status: stable. Returns: a list. - Request: `GET https://api.onekey.dev/v1/npm/downloads_range?name=react` with header `x-api-key: YOUR_API_KEY` - Parameters: - `name` (string, required): npm package name, e.g. react or @babel/core - `period` (string, optional, default last-week): last-week, last-month or last-year - Fields returned: `content.createdAt`, `engagement.views` - Reference: https://onekey.dev/docs/api/npm/downloads_range.md ### npm.package Latest published metadata of an npm package. - Price: 1 credit per fresh call. Status: stable. Returns: one record. - Request: `GET https://api.onekey.dev/v1/npm/package?name=left-pad` with header `x-api-key: YOUR_API_KEY` - Parameters: - `name` (string, required): npm package name, e.g. left-pad or @babel/core - Fields returned: `content.id`, `content.title`, `content.text`, `content.url`, `package.version`, `author.displayName`, `ext.deprecated` - Reference: https://onekey.dev/docs/api/npm/package.md ### npm.search Search the npm registry (with popularity and quality scores). - Price: 5 credits per fresh call. Status: stable. Returns: a list. - Request: `GET https://api.onekey.dev/v1/npm/search?q=react` with header `x-api-key: YOUR_API_KEY` - Parameters: - `q` (string, required): Search query - Fields returned: `entity.name`, `package.version`, `entity.description`, `entity.url`, `package.repositoryUrl`, `entity.updatedAt`, `author.username`, `entity.stats.score`, `ext.downloadsMonthly`, `ext.dependents` - Reference: https://onekey.dev/docs/api/npm/search.md ### npm.user_packages Packages maintained by an npm user. - Price: 5 credits per fresh call. Status: stable. Returns: a list. - Request: `GET https://api.onekey.dev/v1/npm/user_packages?user=sindresorhus` with header `x-api-key: YOUR_API_KEY` - Parameters: - `user` (string, required): npm username - Fields returned: `entity.name`, `package.version`, `entity.description`, `entity.url`, `entity.updatedAt` - Reference: https://onekey.dev/docs/api/npm/user_packages.md ### npm.version Metadata of one specific published npm version. - Price: 1 credit per fresh call. Status: stable. Returns: one record. - Request: `GET https://api.onekey.dev/v1/npm/version?name=react&version=18.2.0` with header `x-api-key: YOUR_API_KEY` - Parameters: - `name` (string, required): npm package name, e.g. react or @babel/core - `version` (string, required): Exact version, e.g. 18.2.0 - Fields returned: `entity.name`, `package.version`, `entity.description`, `package.license`, `package.homepageUrl`, `author.username`, `package.deprecated`, `package.dependencies`, `ext.downloadUrl`, `ext.unpackedSize`, `ext.files`, `ext.engines` - Reference: https://onekey.dev/docs/api/npm/version.md ## Sample request ```bash curl "https://api.onekey.dev/v1/npm/dist_tags?name=react" \ -H "x-api-key: YOUR_API_KEY" ```