Using the Red Hat Insights API


Red Hat Insights 1-latest

Red Hat Customer Content Services

Abstract

This document describes the web services available to integrate Insights for Red Hat Enterprise Linux with external applications. The Insights for Red Hat Enterprise Linux RESTful APIs are implemented as standard REST HTTP requests and responses of content type JSON.
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright's message.

Chapter 1. Interacting with Red Hat Insights APIs

Red Hat Insights for Red Hat Enterprise Linux is a predictive analytics service that helps identify and remediate security, performance, and availability threats to your Red Hat infrastructure. Insights for Red Hat Enterprise Linux is built on APIs (Application Program Interfaces) that supply data and functionality to its various applications. The Insights front end (the user interface, or UI) directly communicates with the back end API (the server) to retrieve and display information. You can interact with Insights through the UI, or create your own custom clients to connect directly to the back end API.

You can use API commands to interact with web services to perform various operations, such as retrieving data, sending data, updating records, and deleting records. Using APIs to interact with Insights enables you to perform Insights operations synchronously or asynchronously, depending on the service and endpoint. The Inventory export service is an example of an asynchronous operation, but most operations work synchronously. You can incorporate API calls into your web-based applications, and you can even automate them.

Using APIs presents many advantages, including:

  • Better security — Instead of granting users access to data on your server, you can create a structured URL that they can use to request information. This helps to protect sensitive data.
  • APIs allow computers to interact directly with other computers.
  • APIs can be scripted. You can configure automation to run scripts on demand.

Insights APIs follow the OpenAPI specification. By default, all Insights API resources are represented in application/json format. In addition, you can also export reports, inventory and maintenance plans as text/csv.

1.1. About REST API and HTTP methods

REST (Representational State Transfer) API is a set of rules and conventions for building and interacting with web services. REST APIs use URLs as resources to communicate with servers using HTTP requests.

HTTP methods perform CRUD (Create, Read, Update, and Delete) operations on API resources. The most common HTTP methods used are:

  • GET (retrieve data)
  • POST (send data)
  • PUT (insert data)
  • DELETE (remove data)
  • PATCH (update data)

An API request (also known as an API call) requests that the server perform the operation that the HTTP method describes (for example, GET) from the location that the request specifies.

Additional resources

1.2. Response Codes

APIs return numerical status codes that indicate whether an API call was successfully processed by the server. If the call fails, the server returns a status code that describes the reason for the failure. The following table shows types of API response codes:

Expand

Response code

Response

Description

100/1xx

Request received

Informational codes. The server has received the request.

200/2xx

Success

200 = The server has successfully processed the request.

2xx = The request has succeeded, and more information is available.

300/3xx

Redirect

The URL/URI of the requested resource exists at a different location than the one you requested.

400/4xx

Client Error

The request failed.

400 = Bad request

404 = Server not found/resource not found

4xx = The request failed, and the cause of the failure is described.

500/5xx

Server Error

The server cannot handle the request.

Additional resources

You can use either of two methods to authenticate to Red Hat Insights APIs:

  • Token-based service accounts, or
  • Certificate-based authentication

The Red Hat Insights API cheat sheet PDF contains step-by-step instructions to authenticate using either method. To download the cheat sheet, navigate to API Cheat sheet.

Note

You must have login access to developers.redhat.com to access the API cheat sheet.

2.1. Obtaining access tokens

Both authentication methods require access tokens. To obtain an access token, you can:

2.2. Configuring service account access

Procedure

  1. From the Red Hat Hybrid Cloud Console, Click the Settings icon and select Service Accounts.
  2. Click Create service account to set up the account.
  3. Enter a Service account name and a Short description, and click Create. The Red Hat Hybrid Cloud Console creates the service account and displays the unique Client ID and Client secret for the account.
  4. Copy the generated Client ID and Client secret values to a secure location. You need to specify these credentials when configuring a connection to a service.

    Important

    The Client secret displays only once, so ensure that you have successfully and securely saved the copied credentials before closing the credentials window.

  5. After you save the Client ID and secret to a secure location, select the confirmation check box in the credentials window and close the window. The service account and its Client ID appear on the Service Accounts page.
  6. Add the service account to the applicable User Access Groups.

    Note

    Service accounts do not inherit permissions from Default access groups, so you must place them in a User Group to grant them access permissions.

  7. At the command line, use a curl command with Red Hat single sign-on (SSO) to generate an access token. Use the service account credentials that you generated in place of <client_id> and <client_secret>.

    curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openidconnect/token -d "grant_type=client_credentials" -d "scope=api.console" -d client_id=<client_id> -d client_secret=<client_secret>
    Copy to Clipboard Toggle word wrap
    Note
  8. Red Hat Single Sign-On (SSO) responds with a JSON object containing an access token. You can use this access token to make authenticated requests to APIs. To make a request, include the access token generated in the previous step in an Authorization: Bearer HTTP header in your request. Substitute the access token for <access_token>.

    Authorization: Bearer <access_token>
    Copy to Clipboard Toggle word wrap

