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.
The REST API command structure follows this template:
GET command could also be a
DELETE, depending on the query intent.
To understand the placeholders, keep reading.
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.
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:
The $APPID 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:
You can retrieve XML data instead of JSON by replacing
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
- 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.
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
See the following docs for example REST API use cases:
- APM examples (how to retrieve metric timeslice data from APM)
- Browser examples (how to retrieve metric timeslice data from browser monitoring). 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)