Skip to content

Commit 2c25705

Browse files
authored
Document auth and pagination (#696)
1 parent 6808286 commit 2c25705

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ apiInstance.getMonitor(params).then((data: v1.Monitor) => {
3939

4040
```
4141

42+
### Authentication
43+
44+
By default the library will use the `DD_API_KEY` and `DD_APP_KEY` environment variables to authenticate against the Datadog API.
45+
To provide your own set of credentials, you need to set the appropriate keys on the configuration:
46+
47+
```typescript
48+
import { v1 } from '@datadog/datadog-api-client';
49+
50+
const configurationOpts = {
51+
authMethods: {
52+
apiKeyAuth: "<API KEY>",
53+
appKeyAuth: "<APPLICATION KEY>"
54+
},
55+
};
56+
57+
const configuration = v1.createConfiguration(configurationOpts);
58+
```
59+
4260
### Unstable Endpoints
4361

4462
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:
@@ -122,6 +140,27 @@ apiInstance.listMonitors().then((data: v1.Monitor[]) => {
122140
}).catch((error:any) => console.error(error)).finally(() => clearTimeout(timeout));
123141
```
124142

143+
### Pagination
144+
145+
Several listing operations have a pagination method to help consume all the items available.
146+
For example, to retrieve all your incidents:
147+
148+
```typescript
149+
import { v2 } from "@datadog/datadog-api-client";
150+
151+
async function main() {
152+
const configuration = v2.createConfiguration();
153+
configuration.unstableOperations["listIncidents"] = true;
154+
const apiInstance = new v2.IncidentsApi(configuration);
155+
156+
for await (const incident of apiInstance.listIncidentsWithPagination()) {
157+
console.log("Got incident " + incident.id);
158+
}
159+
}
160+
161+
main();
162+
```
163+
125164
## Documentation
126165

127166
Documentation for API endpoints can be found in in [Github pages][github pages].

0 commit comments

Comments
 (0)