• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 ❤️ 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

  • 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 instance 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.

Example

const 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.

Example

const 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

const 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

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

  • params {Object}: URL query parameters to pass along to the couchdb view.
  • returns {Stream}: Streaming results of the query.

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

  • query {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

let 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

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

.url

Build a formatted url with the provided parameters.

Params

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

About

Contributing

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

Please read the contributing guide 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:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

  • base: Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | homepage
  • download-stats: Get and calculate npm download stats for npm modules. | homepage

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.

More Repositories

1

ansi-colors

Easily add ANSI colors to your text and symbols in the terminal. ansi-colors is the official ansi styling library for gulp, and is used by hundreds of other projects, including mocha, enquirer, redwoodjs, leaflet, and many others.
JavaScript
411
star
2

angular-pusher

AngularJS provider and service for Pusher
JavaScript
150
star
3

grunt-convert

Grunt task to convert to or from JSON, YAML, XML, PLIST or CSV.
JavaScript
84
star
4

github-traffic

Get the Github traffic for the specified repository
JavaScript
81
star
5

watch-cli

Watch files and execute an npm script when files change.
JavaScript
59
star
6

group-array

Group array of objects into lists.
JavaScript
55
star
7

sma

Calculate the simple moving average of an array.
JavaScript
55
star
8

octobox.js

Take back control of your GitHub Notifications! (Port of octobox to node.js)
JavaScript
52
star
9

firebase-cron

Store and run cron jobs with firebase.
JavaScript
48
star
10

converter

Library to convert to or from JSON, YAML, XML, PLIST or CSV.
JavaScript
40
star
11

sort-object

Sort the keys in an object.
JavaScript
37
star
12

composer

API-first task runner with three methods: task, run and watch.
JavaScript
35
star
13

grunt-firebase

Grunt task for updating firebase data.
JavaScript
28
star
14

layouts

Wraps templates with layouts. Layouts can use other layouts and be nested to any depth. This can be used 100% standalone to wrap any kind of file with banners, headers or footer content. Use for markdown, HTML, handlebars views, lo-dash templates, etc. Layouts can also be vinyl files.
JavaScript
28
star
15

download-stats

Get and calculate npm download stats for npm modules.
JavaScript
24
star
16

expand-hash

Recursively expands property keys with dot-notation into objects.
JavaScript
23
star
17

github-content

Easily download files from github raw user content.
JavaScript
22
star
18

snake-cli

Experiment / demo using readline-utils to create a simple snake game in the terminal.
JavaScript
21
star
19

stringify-keys

Build an array of key paths from an object.
JavaScript
18
star
20

gulp-convert

Gulp plugin to convert to or from JSON, YAML, XML, PLIST or CSV.
JavaScript
16
star
21

handlebars-helpers-browserify-example

Example using handlebars-helpers in a web browser with browserify.
JavaScript
16
star
22

paginationator

Paginate an array into pages of items.
JavaScript
15
star
23

module-dependents

Get the list of npm modules that depend on the specified npm module.
JavaScript
15
star
24

async-helpers

Use async helpers in template engines like Handlebars and Lodash
JavaScript
14
star
25

dependents-cli

CLI for listing an npm module's dependent projects and their download stats.
JavaScript
13
star
26

gulp-routes

Add middleware to run for specified routes in your gulp pipeline.
JavaScript
13
star
27

detect-file

Uses a breadth-first search, when necessary, to resolve the file path using the correct casing, and verify that the file actually exists. Returns consistent results regardless of case sensitivity of the file path and/or operating system.
JavaScript
12
star
28

capture-stream

Capture stream output.
JavaScript
11
star
29

accountdown-token

Token authentication for accountdown
JavaScript
11
star
30

vinyl-dat

Vinyl adapter for dat
JavaScript
11
star
31

background-process

Run a process in the background, disconnected from the main process.
JavaScript
11
star
32

set-getter

Create nested getter properties and any intermediary dot notation (`'a.b.c'`) paths
JavaScript
11
star
33

unlazy-loader

Webpack loader to transform lazy-cache files into unlazy cached files.
JavaScript
11
star
34

fly-api

Fly.io API wrapper for simplifying REST calls.
JavaScript
10
star
35

ask-once

Only ask a question one time and store the answer.
JavaScript
10
star
36

append-buffer

Append a buffer to another buffer ensuring to preserve line ending characters.
JavaScript
10
star
37

rage

Add console.rage to your applications.
JavaScript
10
star
38

alarm

Set an alarm that will call the given function at the specified time.
JavaScript
10
star
39

koalas

Coalesce for JavaScript. Returns the first value that is not undefined or null.
JavaScript
9
star
40

npm-api-dependents

npm-api plugin for streaming an npm module's dependents information
JavaScript
9
star
41

clone-repos

Clone all of a user's github repositories.
JavaScript
9
star
42

synonyms-cli

CLI for looking up synonyms for given words.
JavaScript
9
star
43

request-info

Get information about an http request.
JavaScript
8
star
44

format-people

Format a list of authors, contributors, or collaborators.
JavaScript
8
star
45

cologne-drone

Control your drone through an API to spray cologne on-demand!
JavaScript
8
star
46

githubbot

Starting point for registering event handlers and handling payloads coming from github webhooks. Allows usage of plugins to extend functionality for individual implementations.
JavaScript
8
star
47

parse-passwd

Parse a passwd file into a list of users.
JavaScript
8
star
48

ask-for-github-auth

Prompt a user for their github authentication credentials and save the results.
JavaScript
8
star
49

sessionify

Easily bind functions, Event Emitters, and Streams to a session cache.
JavaScript
7
star
50

typeof-github-event

Detect the type of github webhook events.
JavaScript
7
star
51

stash-object

Stash the current state of an object and restore at a later time.
JavaScript
7
star
52

base-bot

Simple bot that knows how to handle events when told too. Use base bot to build more complex bots with plugins.
JavaScript
7
star
53

homedir-polyfill

Node.js os.homedir polyfill for older versions of node.js.
JavaScript
7
star
54

question-helper

Ask questions when running templates for Templates, Handlebars, or Lodash.
JavaScript
7
star
55

log-events

Create custom, chainable logging methods that emit log events when called.
JavaScript
7
star
56

fireside

NoBackend required comment system built with AngularJS and Firebase
JavaScript
6
star
57

computed-property

Add computed properties to JavaScript objects.
JavaScript
6
star
58

upsert-value

Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.
JavaScript
6
star
59

dev-link

Run development versions of command line applications.
JavaScript
6
star
60

resolve-file

Resolve an absolute file path from local directories or node modules.
JavaScript
6
star
61

update-contributors

Update contributors property in package.json with current github contributors.
JavaScript
6
star
62

github-metadata

Gather GitHub metadata about a repository.
JavaScript
6
star
63

append-string

Append a string to another string ensuring to preserve line ending characters.
JavaScript
6
star
64

remarkable-mentions

Transform @ mentions into markdown links.
JavaScript
6
star
65

parse-mentions

Parse and optionally replace @ mentions from a string of text.
JavaScript
6
star
66

iterator-sync

Iterate over a stack of functions.
JavaScript
6
star
67

strings

Replace :props in strings, create simple regex parsers, store parsers and prop-strings and run them in any context.
JavaScript
6
star
68

forward-object

Copy properties from an object to another object, where properties with function values will be invoked in the context of the provider, and properties with non-function values are just copied.
JavaScript
6
star
69

gulp-permalinks

Gulp plugin for easily creating permalinks for vinyl files.
JavaScript
6
star
70

iterator-async

Iterate over a stack of async functions.
JavaScript
5
star
71

group-object

Group object keys and values into lists.
JavaScript
5
star
72

simple-moving-avg

Calculate the simple moving average for an array.
JavaScript
5
star
73

fs-read-queue

Queue `fs.readFile` calls to the same file path.
JavaScript
5
star
74

ngraph.frombinary

Deserialize an ngraph.graph from binary format.
JavaScript
5
star
75

engine-react

Template engine for React that can render server side react templates in Template, Assemble, and Verb.
JavaScript
5
star
76

array-std

Calculate the standard deviation of an array of numbers.
JavaScript
5
star
77

error-base

Create custom Error classes.
JavaScript
5
star
78

base-list

JavaScript
5
star
79

remarkable-defaults

Smart default options for the remarkable markdown parser.
JavaScript
5
star
80

map-config

Map configuration objects to application methods.
JavaScript
5
star
81

gulp-gh-clone

Clone github repositories into a specified folder.
JavaScript
5
star
82

context-manager

Manage context for templates.
JavaScript
5
star
83

array-avg

Calculate the average of an array of numbers.
JavaScript
5
star
84

server-side-react

Example application using assemble and engine-react for server-side rendering.
JavaScript
5
star
85

delegate-object

Copy properties from an object to another object, where properties with function values will be invoked in the context of the receiver, and properties with non-function values are just copied.
JavaScript
5
star
86

base-tree

Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.
JavaScript
5
star
87

assemble-push

Push a collection of templates into an assemble stream as vinyl objects.
JavaScript
5
star
88

slack-invite-webtask

Webtask.io service to invite users to a slack team.
JavaScript
5
star
89

get-latest

Get the latest package.json for a module.
JavaScript
4
star
90

express-template

View replacement for Express using Template.
JavaScript
4
star
91

downloads

Retrieve npm download stats for the specified repository or maintainer.
JavaScript
4
star
92

domains-cli

JavaScript
4
star
93

iterator-streams

Iterate over a stack of streams.
JavaScript
4
star
94

copy-task

Copy a task and it's dependencies from one app to another.
JavaScript
4
star
95

to-mention-link

Create links from @ mentions.
JavaScript
4
star
96

assemble-metalsmith

Assemble v0.6.x plugin for running any metalsmith middlewares
JavaScript
4
star
97

slack-users

Get the users of a slack community.
JavaScript
4
star
98

layout-stack

Create a layout stack based on the given layout templates.
JavaScript
4
star
99

neo4j-dotnet-koans

C# implementation of the neo4j-tutorial using Neo4jClient
C#
4
star
100

find-path

Given a search string and a list of file paths, find the closest path.
JavaScript
4
star