This page is not yet available in Spanish. We are working on its translation. If you have any questions or feedback about our current translation project, feel free to reach out to us!
Containers
The Containers API allows you to query container data for your organization. See the Container Monitoring page for more information.
"""
Get All Containers returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.containers_apiimportContainersApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=ContainersApi(api_client)response=api_instance.list_containers()print(response)
# Get All Containers returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::ContainersAPI.newpapi_instance.list_containers()
// Get All Containers returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewContainersApi(apiClient)resp,r,err:=api.ListContainers(ctx,*datadogV2.NewListContainersOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ContainersApi.ListContainers`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ContainersApi.ListContainers`:\n%s\n",responseContent)}
// Get All Containers returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.ContainersApi;importcom.datadog.api.client.v2.model.ContainersResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();ContainersApiapiInstance=newContainersApi(defaultClient);try{ContainersResponseresult=apiInstance.listContainers();System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling ContainersApi#listContainers");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get All Containers returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_containers::ContainersAPI;usedatadog_api_client::datadogV2::api_containers::ListContainersOptionalParams;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=ContainersAPI::with_config(configuration);letresp=api.list_containers(ListContainersOptionalParams::default()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get All Containers returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.ContainersApi(configuration);apiInstance.listContainers().then((data: v2.ContainersResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));