![]() |
VOOZH | about |
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 👁 Run in Postman
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:
brew install coreutilsBy 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:
Maven - Add this dependency to your project’s POM:
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>datadog-api-client</artifactId>
<version>2.56.0</version>
<scope>compile</scope>
</dependency>
Gradle - Add this dependency to your project’s build file:
compile "com.datadoghq:datadog-api-client:2.56.0"
importcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.Configuration;importcom.datadog.api.<VERSION>.client.api.*;importcom.datadog.api.<VERSION>.client.model.*;Note: Replace <VERSION> with v1 or v2, depending on which endpoints you want to use.
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.56.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.56.0'
}
application {
mainClassName = 'Example.java'
}
Execute example by running gradle run command.
pip install datadog
import datadog
pip3 install datadog-api-client
import datadog_api_client
gem install dogapi
require 'dogapi'
gem install datadog_api_client -v 2.55.0
require 'datadog_api_client'
go mod init main && go get github.com/DataDog/datadog-api-client-go/v2/api/datadog
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.
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
import { <VERSION> } from 'datadog-api-client';
Note: Replace <VERSION> with v1 or v2, depending on which endpoints you want to use.
Run cargo add datadog-api-client, or add the following to Cargo.toml under [dependencies]:
datadog-api-client = "0"
Try the following snippet to validate your Datadog API key:
usedatadog_api_client::datadog::Configuration;usedatadog_api_client::datadogV1::api_authentication::AuthenticationAPI;#[tokio::main]asyncfn main(){letconfiguration=Configuration::new();letapi=AuthenticationAPI::with_config(configuration);letresp=api.validate().await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}Or check out the libraries directly:
Additional helpful documentation, links, and articles: