All Projects → DataDog → datadog-api-client-python

DataDog / datadog-api-client-python

Licence: Apache-2.0 license
Python client for the Datadog API

Programming Languages

python
139335 projects - #7 most used programming language
Gherkin
971 projects
Jinja
831 projects
shell
77523 projects

Projects that are alternatives of or similar to datadog-api-client-python

datadog-sidekiq
A Rust app to track Sidekiq enqueued & processed jobs in Datadog
Stars: ✭ 14 (-68.18%)
Mutual labels:  datadog, datadog-api
Ktor-OpenAPI-Generator
Ktor OpenAPI/Swagger 3 Generator
Stars: ✭ 203 (+361.36%)
Mutual labels:  openapi, openapi-generator
SwiftDog
This is an (un)official swift library of the datadog API! Many more features to come, but right now it supports sending metrics and events!
Stars: ✭ 26 (-40.91%)
Mutual labels:  datadog, datadog-api
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-18.18%)
Mutual labels:  openapi, openapi-generator
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+24068.18%)
Mutual labels:  openapi, openapi-generator
ogen
OpenAPI v3 code generator for go
Stars: ✭ 436 (+890.91%)
Mutual labels:  openapi, openapi-generator
intellij-openapi-generator
Intellij Plugin for openapi-generator
Stars: ✭ 73 (+65.91%)
Mutual labels:  openapi, openapi-generator
openapi-generator-go
An opinionated OpenAPI v3 code generator for Go. Use this to generate API models and router scaffolding.
Stars: ✭ 42 (-4.55%)
Mutual labels:  openapi, openapi-generator
laravel-openapi
Generate OpenAPI specification for Laravel Applications
Stars: ✭ 269 (+511.36%)
Mutual labels:  openapi
AlipayOpenapiCpp
支付宝开放平台的C\C++版接入示例代码,包含加签验签\网络请求\参数组装\报文解析等等;仅供商户或开发者参考使用;
Stars: ✭ 44 (+0%)
Mutual labels:  openapi
datadog-trace-agent
Datadog Trace Agent archive (pre-6.10.0)
Stars: ✭ 70 (+59.09%)
Mutual labels:  datadog
apispec-webframeworks
Web framework plugins for apispec (formally in apispec.ext).
Stars: ✭ 25 (-43.18%)
Mutual labels:  openapi
oas
OpenAPI Spec builder in go
Stars: ✭ 15 (-65.91%)
Mutual labels:  openapi
mapi-action
🤖 Run a Mayhem for API scan in GitHub Actions
Stars: ✭ 16 (-63.64%)
Mutual labels:  openapi
microblog-api
A modern (as of 2022) Flask API back end.
Stars: ✭ 218 (+395.45%)
Mutual labels:  openapi
yamlinc
Compose multiple YAML files into one with $include tag. Split Swagger/OpenAPI into multiple YAML files.
Stars: ✭ 103 (+134.09%)
Mutual labels:  openapi
dataclasses-jsonschema
JSON schema generation from dataclasses
Stars: ✭ 145 (+229.55%)
Mutual labels:  openapi
terraform-aws-datadog-forwarders
Terraform module which creates resources on AWS to forward logs/metrics to Datadog 🇺🇦
Stars: ✭ 30 (-31.82%)
Mutual labels:  datadog
advanced-spring-scaffold
This project provides an advanced baseline to help you kick start a Spring project.
Stars: ✭ 21 (-52.27%)
Mutual labels:  openapi
watchdog
DEPRECATED -- Github Bot for Datadog codification
Stars: ✭ 26 (-40.91%)
Mutual labels:  datadog

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.7+.

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)

Authentication

By default the library will use the DD_API_KEY and DD_APP_KEY environment variables to authenticate against the Datadog API. To provide your own set of credentials, you need to set some keys on the configuration:

configuration.api_key["apiKeyAuth"] = "<API KEY>"
configuration.api_key["appKeyAuth"] = "<APPLICATION KEY>"

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

Threads support

You can run API calls in a thread by using ThreadedApiClient in place of ApiClient. API calls will then return a AsyncResult instance on which you can call get to retrieve the result:

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

configuration = Configuration()
with ThreadedApiClient(configuration) as api_client:
    api_instance = dashboards_api.DashboardsApi(api_client)
    result = api_instance.list_dashboards()
    dashboards = result.get()
    print(dashboards)

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())

Pagination

Several listing operations have a pagination method to help consume all the items available. For example, to retrieve all your incidents:

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.incidents_api import IncidentsApi

configuration = Configuration()
configuration.unstable_operations["list_incidents"] = True
with ApiClient(configuration) as api_client:
    api_instance = IncidentsApi(api_client)
    for incident in api_instance.list_incidents_with_pagination():
        print(incident.id)

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

[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].