# npm API: Search packages

> Searches the npm registry for JavaScript packages by description or keywords, in npm's search order, and returns each package's latest version, weekly downloads and publish date.

Unofficial. Not affiliated with or endorsed by npm.

- Page: https://fous.com/methods/npmjs.com/search-packages
- Method: `npmjs.com/search_packages`, version 1
- Website: npmjs.com
- Returns: name, latest version, description, weekly downloads, last publish date, publisher, npm page link, search score
- Effect: read (it gets data and changes nothing)
- Sign-in: none needed
- Cost: 1 credit per completed run (1¢ with pay as you go); failed runs are free
- Verified: Nov 2, 2026

## Inputs

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

## Output

From a run on Oct 23, 2026, shortened. Its input:

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

Its output:

```json
{
  "packages": [
    {
      "name": "fecha",
      "publisher": "taylorhakes",
      "description": "Date formatting and parsing",
      "search_score": 776.5016,
      "npm_page_link": "https://www.npmjs.com/package/fecha",
      "latest_version": "4.2.3",
      "weekly_downloads": 14434131,
      "last_publish_date": "2022-04-15"
    },
    {
      "name": "@kev_nz/daylight",
      "publisher": "kev_nz",
      "description": "lightweight javascript date formatting",
      "search_score": 327.087,
      "npm_page_link": "https://www.npmjs.com/package/@kev_nz/daylight",
      "latest_version": "1.0.1",
      "weekly_downloads": 1216,
      "last_publish_date": "2019-12-02"
    },
    {
      "name": "small-date",
      "publisher": "rofrischmann",
      "description": "Tiny (0.8kb) date formatting library with built-in i18n",
      "search_score": 324.78616,
      "npm_page_link": "https://www.npmjs.com/package/small-date",
      "latest_version": "2.0.1",
      "weekly_downloads": 3929,
      "last_publish_date": "2024-11-06"
    }
  ]
}
```

## Run it

From code, with a Fous API key in `FOUS_API_KEY`; the answer's `data` holds the output:

```bash
curl https://api.fous.com/v1/runs \
  -H "Authorization: Bearer $FOUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"method":"npmjs.com/search_packages","input":{"query":"date formatting"}}'
```

From an AI agent connected to the Fous MCP server: its `run` with the same method and input. To connect one, give it `set up https://fous.com/SKILL.md`.

## Ask your agent

- Find npm packages for parsing CSV files in Node, show top 10 by weekly downloads
- I need a JavaScript library that validates email addresses, list the most popular options
- Which packages handle timezone-aware date formatting? Give me the latest versions and publish dates
- Search npmjs.com for lightweight markdown-to-HTML converters with at least 20 results
- Look up JavaScript packages for generating PDF invoices, sorted by search relevance

## 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."
    },
    "max_results": {
      "type": "integer",
      "default": 20,
      "maximum": 250,
      "minimum": 1,
      "description": "Maximum number of packages to return, such as 20.",
      "x-fous-developer": true
    }
  },
  "additionalProperties": false
}
```

## Output schema

```json
{
  "type": "object",
  "required": [
    "packages"
  ],
  "properties": {
    "packages": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "latest_version",
          "description",
          "weekly_downloads",
          "last_publish_date",
          "publisher",
          "npm_page_link",
          "search_score"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Package name."
          },
          "publisher": {
            "type": [
              "string",
              "null"
            ],
            "description": "Publisher username."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Package description."
          },
          "search_score": {
            "type": [
              "number",
              "null"
            ],
            "description": "npm search ranking score.",
            "x-fous-developer": true
          },
          "npm_page_link": {
            "type": "string",
            "format": "uri",
            "description": "Package page on npm."
          },
          "latest_version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Latest published version."
          },
          "weekly_downloads": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Downloads in the past week."
          },
          "last_publish_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Date of the latest package publish."
          }
        },
        "additionalProperties": false
      },
      "description": "Matching packages in npm search order."
    }
  },
  "additionalProperties": false
}
```

## See more

- [npm API: Get package](https://fous.com/methods/npmjs.com/get-package.md): Looks up a public npm package by name or npm link. Returns its latest version, weekly downloads, maintainers, links, dates and version count.
- [npm API: Get download stats](https://fous.com/methods/npmjs.com/get-download-stats.md): Returns total and daily or Monday-start weekly npm downloads for a package over the last week, month, or year.
- [PyPI API: Search packages](https://fous.com/methods/pypi.org/search-packages.md): Searches PyPI by keywords and returns matching packages in relevance order, each with its latest version and that version's release date. Returns up to 100 results.
- [Docker API: Search container images](https://fous.com/methods/hub.docker.com/search-container-images.md): Finds public Docker Hub container images matching a software name, in Docker Hub search order, with publisher, badge, stars, last update and exact total pulls when Docker Hub publishes them. Can keep only Docker Official Images and Verified Publisher images.
- [crates.io API: Search crates](https://fous.com/methods/crates.io/search-crates.md): Finds Rust crates on crates.io by keywords, sorted by relevance, total downloads, recent downloads, or newest creation.
- [Google API: Search Google Play apps](https://fous.com/methods/play.google.com/search-apps.md): Finds Android apps on Google Play by keywords, in Play search order, with each listing's developer, star rating, price and currency for the chosen country, download range and link. Results are limited to apps shown on the public search page.
- [Google API: Search Chrome extensions](https://fous.com/methods/chromewebstore.google.com/search-extensions.md): Finds Chrome Web Store extensions by keywords in store order, with each listing's developer, users, rating, rating count, short description and store link. Some listings omit developer, users or ratings.
- [WordPress.org API: Search plugins](https://fous.com/methods/wordpress.org/search-plugins.md): Searches the WordPress.org plugin directory by description and returns matches in directory search order, with ratings, installations, compatibility and plugin page links.
- [All npm methods](https://fous.com/methods/npmjs.com.md)
