Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

New Relic SB SDK

Automate your SRE tasks with ease using the New Relic SB SDK.

Community-Project

PyPI - Supported versions PyPI - Package version PyPI - Downloads PyPI - License Codacy Grade Badge Codacy Coverage Badge Gitlab Pipeline Status

This library provides a robust, typed Python client for the New Relic NerdGraph API, built on top of sgqlc. It simplifies the process of querying and mutating New Relic data, making it easier to build automation tools, monitoring scripts, and custom dashboards.

✨ Features

📋 Requirements

📦 Installation

Using pip

pip install newrelic-sb-sdk

Using uv

uv add newrelic-sb-sdk

🚀 Usage

Here is a simple example of how to use the NewRelicGqlClient to query the current user’s information from New Relic.

import os
from newrelic_sb_sdk.client import NewRelicGqlClient
from sgqlc.operation import Operation

# Initialize the client
# Ensure NEW_RELIC_USER_KEY is set in your environment or pass it directly
client = NewRelicGqlClient(new_relic_user_key=os.getenv("NEW_RELIC_USER_KEY"))

# Create an operation based on the New Relic schema
op = Operation(client.schema.query_type)

# Select fields to query
op.actor.user.__fields__(
    "name",
    "email",
    "id"
)

# Execute the query
response = client.execute(op)

# Access the data as native Python objects
data = op + response.json()
user = data.actor.user

print(f"User: {user.name} <{user.email}> (ID: {user.id})")

For more advanced usage and examples, check out our Documentation and Playground.

🛠️ Development

We welcome contributions! Please see our Contribution Guide for details on setting up your development environment, running tests, and submitting pull requests.

The project uses uv for dependency management and ruff for linting.

📜 Changelog

See the CHANGELOG.md for a history of changes.

👥 Contributors

See our list of contributors.

📄 License

This project is licensed under the Apache License 2.0. See the LICENSE.txt file for details.