# 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/workflows/npm
- Handle: `@npm`
- Category: [Developer tools](https://fous.com/workflows/category/developer-tools)
- Source website: https://npmjs.com
- Last verified: Sep 29, 2026
- Fous is not affiliated with npm.

## Methods

### Get download stats

Operation `get_download_stats`, version 1. 1 credit per call.

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 call.

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 call.

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

Call the API with a Fous API key (`FOUS_API_KEY`). To create one, turn on Developer mode in Fous Studio, then open Keys & connections → API keys (https://app.fous.com/keys).

```bash
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
: "${FOUS_API_KEY:?Set FOUS_API_KEY before running this example}"

curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 120 \
  -H "Authorization: Bearer $FOUS_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.
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
import json
import os
import urllib.error
import urllib.request

api_key = os.environ.get("FOUS_API_KEY")
if not api_key:
    raise RuntimeError("Set FOUS_API_KEY before running this example")

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=120) 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.
// First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
const apiKey = process.env.FOUS_API_KEY;
if (!apiKey) throw new Error("Set FOUS_API_KEY before running this example");

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(120_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);
```

Or describe the data in plain language: send `{"api":"@npm","prompt":"Describe the data you need, with every detail"}` to the same URL. Fous fills in the input, runs the method that fits and returns only the fields you asked for; `data.route.calls[].request` is the exact call it made. Routing is free; the run costs the same.

## 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

### Is Fous affiliated with npm?

No. Fous is not affiliated with npm. This workflow reads the public npmjs.com website and returns its data.

### How much does it cost?

Each run costs 1 credit. 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; repeating the same request within a day may return the saved result. Fous checks this workflow automatically; it last passed a check 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/workflows/nuget.md): The .NET package gallery for discovering and sharing packages.
- [PyPI API](https://fous.com/workflows/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/workflows/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/workflows/rubygems.md): Discover and share Ruby gems.
- [crates.io API](https://fous.com/workflows/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/workflows/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/workflows/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/workflows/vs-code-marketplace.md): Public listings for Visual Studio Code extensions.
- [All Developer tools workflows](https://fous.com/workflows/category/developer-tools)
