New Relic REST API v1

Search form

Working with the New Relic REST API (v1) (deprecated)

Deprecated

Currently New Relic supports two versions of the REST API. Version 1 is deprecated and will eventually be replaced with the newer v2. No termination date has been announced. However, no further development or modifications are being made to v1.

Contents

Video

[video link] For an overview of the New Relic's reporting, alerting, and API features, watch this video (approximately 1-1/2 minutes).

Setup

To use the REST API in any way, be sure to activate API access and get your API key from your account settings. For more information, see API key.

Then, from the command line, you can use:

curl -gH "x-api-key:REPLACE_WITH_YOUR_API_KEY" '<URL>'

OR

wget -qO- --header "x-api-key:REPLACE_WITH_YOUR_API_KEY" '<URL>'

From a Ruby program, use an http helper such as curb. Be sure to set the x-api-key header with every request.

Note: You may be able to use the newrelic_api Ruby gem to do some of these things natively. In this situation, be sure to first set:

NewRelicApi.api_key='REPLACE_WITH_YOUR_API_KEY'

Examples

Here are some practical examples to pull metric data with New Relic's REST API v1 by using the command line or Ruby. If you are looking for an exhaustive guide to using the REST API v1 with cross-linked information to the background methods in the newrelic_api Ruby gem, refer to the documentation for using New Relic's data API access methods.

Account ID (v1)

Many New Relic API calls require both an API key in the call header and an Account ID in the request URI. However, when requesting authorization from users to access New Relic APIs on their behalf, you only need to ask those users for their New Relic API key; you do not need to request their New Relic Account ID.

Make the following call, using only the API key in the header:

https://api.newrelic.com/api/v1/accounts.xml

New Relic will return the Account ID for that API key. The Account ID appears between data-access-key and license-key as id. For example:

New Relic's REST API allows you to configure alert settings. This includes enabling and disabling alerts for applications and servers, as well as getting and setting alert thresholds.

User alert notification settings are also exposed. You can configure whether a user receives email alerts at the account level and tailor settings for individual applications. You can also specify which users receive weekly performance reports. For more information, see Alert API examples (v1).

Servers (v1)

You can use display_name at the server_settings API endpoint to view a list of settings for all servers, view a specific server's settings, or update a server's settings. Here is an example of the display_name setting using CURL:

If you want to take the performance data out of New Relic and use it in some way, you can use the metric data API. It will allow you to get most of the data used in New Relic charts for your own purposes. For more information, see: