Skip to main content

Collection of all Datadog Public endpoints

Project description

datadog-api-client-python

This repository contains a Python API client for the Datadog API.

Requirements

Building and using the API client library requires Python 3.6+.

Installation

To install the API client library, simply execute:

pip install datadog-api-client

Getting Started

Please follow the installation instruction and execute the following Python code:

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_type import MonitorType

body = Monitor(
    name="example",
    type=MonitorType("log alert"),
    query='logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2',
    message="some message Notify: @hipchat-channel",
    tags=["test:example", "env:ci"],
    priority=3,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.create_monitor(body=body)
    print(response)

Unstable Endpoints

This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to enable these endpoints:

configuration.unstable_operations["<OperationName>"] = True

where <OperationName> is the name of the method used to interact with that endpoint. For example: list_log_indexes, or get_logs_index

Changing Server

When talking to a different server, like the eu instance, change the server_variables on your configuration object:

configuration.server_variables["site"] = "datadoghq.eu"

Disable compressed payloads

If you want to disable GZIP compressed responses, set the compress flag on your configuration object:

configuration.compress = False

Enable requests logging

If you want to enable requests logging, set the debug flag on your configuration object:

configuration.debug = True

Asyncio support

The library supports asynchronous operations when using AsyncApiClient for the transport. When that client is used, the API methods will then return coroutines that you can wait for.

To make async support available, you need to install the extra async qualifiers during installation: pip install datadog-api-client[async].

import asyncio

from datadog_api_client import Configuration, AsyncApiClient
from datadog_api_client.v1.api import dashboards_api

async def main():
    configuration = Configuration()
    async with AsyncApiClient(configuration) as api_client:
        api_instance = dashboards_api.DashboardsApi(api_client)
        dashbooards = await api_instance.list_dashboards()
        print(dashbooards)

asyncio.run(main())

Documentation for API Endpoints and Models

Documentation for API endpoints and models are available on readthedocs.

Documentation for Authorization

Authenticate with the API by providing your API and Application keys in the configuration:

configuration.api_key["apiKeyAuth"] = "YOUR_API_KEY"
configuration.api_key["appKeyAuth"] = "YOUR_APPLICATION_KEY"

Author

support@datadoghq.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datadog-api-client-1.11.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

datadog_api_client-1.11.0-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file datadog-api-client-1.11.0.tar.gz.

File metadata

  • Download URL: datadog-api-client-1.11.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for datadog-api-client-1.11.0.tar.gz
Algorithm Hash digest
SHA256 785364fdd311b775763275f9a0564307a8eb59bc05791a12cafd252dae9a3fe9
MD5 d63fc07578a5af275938118920230abc
BLAKE2b-256 8c5f731fa812e4d61801b4bb1642508789ac469d375422a8c3eb51b6baf9a249

See more details on using hashes here.

Provenance

File details

Details for the file datadog_api_client-1.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datadog_api_client-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e0f014973cacdb207896f70213050f08603827745d827dba433c913e452bc94
MD5 26548abf97aa4f84cd47f68a54145524
BLAKE2b-256 d1dc518355e137e827631e1eaae760497753b49327624123b747d9c4fd20c638

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page