Socket
Socket
Sign inDemoInstall

npm-api

Package Overview
Dependencies
14
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-api


Version published
Weekly downloads
241K
decreased by-4.32%
Maintainers
1
Install size
9.50 MB
Created
Weekly downloads
 

Package description

What is npm-api?

The npm-api package provides a simple interface to interact with the npm registry programmatically. It allows users to fetch information about packages, users, and other entities on the npm registry.

What are npm-api's main functionalities?

Get Package Information

This feature allows you to fetch detailed information about a specific npm package. In this example, it retrieves information about the 'express' package.

const NpmApi = require('npm-api');
const repo = new NpmApi().repo('express');
repo.package().then(pkg => console.log(pkg));

Get User Information

This feature allows you to fetch information about a specific npm user. In this example, it retrieves information about the user 'isaacs'.

const NpmApi = require('npm-api');
const user = new NpmApi().user('isaacs');
user.info().then(info => console.log(info));

Search for Packages

This feature allows you to search for packages on the npm registry. In this example, it searches for packages related to 'express'.

const NpmApi = require('npm-api');
const npm = new NpmApi();
npm.search('express').then(results => console.log(results));

Other packages similar to npm-api

Readme

Source

npm-api NPM version Build Status

Base class for retrieving data from the npm registry.

Install

Install with npm:

$ npm install npm-api --save

Usage

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

API

NpmApi

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

Example

var npm = new NpmApi();

.view

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

Params

  • name {String}: Name of the couchdb view to work with.
  • returns {Object} View: instance

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

  • name {String}: Name of the couchdb list to work with.
  • view {String|Object}: Name or instance of a view to work with.
  • returns {Object} List: instance

Example

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

.repo

Create an instance of a repo to work with.

Params

  • name {String}: Name of the repo as it's published to npm.
  • returns {Object}: Instance of a Repo model to work with.

Example

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

.maintainer

Create an instance of a maintainer to work with.

Params

  • name {String}: Npm username of the maintainer.
  • returns {Object}: Instance of a Maintainer model to work with.

Example

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

Models

BaseModel

Base model to include common plugins.

Params

  • store {Object}: Cache store intance to use.

Maintainer

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

Params

  • name {String}: Name of the npm maintainer to get information about.
  • store {Object}: Optional cache store instance for caching results. Defaults to a memory store.

Example

var maintainer = new Maintainer('doowb');

.repos

Get the repositories owned by this maintainer.

  • returns {Promise}: Returns array of repository names when promise resolves.

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

  • name {String}: Name of the npm repo to get information about.
  • store {Object}: Optional cache store instance for caching results. Defaults to a memory store.

Example

var repo = new Repo('micromatch');

.package

Get the repo's published package.json.

  • returns {Promise}: Returns the package.json object when promise resolves.

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

  • version {String}: Specific version to retrieve.
  • returns {Promise}: Returns the package.json object for the specified version when promise resolves.

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

  • version {String}: Specific version to retrieve. Defaults to latest.
  • returns {Promise}: Returns the dependencies object for the specified version when promise resolves.

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

  • version {String}: Specific version to retrieve. Defaults to latest.
  • returns {Promise}: Returns the devDependencies object for the specified version when promise resolves.

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

  • prop {String}: Name of the property to get.
  • version {String}: Specific version to retrieve. Defaults to latest.
  • returns {Promise}: Returns the property for the specified version when promise resolves.

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

  • name {String}: Name of couchdb view to use.
  • returns {Object}: instance of View

Example

var view = new View('dependedUpon');

.query

Query the couchdb view with the provided parameters.

Params

  • params {Object}: URL query parameters to pass along to the couchdb view.
  • returns {Promise}: Results of the query when promise is resolved.

Example

view.query({ group_level: 2, startkey: JSON.stringify(['micromatch']), endkey: JSON.stringify(['micromatch', {}])})
  .then(function(results) {
    console.log(results);
  }, function(err) {
    console.log(err);
  });

.url

Build a formatted url with the provided parameters.

Params

  • params {Object}: URL query parameters.
  • returns {String}: formatted url string

List

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

Params

  • name {String}: Name of couchdb list to use.
  • view {Object}: Instance of a View to use with the list.
  • returns {Object}: instance of List

Example

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

.query

Query the couchdb list with the provided parameters.

Params

  • params {Object}: URL query parameters to pass along to the couchdb list.
  • returns {Promise}: Results of the query when promise is resolved.

Example

list.query({ key: JSON.stringify(['micromatch']) })
  .then(function(results) {
    console.log(results);
  }, function(err) {
    console.log(err);
  });

.url

Build a formatted url with the provided parameters.

Params

  • params {Object}: URL query parameters.
  • returns {String}: formatted url string
  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • download-stats: Get and calculate npm download stats for npm modules. | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb, v0.9.0, on March 29, 2016.

Keywords

FAQs

Last updated on 29 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc