PHPackages                             romainnorberg/datadog-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. romainnorberg/datadog-api

ActiveLibrary

romainnorberg/datadog-api
=========================

The missing DataDog API PHP Wrapper! A lightweight package to fetch metrics from Datadog

v0.6(1y ago)14.0kMITPHPPHP ^8.1CI failing

Since May 10Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/romainnorberg/datadog-api)[ Packagist](https://packagist.org/packages/romainnorberg/datadog-api)[ GitHub Sponsors](https://github.com/romainnorberg)[ RSS](/packages/romainnorberg-datadog-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (8)Versions (10)Used By (0)

 **NON OFFICIAL PACKAGE**

 [![Datadog API](.github/media/logo-horizontal.png?raw=true)](.github/media/logo-horizontal.png?raw=true)

 [![Latest Version on Packagist](https://camo.githubusercontent.com/36c7598c672df93f23ce18d1058ca3ba8833d3c46b2d796260b46dec8bce4a1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6d61696e6e6f72626572672f64617461646f672d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romainnorberg/datadog-api) [![GitHub Tests Action Status](https://camo.githubusercontent.com/b6f05bf7a817277afd59e74e93d41ddace3352f07095092e7c476a3c6616e1e0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f726f6d61696e6e6f72626572672f64617461646f672d6170692f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/romainnorberg/datadog-api/actions?query=workflow%3Arun-tests+branch%3Amaster) [![codecov](https://camo.githubusercontent.com/2731fb17cfdb01d45da6e0be98858ec3d3e917381948fcc425e5cc73f12776f8/68747470733a2f2f636f6465636f762e696f2f67682f726f6d61696e6e6f72626572672f64617461646f672d6170692f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/romainnorberg/datadog-api) [![Total Downloads](https://camo.githubusercontent.com/6ae7923c077c7dbef40d822c38515e1b7f0d8d5e8a802104db409c4bc5cf2690/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6d61696e6e6f72626572672f64617461646f672d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romainnorberg/datadog-api/stats)

 The missing DataDog API PHP Wrapper! A lightweight package to fetch metrics from Datadog

---

Actual scope
------------

[](#actual-scope)

- **Metrics** [doc](https://docs.datadoghq.com/api/v1/metrics/)

    - ✅ Get active list
    - ✅ Get metadata
    - ✅ Query timeseries points
    - Edit metadata
    - Search
    - Submit metrics
- **Downtimes** [doc](https://docs.datadoghq.com/fr/api/v1/downtimes/)

    - ✅ Get all downtimes
    - Cancel a downtime
    - Cancel downtimes by scope
    - Get a downtime
    - Schedule a downtime
    - Update a downtime

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require romainnorberg/datadog-api
```

Usage / examples
----------------

[](#usage--examples)

### Instantiation

[](#instantiation)

```
use Romainnorberg\DataDogApi\DataDogApi;

// Using env (DATADOG_API_KEY & DATADOG_APPLICATION_KEY)
$datadogApi = new DataDogApi();

// Using arguments
$datadogApi = new DataDogApi('', '');
```

### Metrics

[](#metrics)

#### Fetching metrics

[](#fetching-metrics)

```
use Romainnorberg\DataDogApi\DataDogApi;

$datadogApi = new DataDogApi(); // Using env

$metrics = $datadogApi
            ->metrics()
            ->query()
            ->from((new \DateTime())->sub(new \DateInterval('PT1H')))
            ->to(new \DateTime())
            ->query('avg:worker.memory.heapUsed{*}')
            ->handle();
```

#### Get max values for a specific period

[](#get-max-values-for-a-specific-period)

|----^-------|

Using `$metrics->maxPoint()` provide the highest point for the requested period.

```
use Romainnorberg\DataDogApi\DataDogApi;

$datadogApi = new DataDogApi(); // Using env

$metrics = $datadogApi
            ...
            ->query('sum:nginx.net.request_per_s{*}')
            ->handle();

$max = $metrics->maxPoint();
/**
* Romainnorberg\DataDogApi\Model\Metrics\Point {
    +timestamp: 1588269614000
    +value: 68.389493934967
  }
 */
```

Using `$metrics->maxPointBySerie()` provide highest points by serie for the requested period. By example if you query by host, you can retrieve max point by host.

```
use Romainnorberg\DataDogApi\DataDogApi;

$datadogApi = new DataDogApi(); // Using env

$metrics = $datadogApi
            ...
            ->query('sum:nginx.net.request_per_s{*} by{host}')
            ->handle();

$maxBySerie = $metrics->maxPointBySerie();

/*
 * array:4 [
     0 => array:2 [
       "serie" => Romainnorberg\DataDogApi\Model\Metrics\Serie^ {#292
         +aggr: "sum"
         +end: 1588269659000
         +expression: "sum:nginx.net.request_per_s{host:staging}"
         +interval: 1
         +length: 32
         +metric: "nginx.net.request_per_s"
         +pointlist: []
         +scope: "host:staging"
         +start: 1588269548000
       }
       "point" => array:2 [
         0 => 1588269594000.0
         1 => 1.1333215343856
       ]
     ]
     1 => array:2 [
       "serie" => Romainnorberg\DataDogApi\Model\Metrics\Serie^ {#70
         +aggr: "sum"
         +end: 1588269659000
         +expression: "sum:nginx.net.request_per_s{host:frontend1}"
         +interval: 1
         +length: 32
         +metric: "nginx.net.request_per_s"
         +pointlist: []
         +scope: "host:frontend1"
         +start: 1588269548000
       }
       "point" => array:2 [
         0 => 1588269608000.0
         1 => 51.069667634348
       ]
     ]
     ...
 */
```

### Downtimes

[](#downtimes)

#### Get all downtimes

[](#get-all-downtimes)

```
use Romainnorberg\DataDogApi\DataDogApi;

$datadogApi = new DataDogApi(); // Using env

$metrics = $datadogApi
            ->downtime()
            ->list()
            //->currentOnly() // Only return downtimes that are active when the request is made.
            ->handle()
            ->response();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Romain Norberg](https://github.com/romainnorberg)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance65

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~258 days

Recently: every ~449 days

Total

8

Last Release

378d ago

PHP version history (2 changes)v0.1-betaPHP ^7.4

v0.5PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d2089438da6aa35ffc3b53219ca96e8b0ce5a6b495cb7b56619ddc6ad50a6fd?d=identicon)[romainnorberg](/maintainers/romainnorberg)

---

Top Contributors

[![romainnorberg](https://avatars.githubusercontent.com/u/7681951?v=4)](https://github.com/romainnorberg "romainnorberg (19 commits)")

---

Tags

datadogdatadog-apiphpDataDogdatadog-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/romainnorberg-datadog-api/health.svg)

```
[![Health](https://phpackages.com/badges/romainnorberg-datadog-api/health.svg)](https://phpackages.com/packages/romainnorberg-datadog-api)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M192](/packages/simplesamlphp-simplesamlphp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
