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

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¶
Typed Interactions: Leveraging
sgqlcfor type-safe GraphQL queries.Easy Configuration: Simple setup with environment variables or direct initialization.
Comprehensive Coverage: Designed to support key SRE workflows.
Modern Stack: Built with Python 3.10+ and modern tooling.
📋 Requirements¶
Python 3.10.0 or higher
📦 Installation¶
Using pip¶
pip install newrelic-sb-sdkUsing 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.