• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

How to use our REST API (v2)

New Relic's REST API lets you retrieve data from and push data to New Relic tools, as well as to configure features and perform delete operations. You can also use the API Explorer to understand the data available to you via the REST API, to obtain curl commands, and to see JSON responses.

Setup

The REST API command structure follows this template:

curl  -X GET URL -H "Api-Key:$API_KEY" -d 'PAYLOAD'

The GET command could also be a POST or DELETE, depending on the query intent.

To understand the placeholders, keep reading.

Sugerencia

Our examples use curl as a common command line tool to pull metric timeslice data from the REST API. However, you can use any method to make your REST requests. The curl commands include target URLs, header information, and data which are relevant for any request mechanism.

URL

The API calls require a URL to specify the location from which the data will be accessed. You must replace the placeholder <URL> with the appropriate URL which will change depending on the type of data being requested. In general the URL follows this template:

https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.json

The $APP_ID specifies the exact application or product for which the data is being requested. The information following this parameter will vary depending on the data request.

If you have an EU region account, the URL is:

api.eu.newrelic.com/v2/applications/$APP_ID/metrics/data.json

Sugerencia

You can retrieve XML data instead of JSON by replacing .json with .xml.

API key $API_KEY

New Relic API calls require an API key. This may be one of several API keys:

  • A user key: This is recommended. It's our latest key implementation and has fewer limitations than a REST API key. The user key is also used for our NerdGraph API.
  • A REST API key: This is our older key implementation. For more information about it, see REST API key. If you use this key, the required header is X-Api-Key and not Api-Key.
  • If you have a New Relic partnership account, you'll use a different key: see Partnership authentication.

In our REST API examples, we borrow the API key placeholder $API_KEY from Unix shell programming. Be sure to replace that and other user-specific variables when forming calls.

Query details (PAYLOAD)

The PAYLOAD contains the query details, which define:

  • The metric name you want to query and the value you want to retrieve
  • The defined time range for retrieving metrics
  • (Optional): The average of the metric timeslice data by using summarize

Examples

See the following docs for example REST API use cases:

  • APM examples (how to retrieve metric timeslice data from ).
  • Browser examples (how to retrieve metric timeslice data from ). The REST API only returns the Lite browser agent script. For more information, see this table comparing Lite, Pro, and Pro+SPA types.
  • Infrastructure alert examples
  • Alerts examples (create alert conditions and configure notification channels, and more).
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.