{"id":15290345,"url":"https://github.com/npm/libnpmsearch","last_synced_at":"2025-10-07T03:33:06.867Z","repository":{"id":46912887,"uuid":"146349815","full_name":"npm/libnpmsearch","owner":"npm","description":"programmatic API for the shiny new npm search endpoint","archived":true,"fork":false,"pushed_at":"2022-01-18T22:23:03.000Z","size":539,"stargazers_count":25,"open_issues_count":0,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-01T16:07:08.363Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/libnpmsearch","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-27T20:23:44.000Z","updated_at":"2023-08-25T22:33:48.000Z","dependencies_parsed_at":"2022-09-26T18:41:13.207Z","dependency_job_id":null,"html_url":"https://github.com/npm/libnpmsearch","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/libnpmsearch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586099,"owners_count":19014028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-cli"],"created_at":"2024-09-30T16:07:18.313Z","updated_at":"2025-10-07T03:33:01.553Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# We've Moved! 🚚\nThe code for this repo is now a workspace in the npm CLI repo.\n\n[github.com/npm/cli](https://github.com/npm/cli)\n\nYou can find the workspace in /workspaces/libnpmsearch\n\nPlease file bugs and feature requests as issues on the CLI and tag the issue with \"ws:libnpmsearch\".\n\n[github.com/npm/cli/issues](https://github.com/npm/cli)\n\n# libnpmsearch\n\n[![npm version](https://img.shields.io/npm/v/libnpmsearch.svg)](https://npm.im/libnpmsearch)\n[![license](https://img.shields.io/npm/l/libnpmsearch.svg)](https://npm.im/libnpmsearch)\n[![Coverage Status](https://coveralls.io/repos/github/npm/libnpmsearch/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmsearch?branch=latest)\n\n[`libnpmsearch`](https://github.com/npm/libnpmsearch) is a Node.js library for\nprogrammatically accessing the npm search endpoint. It does **not** support\nlegacy search through `/-/all`.\n\n## Table of Contents\n\n* [Example](#example)\n* [Install](#install)\n* [Contributing](#contributing)\n* [API](#api)\n  * [search opts](#opts)\n  * [`search()`](#search)\n  * [`search.stream()`](#search-stream)\n\n## Example\n\n```js\nconst search = require('libnpmsearch')\n\nconsole.log(await search('libnpm'))\n=\u003e\n[\n  {\n    name: 'libnpm',\n    description: 'programmatic npm API',\n    ...etc\n  },\n  {\n    name: 'libnpmsearch',\n    description: 'Programmatic API for searching in npm and compatible registries',\n    ...etc\n  },\n  ...more\n]\n```\n\n## Install\n\n`$ npm install libnpmsearch`\n\n### API\n\n#### \u003ca name=\"opts\"\u003e\u003c/a\u003e `opts` for `libnpmsearch` commands\n\nThe following opts are used directly by `libnpmsearch` itself:\n\n* `opts.limit` - Number of results to limit the query to. Default: 20\n* `opts.from` - Offset number for results. Used with `opts.limit` for pagination. Default: 0\n* `opts.detailed` - If true, returns an object with `package`, `score`, and `searchScore` fields, with `package` being what would usually be returned, and the other two containing details about how that package scored. Useful for UIs. Default: false\n* `opts.sortBy` - Used as a shorthand to set `opts.quality`, `opts.maintenance`, and `opts.popularity` with values that prioritize each one. Should be one of `'optimal'`, `'quality'`, `'maintenance'`, or `'popularity'`. Default: `'optimal'`\n* `opts.maintenance` - Decimal number between `0` and `1` that defines the weight of `maintenance` metrics when scoring and sorting packages. Default: `0.65` (same as `opts.sortBy: 'optimal'`)\n* `opts.popularity` - Decimal number between `0` and `1` that defines the weight of `popularity` metrics when scoring and sorting packages. Default: `0.98` (same as `opts.sortBy: 'optimal'`)\n* `opts.quality` - Decimal number between `0` and `1` that defines the weight of `quality` metrics when scoring and sorting packages. Default: `0.5` (same as `opts.sortBy: 'optimal'`)\n\n`libnpmsearch` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch).\nMost options are passed through directly to that library, so please refer to\n[its own `opts`\ndocumentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options)\nfor options that can be passed in.\n\nA couple of options of note for those in a hurry:\n\n* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs.\n\n#### \u003ca name=\"search\"\u003e\u003c/a\u003e `\u003e search(query, [opts]) -\u003e Promise`\n\n`query` must be either a String or an Array of search terms.\n\nIf `opts.limit` is provided, it will be sent to the API to constrain the number\nof returned results. You may receive more, or fewer results, at the endpoint's\ndiscretion.\n\nThe returned Promise resolved to an Array of search results with the following\nformat:\n\n```js\n{\n  name: String,\n  version: SemverString,\n  description: String || null,\n  maintainers: [\n    {\n      username: String,\n      email: String\n    },\n    ...etc\n  ] || null,\n  keywords: [String] || null,\n  date: Date || null\n}\n```\n\nIf `opts.limit` is provided, it will be sent to the API to constrain the number\nof returned results. You may receive more, or fewer results, at the endpoint's\ndiscretion.\n\nFor streamed results, see [`search.stream`](#search-stream).\n\n##### Example\n\n```javascript\nawait search('libnpm')\n=\u003e\n[\n  {\n    name: 'libnpm',\n    description: 'programmatic npm API',\n    ...etc\n  },\n  {\n    name: 'libnpmsearch',\n    description: 'Programmatic API for searching in npm and compatible registries',\n    ...etc\n  },\n  ...more\n]\n```\n\n#### \u003ca name=\"search-stream\"\u003e\u003c/a\u003e `\u003e search.stream(query, [opts]) -\u003e Stream`\n\n`query` must be either a String or an Array of search terms.\n\nIf `opts.limit` is provided, it will be sent to the API to constrain the number\nof returned results. You may receive more, or fewer results, at the endpoint's\ndiscretion.\n\nThe returned Stream emits one entry per search result, with each entry having\nthe following format:\n\n```js\n{\n  name: String,\n  version: SemverString,\n  description: String || null,\n  maintainers: [\n    {\n      username: String,\n      email: String\n    },\n    ...etc\n  ] || null,\n  keywords: [String] || null,\n  date: Date || null\n}\n```\n\nFor getting results in one chunk, see [`search`](#search-stream).\n\n##### Example\n\n```javascript\nsearch.stream('libnpm').on('data', console.log)\n=\u003e\n// entry 1\n{\n  name: 'libnpm',\n  description: 'programmatic npm API',\n  ...etc\n}\n// entry 2\n{\n  name: 'libnpmsearch',\n  description: 'Programmatic API for searching in npm and compatible registries',\n  ...etc\n}\n// etc\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Flibnpmsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Flibnpmsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Flibnpmsearch/lists"}