2.3. Generating an offline access token

Procedure

  1. Log in to the Red Hat Customer Portal with your username and password.

    Note

    You can no longer log in to your Red Hat account with your email unless your email is your Red Hat login. For more information, see Finding your Red Hat login.

  2. Navigate to the Red Hat API Tokens page.
  3. Click Generate Token to generate an offline token.
  4. At the command line, use a curl command to generate an access token. Use the offline token that you generated in place of <offline_token>.

    curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openidconnect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=<offline_token>
    Copy to Clipboard Toggle word wrap
  5. Copy the generated access token and save it in a secure location. You can use this access token to make authenticated requests to APIs.
  6. To make a request, include the access token in an Authorization: Bearer HTTP header in your API call. Substitute the access token for <access_token>.

    Authorization: Bearer <access_token>
    Copy to Clipboard Toggle word wrap
Important

Save the token. The Red Hat API Tokens page displays each token only once, and does not store tokens. Offline access tokens generated from the Red Hat API Tokens page expire after 30 days of inactivity.

Additional resources

Chapter 3. Making API calls

There are multiple ways to make API calls to the Red Hat Insights APIs. Some of the available methods include:

  • Using the curl command from your command line or script
  • Accessing the Insights API documentation within the Hybrid Cloud Console
  • Referring to the legacy documentation within the Hybrid Cloud Console
  • Making calls through a Python interpreter or other programming languages in your client code
Important

You should have a service account set up and configured for authentication in the application or system that will be performing the API calls. For more information about authentication, see Chapter 2, Configuring Authentication with Insights APIs.

The Red Hat Developers API Catalog helps you to create valid API calls in a variety of languages and formats, including curl commands. For example, you can send an API call in a curl command or embed a python-formatted API call in python code. Using the GET/api/insights/v1/account API call in the command or in code returns a list of all known accounts by Organization ID (org_id).

3.1. Using the curl command

You can use the curl command to communicate with a server over HTTP without having to use a browser. curl is useful for making quick requests from the command line, such as requesting status, making updates to parameters, or requesting the values for specific parameters.

Note

This example procedure uses the Advisor API endpoint.

Prerequisites

  • You have an access token that you obtained from your service account or from an offline access token for authentication.
  • The service account has the necessary permissions to interact with the requested endpoint.

Procedure

  1. Open the API catalog in a web browser. The API catalog lists available APIs for Insights and other services.
  2. Select Advisor from the catalog. The Insights Advisor API page opens. The page lists the base URL of the Advisor API and any requirements for authentication.
  3. Under the Operations list, click the drop-down arrow next to GET /api/insights/v1/account.

    The description for the operation includes parameters you can use to refine your API call, and also expected responses from the server. In addition, the panel on the right side of the page has sample code to perform the API call in many languages.

  4. In the panel, click the drop-down and select CURL from the list of options. The panel displays sample code for the GET operation, formatted as a curl command.
  5. Copy the sample code and paste it into your command line or into an existing code file where you want to invoke the GET command.

    # curl --request GET \
    --url https://console.redhat.com/api/insights/v1/account/ \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json'
    Copy to Clipboard Toggle word wrap
  6. Paste your access token in place of <token>.
  7. Press Enter to invoke the command.

If the command line returns a response of 200, your API call was successful. In addition to a successful response and an optional description of the operation, the server returns the data you requested.

If the command line returns a response other than 200, refer to Response Codes to determine how the API call failed and how to remedy the reason for the failure.

Additional resources

  • The Red Hat Insights API cheat sheet contains information about how to authenticate your API access, and includes examples of common queries for Insights services. The cheat sheet also contains examples for python and for Ansible. To download the cheat sheet, navigate to Red Hat Insights API cheat sheet.
  • Red Hat Developers API catalog: https://developers.redhat.com/api-catalog

The Insights API Catalog and Documentation page in the Red Hat Hybrid Cloud Console describes each operation you can perform with the Red Hat Insights API. The documentation describes how to create API requests in multiple languages and formats. You can copy the requests and then use them within your own code to make the API calls.

The Red Hat Developers API Catalog shows you how to create valid API calls in a variety of languages and formats, including python code. For example, the GET/api/insights/v1/account API call returns a list of all known accounts by Organization ID (org_id).

Note

This example procedure uses the Advisor API endpoint.

Prerequisites

  • You have the programming language you want to use (for example, python) installed on your system.
  • You have an access token that you obtained from your service account or from an offline access token.
  • You have a service account configured with necessary permissions.

