npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-newrelic-api

v0.1.7-rc5

Published

Async and Sync Node.js bindings for the New Relic XML and RESTFul APIs into a single one.

Downloads

13

Readme

node-newrelic-api

Travis Dependency Status

Async and Sync Node.js bindings for the New Relic XML and RESTFul APIs into a single one.

NPM

Description

New Relic provides some of their APIs through XML or RESTful JSON endpoints, but they use different hosts, methods. This is a consolidated API that intends to provide bindings to their Public APIs in Node.js using Async and Sync methods.

  • Async: Useful when implementing anything in the event loop for your app.
  • Sync: Useful for bootstrap APIs that needs to be executed sequentially.

The APIs added per version are as follows:

| Version | Feature |------- | --------- | 0.1.1 | * Deployments: Caches the application deployment | ----- | -------- | 0.1.0 | * Accounts: Retrieve account information; (XML v1 API) | | * Application: Retrieve application information; (JSON V2 API) | | * Deployments: Submits application deployment information. (XML V1 API)

By default, APIs are async, and the optional sync method will include the suffix "Sync".

Installation

npm install --save node-newrelic-api

Accounts API

The XML V1 API binds that retrieves information about an account.

  • https://docs.newrelic.com/docs/apm/apis/new-relic-rest-api-v1/getting-started-new-relic-rest-api-v1#account_id

Accounts.get(opts, callback)

Retrieves the account information based on the license information.

  opts: {
    appKey: {string} // The license key provided by New Relic.
  }

  /**
   * @param {object} err Is the possible error related to connectivity with New Relic.
   * @param {object} AccountInfo Is the object information translated from XML V1 API to JSON.
   */
  function callback(err, account) { }

Accounts.getSync(opts) := AccountInfo

The blocking version of the accounts info.


  opts: {
    appKey {string} // The license key provided by New Relic.
  }

Sample

AccountInfo = 
{ name: 'Node.js App',
  subscription: 
   { state: 'paid',
     annualRenewalOn: '2015-09-30',
     startsOn: '2014-01-17',
     productName: 'Enterprise Annual'
  },
  apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  dataAccessKey: 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
  licenseKey: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
  eventFeedUri: '/account_feeds/cccccccccccccccccccccccccccccccccc/events.rss',
  primaryAdmin: 
   { email: '[email protected]',
     state: 'active',
     firstName: 'Marcello',
     lastName: 'de Sales' 
   } 
}

Application API

The JSON V2 API binds that retrieves information about an application. (Lists on next versions)

  • https://docs.newrelic.com/docs/apm/apis/api-explorer-v2/getting-started-new-relics-api-explorer

Applications.get(opts, callback)

Retrieves the application information based on the license information and the name of an app.

  opts: {
    appKey: {string}, // The license key provided by New Relic.
    appName: {string} // The name of the application that you have deployed.
  }

  /**
   * @param {object} err Is the possible error related to connectivity with New Relic.
   * @param {object} AccountInfo Is the object information translated from XML V1 API to JSON.
   */
  function callback(err, app) { }

Applications.getSync(opts) := ApplicationInfo

The blocking version of the application info.

  opts: {
    appKey {string}, // The license key provided by New Relic.
    appName: {string} // The name of the application that you have deployed.
  }

Sample

Sample for the application info:

ApplicationInfo =
{ id: xyxyxyxyxyx,
  name: 'nodejs-sample',
  language: 'nodejs',
  health_status: 'gray',
  reporting: false 
}

Deployments

Provides an API to support the submission of deployments, retrieving the deployment info.

More info at https://rpm.newrelic.com/accounts/xxxxxxx/applications/yyyyyyyy/deployments/instructions

Deployments.get(opts, callback)

Retrieves the deployment information based on the license information and the name of an app.

  opts: {
    appKey: {string}, // The license key provided by New Relic.
    appName: {string} // The name of the application that you have deployed.
    git: {object} // The git object with current version  //
  }

  /**
   * @param {object} err Is the possible error related to connectivity with New Relic.
   * @param {object} deployment Is the object containing the information from XML V1 API to JSON.
   */
  function callback(err, deployment) { }

Deployments.getSync(opts) := DeploymentInfo

The blocking version of the deployments API.

  opts: {
    appKey {string}, // The license key provided by New Relic.
    appName: {string} // The name of the application that you have deployed.
    git: 
  }

Sample

Sample for the application info:

{ id: 'xyxyxyxyx',
  appName: 'nodejs-sample',
  accountId: '0000000',
  agentId: 'zdzdzd',
  changelog: '[First working version] .',
  description: 'Submitted from mdesales@ubuntu (192.168.248.137).',
  revision: '670383',
  timestamp: '2014-12-02T00:53:02-08:00',
  user: 'user' 
} 

Installation

npm install --save node-newrelic-api

Use

The test directory contains examples on how to call the API using the Async and Sync modes. You will need to use:

  • LICENSE_KEY: Your license Key provided by your account.
  • App Name: Usually the name of the app based on the package.json.

Some examples of the output of the current version include:

Contributing

We use the GitFlow branching model http://nvie.com/posts/a-successful-git-branching-model/.

  1. Fork it
  2. Create your feature branch (git checkout -b feature/issue-444-Add-Rest-APIs origin/master --track)
  • Adding the Jira ticket ID helps communicating where this feature is coming from.
  1. Commit your changes (git commit -am 'Fix #444: Add support to REST-APIs')
  • Adding "fix #444" will trigger a link to the GitHub issue #444.
  1. Push to the branch (git push feature/issue-444-Add-Rest-APIS)
  2. Create new Pull Request as indicated by this page or your forked repo.