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 🙏

© 2026 – Pkg Stats / Ryan Hefner

newrelic-api-client

v0.1.7

Published

JavaScript library for working with New Relic APIs

Readme

newrelic-api-test-js Build Status

JavaScript library to test connectivity to New Relic API

How to use

This is just a simple library to test connectivity between NodeJS and New Relic API.

Initial Setup

Clone the repository and run npm install which should install dependencies into node_modules

kahrens@kenbook8u:~/dev/node$ git clone https://github.com/kenahrens/newrelic-api-test-js.git
...
kahrens@kenbook8u:~/dev/node$ cd newrelic-api-test
kahrens@kenbook8u:~/dev/node/newrelic-api-test$ npm install

Setup Your API Keys

This library uses the npm config package to setup your API Keys. There is a basic default.json that shows the 5 keys you can populate, with an account nicknamed newrelic:

  • accountId - you will also see this in the URL bar
  • restKey - overall REST API Key (legacy)
  • adminKey - specific Admin user API Key, used for certain API calls
  • insightsQueryKey - there are keys just for Insights in the Manage Data section

If you configure Environment Variables those will over-ride the values in default.json.

However you can also make your own JSON config file with multiple accounts in there.

Environment Variables

Set 4 environment variables to the correct values for your account, this works if you're using a single account.

  • NEWRELIC_ACCOUNT_ID maps to accountId
  • NEWRELIC_REST_API_KEY maps to restKey
  • NEWRELIC_ADMIN_API_KEY maps to adminKey
  • NEWRELIC_INSIGHTS_QUERY_KEY maps to insightsQueryKey

Multiple Accounts

Here is an example of how to setup a custom JSON file with multiple sets of keys. At runtime you would set NODE_ENV to the name of this config.

{
  "MasterAccount": {
    "accountId": "",
    "restKey": "",
    "adminKey": "",
    "insightsQueryKey": ""
  },
  "SubAccount1": {
    "accountId": "",
    "restKey": "",
    "adminKey": "",
    "insightsQueryKey": ""
  },
  "SubAccount2": {
    "accountId": "",
    "restKey": "",
    "adminKey": "",
    "insightsQueryKey": ""
  }
}

Then in your code you could make the same API call against multiple accounts (of course you could use a variable or whatever):

insights.query(nrql, 'MasterAccount', cb);
insights.query(nrql, 'SubAccount1', cb);
insights.query(nrql, 'SubAccount2', cb);

Partner Account

Gather the PartnerId from your partnership admin console, and the Partner Rest key from the Partnership account.

{
  "configArr": [
    "PartnerName1", "PartnerName2"
  ],
  "PartnerName1": {
    "partnerId": "<PARTNER1_ID>",
    "restKey": "<PARNER1_RESTKEY>"
  },
  "PartnerName2": {
    "partnerId": "<PARTNER2_ID>",
    "restKey": "<PARNER2_RESTKEY>"
  }
}

Execute Tests

You can also run the test cases which is a way to double check things are configured properly.

kahrens:newrelic-api-client-js kahrens$ npm test


> [email protected] test /Users/kahrens/Documents/github/newrelic-api-client-js
> ./node_modules/mocha/bin/mocha



  New Relic Alerts Test
    ✓ gets the list of alert events (5397ms)
    ✓ gets the list of alert policies (195ms)
    ✓ gets a specific alert policy by name (139ms)
    ✓ gets the notification channels (159ms)
    ✓ gets the first page of incidents (957ms)

  New Relic API Test
    ✓ calls the applications api (193ms)
    ✓ gets a specific application (160ms)
    ✓ gets the metricNames for a specific application (324ms)
    ✓ gets the metricData for a specific application (198ms)
    ✓ gets the hosts for a specific application (202ms)
    ✓ gets the instances for a specific application (244ms)
    ✓ gets the deployments for a specific application (143ms)
    ✓ calls the mobile api (165ms)
    ✓ calls the browser api (343ms)
    ✓ calls the keyTransactions api (145ms)
    ✓ calls the servers api (161ms)
    ✓ calls the usages api for apm (145ms)
    ✓ calls the users api (144ms)
    ✓ calls the plugins api (163ms)
    ✓ calls the plugins api with a GUID filter (177ms)
    ✓ gets a specific plugin (153ms)
    ✓ gets the components for this specific plugin (154ms)

  New Relic Dashboards Test
    ✓ gets the list of all Insights Dashboards (289ms)
    ✓ gets the first page of Insights Dashboards (595ms)
    ✓ gets the first dashboard from the list (266ms)
    ✓ creates a copy of the first dashboard (632ms)
    ✓ updates the title of the copied dashboard (614ms)
    ✓ deletes the copied dashboard (253ms)

  New Relic Insights API Test
    ✓ publishes some sample events (240ms)
    ✓ calls the query api (230ms)

  New Relic Pagination Test
    ✓ lists all plugin components (1638ms)
    ✓ gets a specific component (157ms)

  New Relic Synthetics API Test
    ✓ gets the list of all monitors (538ms)
    ✓ gets the list of locations (158ms)
    ✓ creates a ping monitor (670ms)
    ✓ deletes the ping monitor we just created (614ms)


  36 passing (17s)