• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Add or list browser apps via API (v2)

Here are examples of how to use the New Relic REST API (v2) to add apps to or to get a list of your browser apps for a specific API key. This helps you manage deployment outside of New Relic. These API calls are useful, for example, with larger organizations deploying multiple apps, or for integration partners who facilitate New Relic account creation and browser monitoring deployments.

Important

When you add a browser app via API (v2), you can only instrument basic page load timing. To use instrumentation supporting all SPA features, set up single page app monitoring via another method.

Add browser apps

To add an app to New Relic, replace ${API_KEY} with your New Relic API key, and replace ${STRING} with the app's name in the following command. To accomplish the same task from the API Explorer, use your API key and go to rpm.newrelic.com/api/explore > Browser applications > POST create.

Use the following command:

curl -X POST 'https://api.newrelic.com/v2/browser_applications.json' \
-H "X-Api-Key:${API_KEY}" -i \
-H 'Content-Type: application/json' \
-d \
'{
"browser_application": {
"name": ${STRING}
}
}'

The API returns an array of data where the element is a browser application and the data associated with it:

{
"browser_application": {
"id": "integer",
"name": "string",
"browser_monitoring_key": "string",
"loader_script": "string"
}

API (v2) output

Description

Browser app id (integer)

This is the unique identification code for each app in New Relic.

App name (string)

This is the app's name as it appears in the New Relic.

The browser_monitoring_key (string)

This a unique key that is linked to (but is not the same as) the account license key. It is used to indicate the New Relic account where data will be reported. It cannot be used to determine your New Relic account's license key.

Browser monitoring loader_script (string)

The returned loader script is a JSON-encoded JavaScript snippet that is configured with the New Relic license key and application ID. The rest of the script is static and is approximately 10k in size.

The loader script must be inserted into the user’s HTML pages correctly:

  • It must appear in the page's <head> tag before the first script tag. If there are no script tags, put the JavaScript immediately before the </head> (end of head) tag.
  • The entire loader script must be inserted in-line, not as a link to the .js file.

List all browser apps

To view a list of your browser-monitored apps, replace ${API_KEY} with your New Relic API key in the following command. To accomplish the same task from the API Explorer, use your API key and go to rpm.newrelic.com/api/explore > Browser Applications > GET List.

Use the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
-H "X-Api-Key:${API_KEY}" -i

You can use the results to verify the account or name, and to get a copy of the loader script for the app, if needed.

View specific browser apps

View by name:

To view a specific browser app if you know its name, replace ${API_KEY} with your New Relic API key, and replace ${NAME} with your app's name in the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
-H "X-Api-Key:${API_KEY}" -i \
-d "filter[name]=${NAME}"

View by browser application ID:

To view a specific browser app if you know its ID, replace ${API_KEY} with your New Relic API key, and replace ${ID} with your browser application ID in the following command:

curl -X GET 'https://api.newrelic.com/v2/browser_applications.json' \
-H "X-Api-Key:${API_KEY}" -i \
-d 'filter[ids]=${ID}'

View multiple browser apps:

To get information for multiple apps, separate the name or ID values with a comma in these commands; for example:

-d 'filter[ids]=12345,23456'
Copyright © 2024 New Relic Inc.

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