Registry / observability / dogapi

dogapi

JSON →
library1.11.1jsnpmunverified

dogapi is a Node.js client library that provides an interface to the Datadog HTTP API, enabling programmatic interaction with Datadog services for metrics, events, dashboards, and more. It is currently at version 2.8.4. This library focuses exclusively on the HTTP API and does not include functionality for interacting with a local `dogstatsd` server; for StatsD, users are directed to alternative packages like `node-dogstatsd`. The release cadence is driven by changes to the Datadog API or internal library improvements. Key differentiators include its direct mapping to the Datadog API endpoints and clear separation from StatsD client concerns, which are often bundled in other monitoring libraries.

npm install dogapi
INSTALL
IMPORT
SIG · DOGAPI
D
dogapi
observabilityjavascriptv1.11.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dogapi
const dogapi = require('dogapi');
import dogapi from 'dogapi';
This library is primarily CommonJS. While Node.js's ESM interop might allow `import dogapi from 'dogapi'`, the recommended and officially supported way is `require()` for this CJS-first package.
dogapi.initialize
const dogapi = require('dogapi'); dogapi.initialize(options);
The library requires initialization with API and application keys before making any API calls. This function sets up the global configuration.
dogapi.metric.send
const dogapi = require('dogapi'); dogapi.metric.send('metric.name', [[now, 50]]);
The argument format for `send` and `send_all` changed significantly in version 2.x.x; consult documentation for correct point formats (e.g., `[[timestamp, value]]` or `value`).

This quickstart demonstrates how to initialize the dogapi client with API keys (using environment variables for security) and subsequently send a custom timed metric and an event to Datadog's HTTP API.

const dogapi = require('dogapi'); const options = { api_key: process.env.DATADOG_API_KEY ?? '', app_key: process.env.DATADOG_APP_KEY ?? '', // For Datadog EU users, uncomment and set the correct host: // api_host: 'app.datadoghq.eu' }; dogapi.initialize(options); const now = Math.floor(new Date().getTime() / 1000); dogapi.metric.send( 'my.application.response_time', [[now, 123.45]], // Example for a timed metric point (v2.x.x format) ['env:production', 'service:web-api'], function(err, results) { if (err) { console.error('Error sending metric:', err); } else { console.log('Metric sent successfully:', results); } } ); dogapi.event.create( { title: 'New Feature Rollout', text: 'Version 2.8.4 deployed with new user management feature.', tags: ['env:production', 'team:devops', 'release:v2.8.4'], alert_type: 'info' }, function(err, results) { if (err) { console.error('Error creating event:', err); } else { console.log('Event created successfully:', results); } } );
Debug
Known issues
breakingThe argument format for `dogapi.metric.send` and `dogapi.metric.send_all` changed significantly in version 2.x.x. The `points` argument now expects `[[timestamp, value]]` or `[value, value2]` or `value` for a single point, instead of the `[timestamp, value]` or `value` in 1.x.x.
fix
Review the official `dogapi` documentation or the README section 'Major changes from 1.x.x to 2.x.x' to correctly format metric points when upgrading from 1.x.x.
affects: >=2.0.0
gotchaUsers on the Datadog EU site (`app.datadoghq.eu`) or other non-US regions must explicitly set the `api_host` option during initialization to their respective regional endpoint (e.g., `app.datadoghq.eu`) to ensure metrics and events are sent to the correct location. The default `api_host` points to the US site.
fix
When calling `dogapi.initialize()`, include `api_host: 'app.datadoghq.eu'` (or your regional host) in the options object.
affects: >=1.0.0
gotchaThis `dogapi` library is solely for interacting with the Datadog HTTP API. It does not provide functionality for `dogstatsd`, which is used for sending metrics via UDP to a local agent. Attempting to use `dogapi` for StatsD purposes will fail.
fix
For Datadog StatsD functionality, use a dedicated StatsD client library such as `node-dogstatsd`, which is designed for UDP communication with the local agent.
affects: >=1.0.0
gotchaDatadog API and Application keys are sensitive credentials and should never be hardcoded directly into your application's source code. Exposing them can lead to unauthorized access and data manipulation within your Datadog account.
fix
Store `DATADOG_API_KEY` and `DATADOG_APP_KEY` securely in environment variables and access them using `process.env.DATADOG_API_KEY` or a secrets management system.
affects: >=1.0.0
Errors
Common errors & fixes
Error: API key or application key missing (or similar error message indicating missing credentials)
The `dogapi.initialize` method was called without providing valid `api_key` and `app_key` in the options object, or the provided keys are incorrect.
fix
Ensure `api_key` and `app_key` are correctly set in the options object passed to `dogapi.initialize()`. Double-check the keys on your Datadog account settings page (https://app.datadoghq.com/account/settings#api).
Metric data is not appearing in Datadog, or appears on the wrong site (e.g., US instead of EU).
The `api_host` configuration is incorrect or missing for users on Datadog's EU region, or other non-US regions. The client is sending data to the default US endpoint.
fix
If you are on Datadog EU, ensure `api_host: 'app.datadoghq.eu'` is explicitly included in the options when calling `dogapi.initialize()`.
Error: Invalid metric point format (e.g., 'points' array expects array of arrays or single value)
Using the pre-2.x.x metric point format (e.g., `[timestamp, value]`) for `dogapi.metric.send` or `dogapi.metric.send_all` with version 2.x.x or later.
fix
Update metric point formats according to version 2.x.x requirements. For `dogapi.metric.send`, use `[[timestamp, value]]` for a single timed value, or `value` for an untimed value. For `dogapi.metric.send_all`, ensure each metric's `points` array contains arrays of `[timestamp, value]` or single values.
Upgrade
Version history
1.11.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Resources
dogapi — npm install dogapi · libregistry