# search-npm-packages

> Promise based search for npm packages with rating search support

Latest version **1.0.4** (published 2020-02-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install search-npm-packages
pnpm add search-npm-packages
yarn add search-npm-packages
bun add search-npm-packages
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-02-11 |
| First published | 2020-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ZZQ |
| Maintainers | mrzzq |
| Keywords | npm, search |

## Links

- npm: https://www.npmjs.com/package/search-npm-packages
- Repository: https://github.com/ZZZZZZQQQQQQ/search-npm-packages
- Homepage: https://github.com/ZZZZZZQQQQQQ/search-npm-packages#readme
- Issues: https://github.com/ZZZZZZQQQQQQ/search-npm-packages/issues
- npm.io page: https://npm.io/package/search-npm-packages

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.0
- [@types/request](https://npm.io/package/@types/request.md) ^2.48.4

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-02-11
- 1.0.3 — 2020-02-11
- 1.0.2 — 2020-02-08
- 1.0.1 — 2020-02-08
- 1.0.0 — 2020-02-08

## README

# Search npm packages

![version](https://img.shields.io/npm/v/search-npm-packages?style=flat-square)
![licence](https://img.shields.io/npm/l/search-npm-packages?style=flat-square)
![npm type definitions](https://img.shields.io/npm/types/search-npm-packages?style=flat-square)

Promise based package for searching other npm packages in registry.
With rating search support as on the npmjs.com

![ranking search](./img/npm_ranking_search.png)

## Instalation
```shell script
npm i search-npm-packages
# or if you using yarn
yarn add search-npm-packages
```

## Usage



```javascript
const npmSearch = require('search-npm-packages')
```

Or import using TypeScript or ESM

```typescript
import npmSearch from 'search-npm-packages'
```

### Simple search by name

The output will be an array with packages from the register

```typescript
npmSearch({ name: 'telegram' })
    .then(packages => console.log(packages))
    .catch(e => console.error(e))

// output:
/*[
    {
      name: 'telegram',
      scope: 'unscoped',
      version: '1.0.0-alpha.2',
      description: 'NodeJS MTProto API Telegram client library,',
      date: { ts: 1575163205790, rel: '2 months ago' },
      links: {
        npm: 'https://www.npmjs.com/package/telegram',
        homepage: 'https://github.com/gram-js/gramjs#readme',
        repository: 'https://github.com/gram-js/gramjs',
        bugs: 'https://github.com/gram-js/gramjs/issues'
      },
      publisher: {
        name: 'youtwitface',
        avatars: [Object],
        created: [Object],
        email: 'contact@lungers.com'
      },
      maintainers: [ [Object] ],
      keywordsTruncated: false,
      keywords: []
    },
    {
      name: 'winston-telegram',
      scope: 'unscoped',
      version: '2.2.2',
    ...
*/
```

### Search by keywords

For search by keywords use `keywords` option.

> if use the `name` and `keywords` option at the same time. The search will be performed by keywords

```javascript
npmSearch({ keywords: ['backend', 'cli'] })
    .then(packages => console.log(packages))
    .catch(e => console.error(e))

// output:
/*[
    {
        name: '@rucken/cli',
        scope: 'rucken',
        version: '4.1.5',
        description: 'Console tools for create and build Angular7+, Bootstrap, Ionic and NestJS application based on Rucken template',
        keywords: [
          'cli',       'nx',
         'workspace', 'ngx',
         'angular7',  'nestjs',
          'ionic',     'bootstrap',
          'rucken',    'admin',
         'ui',        'backend',
         'mobile',    'frontend'
        ],
        date: { ts: 1557580280060, rel: '9 months ago' },

        ...
*/
```

### Ranking search

You can use ranking search as on the npmjs.com

![ranking search](./img/npm_ranking_search.png)

`ranking` can be `optimal`, `popularity`, `quality` or `maintenance`.

```javascript
npmSearch({
    name: 'torrent',
    ranking: "quality"
})
    .then(packages => packages.forEach(p => {
        console.log(p.links.npm)
    }))

// output:
/*
https://www.npmjs.com/package/torrent
https://www.npmjs.com/package/torrent-extract-hash
https://www.npmjs.com/package/magnet2torrent
...
*/
```

### TypeScript

This package with full TypeScript support. And your IDE can use autocomplete.

![autocomplete](./img/ide_autocomplete.png)

Also you can import `RegistryPackage` type, and `NpmSearchParams`
```typescript
import { RegistryPackage, NpmSearchParams } from "search-npm-packages";
```

---
_Source: https://npm.io/package/search-npm-packages · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
