Datadog Site
The Datadog API is an HTTP REST API. The API uses resource-oriented URLs to call the API, uses status codes to indicate the success or failure of requests, returns JSON from all requests, and uses standard HTTP response codes. Use the Datadog API to access the Datadog platform programmatically.
Authenticate to the API with an API key using the header DD-API-KEY
. For some endpoints, you also need an Application key, which uses the header DD-APPLICATION-KEY
.
To try out the API
Note: To authenticate to the Datadog API through Postman, add your Datadog API and Application key values to the Collection variables of the Datadog API collection.
Using the API is a guide to the endpoints.
Notes:
- Add your API and application key values to the Variables tab of the Datadog API Collection.
- cURL code examples assume usage of BASH and GNU coreutils. On macOS, you can install coreutils with the Homebrew package manager:
brew install coreutils
By default, the Datadog API Docs show examples in cURL. Select one of our official client libraries languages in each endpoint to see code examples from that library. To install each library:
Installation
Maven - Add this dependency to your project’s POM:
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>datadog-api-client</artifactId>
<version>2.28.0</version>
<scope>compile</scope>
</dependency>
Gradle - Add this dependency to your project’s build file:
compile "com.datadoghq:datadog-api-client:2.28.0"
Usage
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.Configuration;
import com.datadog.api.<VERSION>.client.api.*;
import com.datadog.api.<VERSION>.client.model.*;
Note: Replace <VERSION>
with v1 or v2, depending on which endpoints you want to use.
Examples
Maven pom.xml
for running examples:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>datadog-api-client</artifactId>
<version>2.28.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Make sure that CLASSPATH
variable contains all dependencies.
export CLASSPATH=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args="%classpath")
Gradle build.gradle
for running examples:
plugins {
id 'java'
id 'application'
}
repositories {
jcenter()
}
dependencies {
implementation 'com.datadoghq:datadog-api-client:2.28.0'
}
application {
mainClassName = 'Example.java'
}
Execute example by running gradle run
command.
Installation
pip3 install datadog-api-client
Usage
import datadog_api_client
Installation
gem install datadog_api_client -v 2.26.1
Usage
require 'datadog_api_client'
Installation
go mod init main && go get github.com/DataDog/datadog-api-client-go/v2/api/datadog
Usage
import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog<VERSION>"
)
Note: Replace <VERSION>
with V1
or V2
, depending on which endpoints you want to use.
Installation
The package is under @datadog/datadog-api-client and can be installed through NPM or Yarn:
# NPM
npm install @datadog/datadog-api-client
# Yarn
yarn add @datadog/datadog-api-client
Usage
import { <VERSION> } from 'datadog-api-client';
Note: Replace <VERSION>
with v1 or v2, depending on which endpoints you want to use.
Installation
Run cargo add datadog-api-client
, or add the following to Cargo.toml
under [dependencies]
:
Usage
Try the following snippet to validate your Datadog API key:
use datadog_api_client::datadog::Configuration;
use datadog_api_client::datadogV1::api_authentication::AuthenticationAPI;
#[tokio::main]
async fn main() {
let configuration = Configuration::new();
let api = AuthenticationAPI::with_config(configuration);
let resp = api.validate().await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Or check out the libraries directly:
Trying to get started with the application instead? Check out Datadogs general
Getting Started docs.
Additional helpful documentation, links, and articles: