@deepgram/sdk 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +307 -68
  2. package/dist/billing.d.ts +4 -4
  3. package/dist/helpers/secondsToTimestamp.d.ts +1 -1
  4. package/dist/httpRequest.d.ts +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/invitation.d.ts +5 -5
  7. package/dist/keys.d.ts +3 -3
  8. package/dist/members.d.ts +6 -6
  9. package/dist/projects.d.ts +7 -7
  10. package/dist/scopes.d.ts +5 -5
  11. package/dist/transcription/index.d.ts +5 -5
  12. package/dist/transcription/preRecordedTranscription.d.ts +1 -1
  13. package/dist/types/alternatives.d.ts +1 -1
  14. package/dist/types/balance.d.ts +3 -1
  15. package/dist/types/balanceList.d.ts +3 -1
  16. package/dist/types/channel.d.ts +1 -1
  17. package/dist/types/createKeyOptions.d.ts +1 -1
  18. package/dist/types/entity.d.ts +1 -1
  19. package/dist/types/error.d.ts +1 -1
  20. package/dist/types/hit.d.ts +1 -1
  21. package/dist/types/invitationList.d.ts +3 -1
  22. package/dist/types/invitationOptions.d.ts +1 -1
  23. package/dist/types/key.d.ts +3 -1
  24. package/dist/types/keyResponse.d.ts +3 -1
  25. package/dist/types/keyResponseObj.d.ts +1 -1
  26. package/dist/types/keyword.d.ts +1 -1
  27. package/dist/types/liveTranscriptionOptions.d.ts +1 -1
  28. package/dist/types/liveTranscriptionResponse.d.ts +1 -1
  29. package/dist/types/member.d.ts +1 -1
  30. package/dist/types/memberList.d.ts +3 -1
  31. package/dist/types/message.d.ts +3 -1
  32. package/dist/types/metadata.d.ts +9 -1
  33. package/dist/types/paragraph.d.ts +1 -1
  34. package/dist/types/paragraphGroup.d.ts +1 -1
  35. package/dist/types/prerecordedTranscriptionOptions.d.ts +2 -2
  36. package/dist/types/prerecordedTranscriptionResponse.d.ts +13 -10
  37. package/dist/types/project.d.ts +3 -1
  38. package/dist/types/projectPatchRequest.d.ts +1 -1
  39. package/dist/types/projectPatchResponse.d.ts +3 -1
  40. package/dist/types/projectResponse.d.ts +3 -1
  41. package/dist/types/requestFunction.d.ts +4 -3
  42. package/dist/types/scopeList.d.ts +3 -1
  43. package/dist/types/search.d.ts +1 -1
  44. package/dist/types/sentence.d.ts +1 -1
  45. package/dist/types/summary.d.ts +1 -1
  46. package/dist/types/toggleConfigOptions.d.ts +1 -1
  47. package/dist/types/topic.d.ts +1 -1
  48. package/dist/types/topicGroup.d.ts +1 -1
  49. package/dist/types/transcriptionSource.d.ts +5 -4
  50. package/dist/types/translation.d.ts +1 -1
  51. package/dist/types/usageCallback.d.ts +1 -1
  52. package/dist/types/usageField.d.ts +3 -1
  53. package/dist/types/usageFieldOptions.d.ts +1 -1
  54. package/dist/types/usageOptions.d.ts +2 -2
  55. package/dist/types/usageRequest.d.ts +3 -1
  56. package/dist/types/usageRequestDetail.d.ts +1 -1
  57. package/dist/types/usageRequestList.d.ts +3 -1
  58. package/dist/types/usageRequestListOptions.d.ts +1 -1
  59. package/dist/types/usageRequestMessage.d.ts +1 -1
  60. package/dist/types/usageResponse.d.ts +3 -1
  61. package/dist/types/usageResponseDetail.d.ts +1 -1
  62. package/dist/types/utterance.d.ts +1 -1
  63. package/dist/types/wordBase.d.ts +1 -1
  64. package/dist/usage.d.ts +7 -7
  65. package/package.json +3 -2
package/README.md CHANGED
@@ -2,109 +2,354 @@
2
2
 
