GithubHelp home page GithubHelp logo

wazuh-api's Introduction

Wazuh API PHP Client

Latest Stable Version

The Wazuh API PHP Client is a modern library built on top of Guzzle, providing an efficient interface for interacting with the Wazuh REST API.

Requirements

  • PHP 7 or 8

Installation

The recommended way to install the Wazuh API PHP Client is via Composer, a powerful package manager for PHP:

composer require mtxserv/wazuh-api

Usage

Below is a basic example illustrating how to instantiate the client and retrieve a list of agents:

<?php

use Wazuh\WazuhClient;
use GuzzleHttp\Exception\GuzzleException;
use JsonException;

require_once 'vendor/autoload.php';

// Setup WazuhClient with necessary parameters
$client = new WazuhClient([
    'base_uri' => 'https://wazuh.my.instance:55000',
    'wazuh_user' => 'my_user',
    'wazuh_password' => 'my_password',
    'verify' => true, // SSL Certificate verification
]);

try {
    // Retrieve list of agents
    $response = $client->get('/agents');

    // Decode JSON response and handle JSON exceptions
    try {
        $json = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
    } catch (JsonException $jsonException) {
        echo 'JSON decoding error: ', $jsonException->getMessage(), "\n";
        return;
    }

    var_dump($json);
} catch (GuzzleException $e) {
    echo 'HTTP request error: ', $e->getMessage(), "\n";
}

In this example, we're connecting to a Wazuh instance, authenticating with a username and password, and requesting a list of agents. We're also handling any potential exceptions that might be thrown during this process.

Support

For more examples and usage instructions, please refer to the official Wazuh API documentation.

If you encounter any issues, feel free to open an issue on this GitHub repository.

wazuh-api's People

Contributors

sdieunidou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.