Procedure

  1. Open the API catalog in a web browser. The API catalog lists available APIs for Insights and other services.
  2. Select Advisor from the catalog. The Insights Advisor API page opens. The page lists the base URL of the Advisor API and any requirements for authentication.
  3. Under the Operations list, click the drop-down arrow next to GET /api/insights/v1/account. The description for the operation includes parameters you can use to refine your API call, as well as expected responses from the server. In addition, the panel on the right side of the page generates an example API call for the GET operation in multiple programming languages.
  4. In the panel, click the drop-down and select the programming language that you prefer (for example, Python) from the list of options. The panel displays sample code for the GET operation, formatted in Python syntax.
  5. Copy the sample code and paste it into a Python code file where you want to invoke the GET command. For example:

    import requests
    
    url = "https://console.redhat.com/api/insights/v1/account/"
    
    headers = {
       "Authorization": "Bearer <token>",
       "Content-Type": "application/json"
    }
    
    response = requests.get(url, headers=headers)
    
    print(response.json())
    Copy to Clipboard Toggle word wrap
  6. Paste your authorization key for authentication in place of <token>.
  7. Press Enter to run your code.

If the server returns a response of 200, your API call was successful. In addition to a successful response and an optional description of the operation, the server returns the data you requested.

If the code returns a response other than 200, refer to Response Codes to determine how the API call failed and how to remedy the reason for the failure.

3.2.1. Viewing data formats and schemas

The data formats and schemas for Red Hat Insights API calls display the formats and types for data returned with server responses. You can use this information in your code as well as for troubleshooting unexpected results.

Note

This example uses the Advisor service.

Procedure

  1. Open the API catalog in a web browser. The API catalog lists available APIs for Insights and other services.
  2. Select Advisor from the catalog. The Insights Advisor API page opens. The page lists the base URL of the Advisor API and any requirements for authentication.
  3. Under the Operations list, click the drop-down arrow next to GET /api/insights/v1/account. The Operations section contains the query parameters you need to specify in an API call and the expected format of each parameter (for example, integer).
  4. To see the format for the server response, click the drop-down arrow next to the Responses section. The section shows an example of data that the API returns with a successful response.
  5. To see the formats for the returned data, click the Schema link next to the server response (for example, PaginatedOrgIdList). The page shows the schema for the data in the response, as well as the formats and types of all of the components that make up the data (for example, org_id is a string, and count is an integer).

3.3. Using the Legacy API documentation

The Red Hat Hybrid Cloud Console contains auto-generated legacy Swagger documentation for Insights API operations. You can customize the provided example code for API calls, execute the requests from within the documentation, and receive the server response code.

Prerequisites

  • You are logged in to the Red Hat Hybrid Cloud Console.
  • You have the necessary permissions to perform the queries.

Procedure

  1. Navigate to the API documentation page in the Red Hat Hybrid Cloud Console.
  2. Select the application that you want to use from the list (for example, Advisor). The page for the application displays, with a list of all the operations you can request for that application.
  3. Select the operation that you want to perform (for example, Advisor > account > GET /api/insights/v1/account).
  4. Click the drop-down arrow for the operation. The Swagger documentation page describes the operation and lists the parameters you can use to refine your request. The page also shows the JSON format for a successful server response.
  5. Click Try It Out. The page displays the format of a successful server response. If the operation you selected requires a value for a parameter (for example, org_id), enter the value in the blank.
  6. Click Execute. The page displays a curl request to the server, the request URL, and the server response.

    1. To copy the curl request to the clipboard, click the clipboard icon on the right side of the curl request.
    2. To copy the server response to the clipboard, click the clipboard icon in the top right corner.
    3. To download the server response as a JSON file, click Download.
  7. Optional: To clear the server response and retry the command, click Clear.

You can use the generated requests in your own code to perform API calls to the Insights API server. For POST requests, you can paste formatted data into the Request Body section of the request and select the format for the data (for example, application/json).

For detailed information about the parameters, schemas, and descriptions for each operation, click the View JSON or RAW links on the API Documentation page. Both links display the operations, required formats for parameters, detailed descriptions for each operation, and the required information within each schema. The RAW link also displays information about the header information for both server requests and responses.

For more examples of common requests using Insights APIs, download the Red Hat Insights API cheat sheet.

Note

You must have a login at developers.redhat.com to download the cheat sheet.

Providing feedback on Red Hat documentation

We appreciate and prioritize your feedback regarding our documentation. Provide as much detail as possible, so that your request can be quickly addressed.

Prerequisites

  • You are logged in to the Red Hat Customer Portal.

Procedure

To provide feedback, perform the following steps:

  1. Click the following link: Create Issue
  2. Describe the issue or enhancement in the Summary text box.
  3. Provide details about the issue or requested enhancement in the Description text box.
  4. Type your name in the Reporter text box.
  5. Click the Create button.

This action creates a documentation ticket and routes it to the appropriate documentation team. Thank you for taking the time to provide feedback.

Legal Notice

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat