Registry / observability / newrelic-api

newrelic-api

JSON →
library1.0.6pypypi✓ verified 88d ago

The `newrelic-api` library provides a Python interface to interact with the New Relic API v2. It allows users to fetch application data, monitor metrics, and manage various New Relic entities programmatically. Currently at version 1.0.6, it is a community-maintained client that sees infrequent releases, primarily for maintenance and minor enhancements.

pip install newrelic-api
INSTALL
IMPORT
SIG · NEWRELIC-API
N
newrelic-api
observabilitypythonv1.0.6
Install
2.2s avg
Import
—
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.0.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.8MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.2s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AlertConditions
✓ from newrelic_api import AlertConditions
✗ from newrelic_api import NewRelicApi
Applications
✓ from newrelic_api import Applications
✗ from newrelic_api import NewRelicApi
Dashboards
✓ from newrelic_api import Dashboards
✗ from newrelic_api import NewRelicApi

This quickstart initializes the New Relic API client using an API key from an environment variable and fetches a list of applications. It demonstrates basic API interaction and error handling.

import os from newrelic_api import NewRelicApi # Get your New Relic REST API Key (v2) from environment variable # Ensure it's not a License Key or Insights Key NEW_RELIC_API_KEY = os.environ.get('NEW_RELIC_API_KEY', '') if not NEW_RELIC_API_KEY: print("Error: NEW_RELIC_API_KEY environment variable not set.") exit(1) api = NewRelicApi(api_key=NEW_RELIC_API_KEY) try: # Fetch all applications associated with the API key applications = api.get_applications() print(f"Found {len(applications)} applications:") for app in applications: print(f" ID: {app.get('id')}, Name: {app.get('name')}") # Example: Get a specific application by ID (replace with a real ID) if applications: first_app_id = applications[0]['id'] specific_app = api.get_application(first_app_id) print(f"\nDetails for first application ({first_app_id}): {specific_app.get('name')}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
gotchaThe `newrelic-api` package specifically requires a 'New Relic REST API Key (v2)'. Using other New Relic keys, such as a License Key or an Insights Insert/Query Key, will result in authentication failures.
fix
Generate or locate the correct 'New Relic REST API Key (v2)' in your New Relic account settings. Do not confuse it with other key types.
affects: All versions
gotchaNew Relic's APIs are subject to rate limiting. Making too many requests in a short period will result in `429 Too Many Requests` errors. The library does not implement automatic retry or backoff mechanisms.
fix
Implement client-side rate limiting, exponential backoff, or introduce delays between API calls, especially when processing large datasets or making frequent requests.
affects: All versions
gotchaThe Python package name for import is `newrelic_api` (with an underscore), while the PyPI installation name is `newrelic-api` (with a hyphen). This is a common source of `ImportError`.
fix
Always use `from newrelic_api import NewRelicApi` for imports, regardless of how you installed it via `pip install newrelic-api`.
affects: All versions
Upgrade
Version history
1.0.6latest on PyPI · released Apr 4, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
2
Resources