Page tree
Skip to end of metadata
Go to start of metadata

Most pages of openITCOCKPIT are based on our JSON API. You can use the web interface as an "API request generator" to find objects in openITCOCKPIT.


As authorization method, we highly recommend to use API keys!

1. API Keys

Create API Keys by editing your user profile and clicking on the "Create new API Key" button at the bottom of the page.

2. Connect to API with PHP (Example)

PHP example to connect to our API with the PHP GuzzleHTTP client.

# Install Composer

curl -sS | php

# Install Guzzle
php composer.phar require guzzlehttp/guzzle:~6.0

Add host via REST API using GuzzleHTTP
require_once 'vendor/autoload.php';

$client = new GuzzleHttp\Client([
    'base_uri'        => '',
    'headers'         => [
        'Content-Type' => 'application/json',
        'Authorization' => 'X-OITC-API 9346a4444fb4676b4327d8acd44b3d809ed1b14c00dbff253cd56488a4af0e9362a4a77872f1123ecbd328c4502b79694a211edb598d1c69044fa33c52bda3010482f09f61d175fa8d45a4be01d64437'
    'verify'          => false,
    'cookies'         => true,
    'connect_timeout' => 5,
    'timeout'         => 10
try {
    $response = $client->post("/hosts/add.json",
            'body' => json_encode(
                    'Host' => 
                        'name' => 'api host',
                        'address' => '',
                        'container_id' => 1,
                        'hosttemplate_id' => 1,
                        'notification_interval' => NULL,
                        'check_interval' => NULL,
                        'Hostgroup' => [],
                        'retry_interval' => NULL,
    $response_content = json_decode($response->getBody()->getContents(), true);
    	printf('Host was created successfully. Host ID is: %s%s', $response_content['id'], PHP_EOL);
} catch (Exception $e) {
    echo 'Exception catched: ' . $e->getMessage() . PHP_EOL;

3. Use paginator or scroll mode?

We are using two different modes to get ordered data from our lists.

Scroll mode (recommended)

We strongly recommend to use "scroll mode" for all API requests to index and search actions.

In scroll mode, the response will not contain an exact count of how many objects were found in the database for the given filters. So the API performance will be much better.

To determine if more records are available, the API will return a `hasNextPage` field.

To use scroll mode, add `scroll=true` the API URL.

Usage example: Get all hosts where output contains down


Paginator mode

By default API requests are executed in Pagination mode. The API response will contain an exact count of

how many objects where found in the database.

Usage example: How many hosts are in state down.



4. Generate basic API requests using your web browser

It is easy to create create an API request for a index page to get a filtered list of objects.

To create an API URL for e.g. Hosts, use our filtering system at the "Hosts overview" page.

1. Set the desired filter options

2. Open the console in developer tools (press F12 in Firefox/Chrome) in your web browser

Enable XMLHttpRequest logs by clicking the XHR option in the console section.

3. Click the refresh button on the top of the filter box and get your custom API URL in the developer console

Open the shown URL in a new tab and you will get the filtered hosts in JSON format or click on the url and open the params section to get the API parameter.

To get the full API URL or the request headers click on the Headers section.

  • No labels