API - Introduction

New in Nagios XI 5 is a API that includes far more features and control over the Nagios XI system. This documentation explains how to use the new API to read, write, delete, and update data in the Nagios XI system through commands that are authenticated via Nagios XI API keys. The new API uses JSON instead of XML. However, with the release of Nagios XI 5 there are multiple output formats for the original backend API. It is recommended to use the new API over the old backend API. More information about the original backend API can be found in the backend API URL component.

Getting Started

To gain access to the new API use the URL formatted as such:

http://cammstech.my3cx.ca/nagiosxi/api/v1/

API Sections

The API is split into three separate sections.

  • Objects - The standard read-only backend API that has always been available in Nagios XI. The objects section returns XML or JSON data about objects in Nagios XI including things like object statuses, contacts, contact groups, logs, history, downtime, etc.
  • Config - (Admin Only) Allows adding and removing objects such as hosts and services from Nagios XI.
  • System - (Admin Only) The system section allows managing certain subsystems in Nagios XI and sending commands to Nagios XI/Core.

Authentication

Each user has their own API key to access the API. Normal users are allowed to have read access if the Allow API Access setting is selected in the user management Edit/Create pages. Every admin has full access to the API. Access to the documentation is restricted to users who have API access. Normal XI users, which have read only API access, will only be able to see the documentation about the objects section.

Whether you connect via a browser, cURL, or any other way you will need to pass the API key as a GET variable named apikey just like the example in Getting Started.

Your API Key: 9FlXU94C0fXUkYsPMiEY383F2tqfMenU9L93bsVbKSl47R999M7caq7rWA0Y4nTc

Access Level: Full Access

Basic Usage

The example below is using the GET system/status command which shows general information about this Nagios XI server. Adding pretty=1 to the URL will print the JSON in human readable format like the example below and can be used on any API request that returns output.

Example cURL Request:
curl -XGET "http://cammstech.my3cx.ca/nagiosxi/api/v1/system/status?apikey=9FlXU94C0fXUkYsPMiEY383F2tqfMenU9L93bsVbKSl47R999M7caq7rWA0Y4nTc&pretty=1"
Response JSON:
{
    "instance_id": "1",
    "instance_name": "localhost",
    "status_update_time": "2015-09-21 01:28:06",
    "program_start_time": "2015-09-20 12:21:20",
    "program_run_time": "47212",
    "program_end_time": "0000-00-00 00:00:00",
    "is_currently_running": "1",
    "process_id": "105075",
    "daemon_mode": "1",
    "last_command_check": "1969-12-31 18:00:00",
    "last_log_rotation": "2015-09-21 00:00:00",
    "notifications_enabled": "1",
    "active_service_checks_enabled": "1",
    "passive_service_checks_enabled": "1",
    "active_host_checks_enabled": "1",
    "passive_host_checks_enabled": "1",
    "event_handlers_enabled": "1",
    "flap_detection_enabled": "1",
    "process_performance_data": "1",
    "obsess_over_hosts": "0",
    "obsess_over_services": "0",
    "modified_host_attributes": "0",
    "modified_service_attributes": "0",
    "global_host_event_handler": "xi_host_event_handler",
    "global_service_event_handler": "xi_service_event_handler"
}
<!-- This page requires a web browser which supports frames. --> <h2>Nagios XI</h2> <p align="center"> <a href="https://www.nagios.com/">www.nagios.com</a><br> Copyright (c) 2009-2024 Nagios Enterprises, LLC<br> </p> <p> <i>Note: These pages require a browser which supports frames</i> </p>