doowb / npm-api

Node.js library for getting info from NPM’s API
https://github.com/doowb/npm-api
MIT License
105 stars 18 forks source link
doowb download-stats downloads maintainers nodejs npm package package-info registry stats

npm-api NPM version NPM monthly downloads NPM total downloads Linux Build Status

Node.js library for getting info from NPM’s API

Please consider following this project's author, Brian Woodward, and consider starring the project to show your :heart: and support.

Install

Install with npm:

$ npm install --save npm-api

Usage

var NpmApi = require('npm-api');

API

NpmApi

NpmApi constructor. Create an instance to work with maintainer and repository information.

Example

let npm = new NpmApi();

.view

Create a new instance of View or get an existing instance to work with npm couchdb views.

Params

Example

var view = npm.view('byUser');

.list

Create a new instance of List or get an existing instance to work with npm couchdb list.

Params

Example

var list = npm.list('sortCount', 'byUser');

.repo

Create an instance of a repo to work with.

Params

Example

var repo =  npm.repo('micromatch');

.maintainer

Create an instance of a maintainer to work with.

Params

Example

var maintainer =  npm.maintainer('doowb');

Models

BaseModel

Base model to include common plugins.

Params

Maintainer

Maintainer constructor. Create an instance of an npm maintainer by maintainer name.

Params

Example

const maintainer = new Maintainer('doowb');

.repos

Get the repositories owned by this maintainer.

Example

maintainer.repos()
  .then(function(repos) {
    console.log(repos);
  }, function(err) {
    console.error(err);
  });

Repo

Repo constructor. Create an instance of an npm repo by repo name.

Params

Example

const repo = new Repo('micromatch');

.package

Get the repo's published package.json.

Example

repo.package()
  .then(function(pkg) {
    console.log(pkg);
  }, function(err) {
    console.error(err);
  });

.version

Get the repo's published package.json value for the specified version.

Params

Example

repo.version('0.2.0')
  .then(function(pkg) {
    console.log(pkg);
  }, function(err) {
    console.error(err);
  });

.dependencies

Get the repo's dependencies for the specified version.

Params

Example

repo.dependencies()
  .then(function(dependencies) {
    console.log(dependencies);
  }, function(err) {
    console.error(err);
  });

.devDependencies

Get the repo's devDependencies for the specified version.

Params

Example

repo.devDependencies()
  .then(function(devDependencies) {
    console.log(devDependencies);
  }, function(err) {
    console.error(err);
  });

.prop

Get the specified property from the repo's package.json for the specified version.

Params

Example

repo.prop('author')
  .then(function(author) {
    console.log(author);
  }, function(err) {
    console.error(err);
  });

Registry queries

View

View constructor. Create an instance of a view associated with a couchdb view in the npm registry.

Params

Example

const view = new View('dependedUpon');

.query

Query the couchdb view with the provided parameters.

Params

Example

let results = await view.query({
  group_level: 2,
  startkey: JSON.stringify(['micromatch']),
  endkey: JSON.stringify(['micromatch', {}])
});

.stream

Query the couchdb view with the provided parameters and return a stream of results.

Params

Example

view.stream({
  group_level: 2,
  startkey: JSON.stringify(['micromatch']),
  endkey: JSON.stringify(['micromatch', {}])
})
.on('data', (data) => {
  console.log(data);
});

.url

Build a formatted url with the provided parameters.

Params

List

List constructor. Create an instance of a list associated with a couchdb list in the npm registry.

Params

Example

let list = new List('dependedUpon', view);

.query

Query the couchdb list with the provided parameters.

Params

Example

let results = await list.query({ key: JSON.stringify(['micromatch']) })

.url

Build a formatted url with the provided parameters.

Params

About

Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
Running Tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ```
Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ```

Related projects

You might also be interested in these projects:

Contributors

Commits Contributor
115 doowb
1 0xflotus
1 Hypnosphi
1 NachmanBerkowitz

Author

Brian Woodward

License

Copyright © 2021, Brian Woodward. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on January 20, 2021.