3
3
  [![CI](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml/badge.svg)](https://github.com/deepgram/node-sdk/actions/workflows/CI.yml) [![npm (scoped)](https://img.shields.io/npm/v/@deepgram/sdk)](https://www.npmjs.com/package/@deepgram/sdk) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-rounded)](CODE_OF_CONDUCT.md)
4
4
 
5
- Official Node.js SDK for [Deepgram](https://www.deepgram.com/)'s automated
6
- speech recognition APIs.
5
+ Official Node.js SDK for [Deepgram](https://www.deepgram.com/). Start building with our powerful transcription & speech understanding API.
6
+
7
+ > ### Deprecated JS Browser SDK
8
+ >
9
+ > As of version 2.x, the JS Browser SDK was removed from the Node SDK and will become an independent Client SDK.
10
+ > To use the older SDK, please `npm i @deepgram/sdk@1.2.1` and use `@deepgram/sdk/browser`.
11
+
12
+ - [Deepgram Node.js SDK](#deepgram-nodejs-sdk)
13
+ - [Getting an API Key](#getting-an-api-key)
14
+ - [Installation](#installation)
15
+ - [Constructor](#constructor)
16
+ - [Transcription](#transcription)
17
+ - [Remote Files](#remote-files)
18
+ - [Local Files](#local-files)
19
+ - [Live Audio](#live-audio)
20
+ - [Projects](#projects)
21
+ - [Get Projects](#get-projects)
22
+ - [Get Project](#get-project)
23
+ - [Update Project](#update-project)
24
+ - [Delete Project](#delete-project)
25
+ - [Keys](#keys)
26
+ - [List Keys](#list-keys)
27
+ - [Get Key](#get-key)
28
+ - [Create Key](#create-key)
29
+ - [Delete Key](#delete-key)
30
+ - [Members](#members)
31
+ - [Get Members](#get-members)
32
+ - [Remove Member](#remove-member)
33
+ - [Scopes](#scopes)
34
+ - [Get Member Scopes](#get-member-scopes)
35
+ - [Update Scope](#update-scope)
36
+ - [Invitations](#invitations)
37
+ - [List Invites](#list-invites)
38
+ - [Send Invite](#send-invite)
39
+ - [Delete Invite](#delete-invite)
40
+ - [Leave Project](#leave-project)
41
+ - [Usage](#usage)
42
+ - [Get All Requests](#get-all-requests)
43
+ - [Get Request](#get-request)
44
+ - [Summarize Usage](#summarize-usage)
45
+ - [Get Fields](#get-fields)
46
+ - [Billing](#billing)
47
+ - [Get All Balances](#get-all-balances)
48
+ - [Get Balance](#get-balance)
49
+ - [Development and Contributing](#development-and-contributing)
50
+ - [Getting Help](#getting-help)
51
+
52
+ # Getting an API Key
53
+
54
+ 🔑 To access the Deepgram API you will need a [free Deepgram API Key](https://console.deepgram.com/signup?jump=keys).
55
+
56
+ # Installation
7
57
 
8
- > This SDK only supports hosted usage of api.deepgram.com.
58
+ ```bash
59
+ npm install @deepgram/sdk
60
+ # - or -
61
+ # yarn add @deepgram/sdk
62
+ ```
9
63
 
10
- To access the API you will need a Deepgram account. Sign up for free at
11
- [signup][signup].
64
+ # Constructor
12
65
 
13
- ## Documentation
66
+ ```js
67
+ const { Deepgram } = require("@deepgram/sdk");
68
+ // - or -
69
+ // import { Deepgram } from "@deepgram/sdk";
14
70
 
15
- Full documentation of the Node.js SDK can be found on the
16
- [Deepgram Developer Portal](https://developers.deepgram.com/sdks-tools/sdks/node-sdk/).
71
+ const deepgram = new Deepgram(DEEPGRAM_API_KEY);
72
+ ```
17
73
 
18
- You can learn more about the full Deepgram API at [https://developers.deepgram.com](https://developers.deepgram.com).
74
+ # Transcription
19
75
 
20
- ## Installation
76
+ ## Remote Files
21
77
 
22
- ### With NPM
78
+ ```js
79
+ const response = await deepgram.transcription.preRecorded(
80
+ { url: URL_OF_FILE },
81
+ options
82
+ );
83
+ ```
23
84
 
24
- ```bash
25
- npm install @deepgram/sdk
85
+ [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
86
+
87
+ ## Local Files
88
+
89
+ ```js
90
+ const response = await deepgram.transcription.preRecorded(
91
+ {
92
+ stream: fs.createReadStream("/path/to/file"),
93
+ mimetype: MIMETYPE_OF_FILE,
94
+ },
95
+ options
96
+ );
26
97
  ```
27
98
 
28
- ### With Yarn
99
+ [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
29
100
 
30
- ```bash
31
- yarn add @deepgram/sdk
101
+ ## Live Audio
102
+
103
+ ```js
104
+ const ws = dg.transcription.live(options);
105
+
106
+ // source.addListener('got-some-audio', async (event) => {
107
+ ws.send(event);
108
+ // })
32
109
  ```
33
110
 
34
- ## Constructor
111
+ See an example, here: [https://github.com/deepgram-devs/node-live-example](https://github.com/deepgram-devs/node-live-example).
112
+
113
+ [See our API reference for more info](https://developers.deepgram.com/reference/streaming).
114
+
115
+ # Projects
116
+
117
+ ## Get Projects
118
+
119
+ Returns all projects accessible by the API key.
35
120
 
36
121
  ```js
37
- const { Deepgram } = require("@deepgram/sdk");
122
+ const result = await deepgram.projects.list();
123
+ ```
38
124
 
39
- const deepgram = new Deepgram(DEEPGRAM_API_KEY);
125
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-projects).
126
+
127
+ ## Get Project
128
+
129
+ Retrieves a specific project based on the provided project_id.
130
+
131
+ ```js
132
+ const result = await deepgram.projects.get(project_id);
40
133
  ```
41
134
 
42
- ## Examples
135
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-project).
43
136
 
44
- ### Transcribe an Existing File
137
+ ## Update Project
45
138
 
46
- #### Remote Files
139
+ Update a project.
47
140
 
48
141
  ```js
49
- const fileSource = { url: URL_OF_FILE };
142
+ const result = await deepgram.projects.update(project_id, options);
143
+ ```
50
144
 
51
- const response = await deepgram.transcription.preRecorded(fileSource, {
52
- punctuate: true,
53
- });
145
+ [See our API reference for more info](https://developers.deepgram.com/reference/update-project).
146
+
147
+ ## Delete Project
148
+
149
+ Delete a project.
150
+
151
+ ```js
152
+ await deepgram.projects.delete(project_id);
54
153
  ```
55
154
 
56
- #### Local Files
155
+ [See our API reference for more info](https://developers.deepgram.com/reference/delete-project).
156
+
157
+ # Keys
158
+
159
+ ## List Keys
160
+
161
+ Retrieves all keys associated with the provided project_id.
57
162
 
58
163
  ```js
59
- const streamSource = {
60
- stream: fs.createReadStream("/path/to/file"),
61
- mimetype: MIMETYPE_OF_FILE,
62
- };
164
+ const result = await deepgram.keys.list(project_id);
165
+ ```
166
+
167
+ [See our API reference for more info](https://developers.deepgram.com/reference/list-keys).
63
168
 
64
- const response = await deepgram.transcription.preRecorded(streamSource, {
65
- punctuate: true,
66
- });
169
+ ## Get Key
170
+
171
+ Retrieves a specific key associated with the provided project_id.
172
+
173
+ ```js
174
+ const result = await deepgram.keys.get(project_id, key_id);
67
175
  ```
68
176
 
69
- ### Transcribe Audio in Real-Time
177
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-key).
70
178
 
71
- See an example real time project at https://github.com/deepgram-devs/node-live-example, or visit this [Getting Started guide](https://developers.deepgram.com/documentation/getting-started/streaming/)
179
+ ## Create Key
72
180
 
73
- ## Samples
181
+ Creates an API key with the provided scopes.
74
182
 
75
- To run the sample code, first run the following in your terminal:
183
+ ```js
184
+ let scopes = ["member", "etc"];
185
+ const result = await deepgram.keys.create(project_id, comment, scopes, options);
186
+ ```
76
187
 
77
- ```bash
78
- npm install
79
- npm build
188
+ [See our API reference for more info](https://developers.deepgram.com/reference/create-key).
189
+
190
+ ## Delete Key
191
+
192
+ Deletes a specific key associated with the provided project_id.
193
+
194
+ ```js
195
+ await deepgram.keys.delete(project_id, key_id);
80
196
  ```
81
197
 
82
- Then update the config object located at the top of the `index.js`
83
- file in the sample folder.
198
+ [See our API reference for more info](https://developers.deepgram.com/reference/delete-key).
199
+
200
+ # Members
201
+
202
+ ## Get Members
203
+
204
+ Retrieves account objects for all of the accounts in the specified project_id.
84
205
 
85
206
  ```js
86
- const config = {
87
- deepgramApiKey: "YOUR_DEEPGRAM_API_KEY",
88
- urlToFile:
89
- "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav",
90
- };
207
+ const result = await deepgram.members.listMembers(project_id);
91
208
  ```
92
209
 
93
- Finally, run the sample code using the following command in your terminal:
210
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-members).
94
211
 
95
- ```bash
96
- node sample/index.js
212
+ ## Remove Member
213
+
214
+ Removes member account for specified member_id.
215
+
216
+ ```js
217
+ const result = await deepgram.members.removeMember(project_id, member_id);
218
+ ```
219
+
220
+ [See our API reference for more info](https://developers.deepgram.com/reference/remove-member).
221
+
222
+ # Scopes
223
+
224
+ ## Get Member Scopes
225
+
226
+ Retrieves scopes of the specified member in the specified project.
227
+
228
+ ```js
229
+ const result = await deepgram.scopes.get(project_id, member_id);
230
+ ```
231
+
232
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-member-scopes).
233
+
234
+ ## Update Scope
235
+
236
+ Updates the scope for the specified member in the specified project.
237
+
238
+ ```js
239
+ let scope = "member:read";
240
+ const result = await deepgram.scopes.update(project_id, member_id, scope);
241
+ ```
242
+
243
+ [See our API reference for more info](https://developers.deepgram.com/reference/update-scope).
244
+
245
+ # Invitations
246
+
247
+ ## List Invites
248
+
249
+ Retrieves all invitations associated with the provided project_id.
250
+
251
+ ```js
252
+ const result = await deepgram.invitations.list(project_id);
253
+ ```
254
+
255
+ [See our API reference for more info](https://developers.deepgram.com/reference/list-invites).
256
+
257
+ ## Send Invite
258
+
259
+ Sends an invitation to the provided email address.
260
+
261
+ ```js
262
+ const result = await deepgram.invitation.send(project_id, options);
263
+ ```
264
+
265
+ [See our API reference for more info](https://developers.deepgram.com/reference/send-invites).
266
+
267
+ ## Delete Invite
268
+
269
+ Removes the specified invitation from the project.
270
+
271
+ ```js
272
+ let email = "devrel@deepgram.com";
273
+ const result = await deepgram.invitation.delete(project_id, email);
274
+ ```
275
+
276
+ [See our API reference for more info](https://developers.deepgram.com/reference/delete-invite).
277
+
278
+ ## Leave Project
279
+
280
+ Removes the authenticated user from the project.
281
+
282
+ ```js
283
+ const result = await deepgram.invitation.leave(project_id);
284
+ ```
285
+
286
+ [See our API reference for more info](https://developers.deepgram.com/reference/leave-project).
287
+
288
+ # Usage
289
+
290
+ ## Get All Requests
291
+
292
+ Retrieves all requests associated with the provided project_id based on the provided options.
293
+
294
+ ```js
295
+ const result = await deepgram.usage.listRequests(project_id, options);
97
296
  ```
98
297
 
99
- The sample demonstrates the following uses:
298
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-all-requests).
100
299
 
101
- - Transcribing a prerecorded file
102
- - Retrieving usage for a project
103
- - Getting a project
104
- - Creating an API key
105
- - Deleting an API key
300
+ ## Get Request
106
301
 
107
- ## Development and Contributing
302
+ Retrieves a specific request associated with the provided project_id.
303
+
304
+ ```js
305
+ const result = await deepgram.usage.getRequest(project_id, request_id);
306
+ ```
307
+
308
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-request).
309
+
310
+ ## Summarize Usage
311
+
312
+ Retrieves usage associated with the provided project_id based on the provided options.
313
+
314
+ ```js
315
+ const result = await deepgram.usage.getUsage(project_id, options);
316
+ ```
317
+
318
+ [See our API reference for more info](https://developers.deepgram.com/reference/summarize-usage).
319
+
320
+ ## Get Fields
321
+
322
+ Lists the features, models, tags, languages, and processing method used for requests in the specified project.
323
+
324
+ ```js
325
+ const result = await deepgram.usage.getFields(project_id, options);
326
+ ```
327
+
328
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-fields).
329
+
330
+ # Billing
331
+
332
+ ## Get All Balances
333
+
334
+ Retrieves the list of balance info for the specified project.
335
+
336
+ ```js
337
+ const result = await deepgram.billing.listBalances(project_id);
338
+ ```
339
+
340
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-all-balances).
341
+
342
+ ## Get Balance
343
+
344
+ Retrieves the balance info for the specified project and balance_id.
345
+
346
+ ```js
347
+ const result = await deepgram.billing.getBalance(project_id, balance_id);
348
+ ```
349
+
350
+ [See our API reference for more info](https://developers.deepgram.com/reference/get-balance).
351
+
352
+ # Development and Contributing
108
353
 
109
354
  Interested in contributing? We ❤️ pull requests!
110
355
 
@@ -112,17 +357,11 @@ To make sure our community is safe for all, be sure to review and agree to our
112
357
  [Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
113
358
  [Contribution](./CONTRIBUTING.md) guidelines for more information.
114
359
 
115
- ## Getting Help
360
+ # Getting Help
116
361
 
117
362
  We love to hear from you so if you have questions, comments or find a bug in the
118
363
  project, let us know! You can either:
119
364
 
120
- - [Open an issue](https://github.com/deepgram/node-sdk/issues/new) on this repository
121
- - Tweet at us! We're [@DeepgramAI on Twitter](https://twitter.com/DeepgramAI)
122
-
123
- ## Further Reading
124
-
125
- Check out the Developer Documentation at [https://developers.deepgram.com/](https://developers.deepgram.com/)
126
-
127
- [signup]: https://console.deepgram.com/signup?utm_medium=github&utm_source=DEVREL&utm_content=node-sdk
128
- [license]: LICENSE.txt
365
+ - [Open an issue in this repository](https://github.com/deepgram/node-sdk/issues/new)
366
+ - [Join the Deepgram Github Discussions Community](https://github.com/orgs/deepgram/discussions)
367
+ - [Join the Deepgram Discord Community](https://discord.gg/xWRaCDBtW4)
package/dist/billing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BalanceList, Balance, RequestFunction, ErrorResponse } from "./types";
1
+ import { BalanceList, Balance, RequestFunction } from "./types";
2
2
  export declare class Billing {
3
3
  private _credentials;
4
4
  private _apiUrl;
@@ -10,9 +10,9 @@ export declare class Billing {
10
10
  * @param {string} projectId Unique identifier of the project
11
11
  * @param {string} endpoint Custom API endpoint
12
12
  *
13
- * @returns {Promise<BalanceList | ErrorResponse>}
13
+ * @returns {Promise<BalanceList>}
14
14
  */
15
- listBalances(projectId: string, endpoint?: string): Promise<BalanceList | ErrorResponse>;
15
+ listBalances(projectId: string, endpoint?: string): Promise<BalanceList>;
16
16
  /**
17
17
  * Retrieves balance info of a specified balance_id in the specified project.
18
18
  * @param {string} projectId Unique identifier of the project
@@ -21,5 +21,5 @@ export declare class Billing {
21
21
  *
22
22
  * @returns {Promise<Balance>}
23
23
  */
24
- getBalance(projectId: string, balanceId: string, endpoint?: string): Promise<Balance | ErrorResponse>;
24
+ getBalance(projectId: string, balanceId: string, endpoint?: string): Promise<Balance>;
25
25
  }
@@ -1 +1 @@
1
- export declare function secondsToTimestamp(seconds: number): string;
1
+ export declare function secondsToTimestamp(seconds: number, format?: string): string;
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Readable } from "stream";
3
4
  export declare function _request<T>(method: string, apiKey: string, apiURL: string, requireSSL: boolean, path: string, payload?: string | Buffer | Readable, options?: Object): Promise<T>;