---
title: "Using the REST API with PHP"
description: "Using the op5 Monitor REST API with PHP enables communication between your application and op5 Monitor. This guide provides setup instructions, prerequisites, and example code to list service states on a specific host."
url: "https://docs.itrsgroup.com/docs/faq/op5/360020251713-op5-monitor-using-the-rest-api-with-php/index.html"
---
## Purpose

The purpose of this document is designed for those who want to get started with developing communications between your own application and the op5 Monitor REST API.

The REST API was introduced in op5 Monitor 5.7.0.

## Prerequisites

**op5 Monitor 5.7.0 or higher is required**

- The user accessing the API must have sufficient Group Rights enabled for the group that the user is member of. This can be enabled via "Configure -> Group Rights -> API"

![OP5 Monitor - Using the REST API with PHP](https://docscdn.itrsgroup.com/faq/images/op5/360020251713-688561-api_group_rights.png)

- Some of the auth\_methods in "/etc/op5/http\_api.yml" must be enabled to be able to access the API.

**/etc/op5/http\_api.yml**

```
---
report:
  limit: 1000
auth_method:
  ninja: true
basic_auth: true
```

**PHP must be compiled with cURL-support**

You can verify if PHP is compiled with cURL by running the following in the terminal. The output should tell you whether cURL is enabled or not)

```
## php -i | grep "cURL support"
cURL support => enabled
```

## The code

In particular, the brief code example below will get a list of all services on a specific host and output their states. The desired result is to list services that are in an OK, WARNING, CRITICAL or an UNKNOWN state.

1. Download and save this file ([api\_example.php](/faq/downloads/op5/360020251713-inline-attachment-1-api_example-20120921.php.tar.gz)), and upload it to a server where you can reach the file with your preferred web browser. Make sure that the server you upload the code to can communicate with the op5 Monitor server you set in the $host variable. Please note that you are required to change the following variables in the code, since they need to reflect the settings in your environment:

- - $username = ""
  - $password = ""
  - $uri = ""
  - $host = ""

As a quick test, you can upload the example code to **/var/www/html/**. This will make the code accessible in a web browser through the URL **https://<YOUR\_OP5\_SERVER/api\_example.php**.

2. Once you are done with saving the file, use your browser to navigate to **api\_example.php** webpage you have created/modified. you will then be presented with a list of all services of the host you entered in step 1.

![OP5 Monitor - Using the REST API with PHP](https://docscdn.itrsgroup.com/faq/images/op5/360020251713-688561-api_example-overview.png)

**WRAP UP**

This is a how-to for users who are new to the op5 Monitor API. Hopefully this how-to has kick-started your knowledge in regards to how to use the API to your advantage; and we'd love to see more customers using the API and start integrating your own customized solutions with it.

## Related downloads

- [api_example-20120921.php.tar.gz](/faq/downloads/op5/360020251713-360030426093-api_example-20120921.php.tar.gz)


