# npm API

> npm provides package details, package search, and download statistics as a workflow and API.

npm returns package versions, ownership, links, dates, and weekly downloads; Get package needs a package name or npm link. Search packages finds packages by purpose or keywords from a query; Get download stats returns counts for a package and period.

- Page: https://fous.com/tools/npm
- Handle: `@npm`
- Category: [Developer tools](https://fous.com/tools/category/developer-tools)
- Source website: https://npmjs.com
- Last verified: Sep 29, 2026

## Methods

### Get download stats

Operation `get_download_stats`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Get total and daily or Monday-start weekly downloads for an npm package over the last week, month, or year. The latest available counts may lag by a day or more; boundary weeks can be partial.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `period` | string | no | `"last_week"` | The time period, such as last_month. |
| `package` | string | yes | `"express"` | The npm package name, such as express or @types/node. |
| `breakdown` | string | no | `"week"` | Group counts by day or Monday-start week, such as day. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "package"
  ],
  "properties": {
    "period": {
      "enum": [
        "last_week",
        "last_month",
        "last_year"
      ],
      "type": "string",
      "default": "last_month",
      "description": "The time period, such as last_month.",
      "examples": [
        "last_week",
        "last_year"
      ]
    },
    "package": {
      "type": "string",
      "minLength": 1,
      "description": "The npm package name, such as express or @types/node.",
      "examples": [
        "express",
        "@types/node"
      ]
    },
    "breakdown": {
      "enum": [
        "day",
        "week"
      ],
      "type": "string",
      "default": "day",
      "description": "Group counts by day or Monday-start week, such as day.",
      "examples": [
        "week"
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "package": "express"
    },
    {
      "period": "last_week",
      "package": "@types/node",
      "breakdown": "week"
    },
    {
      "period": "last_year",
      "package": "express",
      "breakdown": "week"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `package` | string | `"express"` | The npm package name. |
| `end_date` | string | `"2026-09-27"` | Last day included in the period. |
| `downloads` | array |  | Counts in chronological order. A weekly date is the Monday of that week. |
| `downloads[].date` | string | `"2026-08-29"` | Day, or Monday starting the week. |
| `downloads[].download_count` | integer | `10413166` | Downloads on this day or within this week and the chosen period. |
| `start_date` | string | `"2026-08-29"` | First day included in the period. |
| `package_url` | string | `"https://www.npmjs.com/package/express"` | The npm package page. |
| `total_downloads` | integer | `493323187` | Total downloads in the period. |

**Example input**

```json
{
  "package": "express"
}
```

**Example output**

```json
{
  "package": "express",
  "end_date": "2026-09-27",
  "downloads": [
    {
      "date": "2026-08-29",
      "download_count": 10413166
    },
    {
      "date": "2026-08-30",
      "download_count": 10704291
    },
    {
      "date": "2026-08-31",
      "download_count": 21966585
    }
  ],
  "start_date": "2026-08-29",
  "package_url": "https://www.npmjs.com/package/express",
  "total_downloads": 493323187
}
```

### Get package

Operation `get_package`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Get a public npm package’s latest version, weekly downloads, ownership, links, dates, and version count from its name or npm link.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `package` | string | yes | `"react"` | The npm package name or npm package page link, for example react, @angular/core, or https://www.npmjs.com/package/react. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "package"
  ],
  "properties": {
    "package": {
      "type": "string",
      "description": "The npm package name or npm package page link, for example react, @angular/core, or https://www.npmjs.com/package/react.",
      "examples": [
        "react",
        "@angular/core",
        "https://www.npmjs.com/package/lodash?activeTab=versions"
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "package": "react"
    },
    {
      "package": "@angular/core"
    },
    {
      "package": "https://www.npmjs.com/package/lodash?activeTab=versions"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `name` | string | `"react"` | Published npm package name. |
| `license` | string or null | `"MIT"` | Package license. |
| `homepage` | string or null | `"https://react.dev/"` | Project homepage. |
| `description` | string or null | `"React is a JavaScript library for building user interfaces."` | Package description. |
| `maintainers` | array |  | Current maintainer names. |
| `created_date` | string or null | `"2011-10-26"` | Date the package was first created. |
| `npm_page_link` | string | `"https://www.npmjs.com/package/react"` | The package page on npm. |
| `latest_version` | string or null | `"19.3.0"` | Version identified as latest by the publisher. |
| `repository_link` | string or null | `"https://github.com/react/react.git"` | Source repository link. |
| `weekly_downloads` | integer or null | `203157609` | Downloads in the most recently reported seven-day period. |
| `last_publish_date` | string or null | `"2026-09-23"` | Date of the most recently published version. |
| `number_of_versions` | integer | `2957` | Number of published versions in the registry. |

**Example input**

```json
{
  "package": "react"
}
```

**Example output**

```json
{
  "name": "react",
  "license": "MIT",
  "homepage": "https://react.dev/",
  "description": "React is a JavaScript library for building user interfaces.",
  "maintainers": [
    "fb",
    "react-bot"
  ],
  "created_date": "2011-10-26",
  "npm_page_link": "https://www.npmjs.com/package/react",
  "latest_version": "19.3.0",
  "repository_link": "https://github.com/react/react.git",
  "weekly_downloads": 203157609,
  "last_publish_date": "2026-09-23",
  "number_of_versions": 2957
}
```

### Search packages

Operation `search_packages`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Find JavaScript packages on npm by what they do or by keywords, in npm search order. Returns up to 250 matches with their latest versions, weekly downloads and publish dates.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `query` | string | yes | `"date formatting"` | What the package should do, or keywords, such as date formatting. |
| `max_results` | integer | no | `7` | Maximum number of packages to return, such as 20. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "query"
  ],
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "description": "What the package should do, or keywords, such as date formatting.",
      "examples": [
        "date formatting",
        "terminal colors",
        "zzzzzqwdzx_unique_nothing_98763245"
      ]
    },
    "max_results": {
      "type": "integer",
      "default": 20,
      "maximum": 250,
      "minimum": 1,
      "description": "Maximum number of packages to return, such as 20.",
      "x-fous-developer": true,
      "examples": [
        7,
        250
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "query": "date formatting"
    },
    {
      "query": "terminal colors",
      "max_results": 7
    },
    {
      "query": "zzzzzqwdzx_unique_nothing_98763245"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `packages` | array |  | Matching packages in npm search order. |
| `packages[].name` | string | `"fecha"` | Package name. |
| `packages[].publisher` | string or null | `"taylorhakes"` | Publisher username. |
| `packages[].description` | string or null | `"Date formatting and parsing"` | Package description. |
| `packages[].search_score` | number or null | `768.8522` | npm search ranking score. |
| `packages[].npm_page_link` | string | `"https://www.npmjs.com/package/fecha"` | Package page on npm. |
| `packages[].latest_version` | string or null | `"4.2.3"` | Latest published version. |
| `packages[].weekly_downloads` | integer or null | `29073022` | Downloads in the past week. |
| `packages[].last_publish_date` | string or null | `"2022-04-15"` | Date of the latest package publish. |

**Example input**

```json
{
  "query": "date formatting"
}
```

**Example output**

```json
{
  "packages": [
    {
      "name": "fecha",
      "publisher": "taylorhakes",
      "description": "Date formatting and parsing",
      "search_score": 768.8522,
      "npm_page_link": "https://www.npmjs.com/package/fecha",
      "latest_version": "4.2.3",
      "weekly_downloads": 29073022,
      "last_publish_date": "2022-04-15"
    },
    {
      "name": "@fullcalendar/moment",
      "publisher": "arshaw",
      "description": "Enhanced date formatting and conversion with Moment",
      "search_score": 416.25626,
      "npm_page_link": "https://www.npmjs.com/package/@fullcalendar/moment",
      "latest_version": "6.1.21",
      "weekly_downloads": 97908,
      "last_publish_date": "2026-06-18"
    },
    {
      "name": "@fullcalendar/luxon3",
      "publisher": "arshaw",
      "description": "Enhanced date formatting, conversion, and named time zone functionality with Luxon 3",
      "search_score": 349.2435,
      "npm_page_link": "https://www.npmjs.com/package/@fullcalendar/luxon3",
      "latest_version": "6.1.21",
      "weekly_downloads": 134000,
      "last_publish_date": "2026-06-18"
    }
  ]
}
```

## Quick start

Replace `YOUR_API_KEY` with a Fous API key. To create one, open Developers at the bottom of Fous Studio, turn on Developer mode, then go to API keys (https://app.fous.com/keys). Change the values in `input` to run the same tool on new data.

```bash
curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 180 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "api": "@npm",
  "visibility": "public",
  "operation": "get_download_stats",
  "version": 1,
  "input": {
    "package": "express"
  },
  "response": {
    "format": "json"
  }
}'
```

```python
# Save as fous.py and run with python3 fous.py. No packages needed.
import json
import urllib.error
import urllib.request

api_key = "YOUR_API_KEY"

body = json.loads("{\n  \"api\": \"@npm\",\n  \"visibility\": \"public\",\n  \"operation\": \"get_download_stats\",\n  \"version\": 1,\n  \"input\": {\n    \"package\": \"express\"\n  },\n  \"response\": {\n    \"format\": \"json\"\n  }\n}")
request = urllib.request.Request(
    "https://api.fous.com/v1/query",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urllib.request.urlopen(request, timeout=180) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8', errors='replace')}") from error
if result.get("success") is False:
    raise RuntimeError(result.get("error", {}).get("message", "Request failed"))
print(json.dumps(result["data"]["output"], indent=2))
```

```typescript
// Save as fous.mts and run with npx tsx fous.mts.
const apiKey = "YOUR_API_KEY";

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(180_000),
  body: JSON.stringify({
  "api": "@npm",
  "visibility": "public",
  "operation": "get_download_stats",
  "version": 1,
  "input": {
    "package": "express"
  },
  "response": {
    "format": "json"
  }
}),
});
type ApiResult = { success: boolean; data?: { output: unknown }; error?: { message: string } };
const result: ApiResult = await response.json();
if (!response.ok || result.success === false) {
  throw new Error(result.error?.message ?? `HTTP ${response.status}`);
}
if (!result.data) throw new Error("Missing API response data");
console.log(result.data.output);
```

## Use from an AI assistant

Connect this tool to Claude Code, Claude Desktop, Cursor, VS Code, Codex and any MCP client as its own MCP server. Each method is a typed tool whose arguments are the method’s input.

- Server URL: `https://api.fous.com/mcp/tools/npm`
- Authorization: `Authorization: Bearer <Fous API key>`

**Tools**

- `get_download_stats`: Get download stats. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `get_package`: Get package. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `search_packages`: Search packages. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `fous_get_run`: the result of a run that was still going, by its `request_id`. Free.

Claude Code:

```bash
claude mcp add --scope user --transport http fous-npm https://api.fous.com/mcp/tools/npm --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"
```

To give the assistant every tool, connect `https://api.fous.com/mcp`: it finds one with `fous_search_tools` and runs it with `fous_run_tool`. Setup for other clients: https://fous.com/llms-full.txt.

## Use cases

- Compare package downloads before choosing a dependency
- Find packages by purpose or keywords
- Review package maintainers, licenses, and repository links
- Track daily or weekly package downloads
- Check package version counts and latest publish dates

## FAQ

### Can I run it with my own inputs?

Yes. Change the inputs in Studio and press Run, or send new inputs from your code, or ask a connected AI assistant.

### Can I call this npm tool as an API?

Yes. Send a POST request to /v1/query with your Fous API key and the inputs, and get JSON back.

### How much does it cost?

Each completed run costs 1 credit. Failed runs without a completed receipt are free; completed work can remain charged if delivery is interrupted. With pay as you go, a credit costs 1¢. Monthly plans cost less per credit.

### Do I need a npm account?

No. You only need a Fous account.

### How current is the data?

Fous gets the data from npmjs.com when you run it. Some results are reused for up to 24 hours, and results that use your account or key are never reused. It was last verified on Sep 29, 2026.

### How many downloads did a package get last month?

Get download stats returns total downloads and daily or Monday-start weekly counts for a package and period.

### Which packages match a particular need?

Search packages finds packages by what they do or by keywords.

### Who maintains a package, and when was it last published?

Get package returns maintainer names and the most recent publish date.

## Related

- [NuGet API](https://fous.com/tools/nuget.md): The .NET package gallery for discovering and sharing packages.
- [PyPI API](https://fous.com/tools/pypi.md): PyPI provides package metadata, links, and current/latest plus 10 recent versions; release dates reflect first file uploads, and keyword searches return up to 100 packages.
- [GitHub API](https://fous.com/tools/github.md): GitHub returns public repository matches and details, up to 25 trending projects, issues, pull requests, and newest-first published releases; release or commit dates may be unavailable.
- [RubyGems API](https://fous.com/tools/rubygems.md): Discover and share Ruby gems.
- [crates.io API](https://fous.com/tools/crates-io.md): crates.io is the Rust community package registry, returning current crate details and recent releases or up to 100 keyword-matched crates with version, download, and update information.
- [Docker Hub API](https://fous.com/tools/docker-hub.md): Docker Hub helps find and publish container images, search public images, and view image details and recently updated tags; pull totals may lag or be unavailable.
- [WordPress.org API](https://fous.com/tools/wordpress-org.md): WordPress.org’s public plugin directory returns up to 100 ranked search matches with ratings, installations, compatibility and links, plus best-match details and the latest-version changelog when available.
- [VS Code Marketplace API](https://fous.com/tools/vs-code-marketplace.md): Public listings for Visual Studio Code extensions.
- [All Developer tools tools](https://fous.com/tools/category/developer-tools)
