@@ -39,9 +39,11 @@ const { Deepgram } = require("@deepgram/sdk");
39
39
const deepgram = new Deepgram (DEEPGRAM_API_KEY );
40
40
```
41
41
42
- ## Examples
42
+ # Examples
43
43
44
- ### Transcribe an Existing File
44
+ ## Transcription
45
+
46
+ ### Pre-recorded
45
47
46
48
#### Remote Files
47
49
@@ -70,6 +72,353 @@ const response = await deepgram.transcription.preRecorded(streamSource, {
70
72
71
73
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/ )
72
74
75
+ ### Usage
76
+
77
+ #### listRequests
78
+ Retrieves all requests associated with the provided project_id based on the provided options.
79
+ ``` js
80
+ deepgram .usage
81
+ .listRequests (" 84b227ad-dfac-4096-82f6-f7397006050b" , {
82
+ start: " 2022-07-01" ,
83
+ end: " 2022-07-28" ,
84
+ })
85
+ .then ((response ) => {
86
+ console .log (" Usage: " , response);
87
+ })
88
+ .catch ((err ) => {
89
+ console .log (" ERROR: " , err);
90
+ });
91
+ ```
92
+ #### getRequest
93
+ Retrieves a specific request associated with the provided project_id.
94
+ ``` js
95
+ deepgram .usage
96
+ .getRequest (
97
+ // projectId
98
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
99
+ // requestId
100
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1"
101
+ )
102
+ .then ((response ) => {
103
+ fs .writeFileSync (
104
+ ` usage.json` ,
105
+ JSON .stringify (response),
106
+ () => ` Wrote json`
107
+ );
108
+ })
109
+ .catch ((err ) => {
110
+ console .log (" ERROR: " , err);
111
+ });
112
+ ```
113
+
114
+ #### getUsage
115
+ Retrieves usage associated with the provided project_id based on the provided options.
116
+ ``` js
117
+ deepgram .usage
118
+ .getUsage (" 84b227ad-dfac-4096-82f6-f7397006050b" , {
119
+ punctuate: true ,
120
+ diarize: true
121
+ })
122
+ .then ((response ) => {
123
+ console .log (" Usage: " , response);
124
+ })
125
+ .catch ((err ) => {
126
+ console .log (" ERROR: " , err);
127
+ });
128
+ ```
129
+
130
+ ### getFields
131
+ Retrieves features used by the provided project_id based on the provided options.
132
+ ``` js
133
+ deepgram .usage
134
+ .getFields (" 84b227ad-dfac-4096-82f6-f7397006050b" , {
135
+ start: " 2022-07-01" ,
136
+ end: " 2022-07-28" ,
137
+ })
138
+ .then ((response ) => {
139
+ console .log (" Usage: " , response);
140
+ })
141
+ .catch ((err ) => {
142
+ console .log (" ERROR: " , err);
143
+ });
144
+ ```
145
+
146
+ ### Scopes
147
+ #### get
148
+ Retrieves scopes of the specified member in the specified project.
149
+ ``` js
150
+ deepgram .scopes
151
+ .get (
152
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
153
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1"
154
+ )
155
+ .then ((response ) => {
156
+ fs .writeFileSync (
157
+ ` scope.json` ,
158
+ JSON .stringify (response),
159
+ () => ` Wrote json`
160
+ );
161
+ })
162
+ .catch ((err ) => {
163
+ console .log (" ERROR: " , err);
164
+ });
165
+ ```
166
+
167
+ #### update
168
+ Updates the scope for the specified member in the specified project.
169
+ ``` js
170
+ deepgram .scopes
171
+ .update (
172
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
173
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1" ,
174
+ " member:read"
175
+ )
176
+ .then ((response ) => {
177
+ console .log ({response})
178
+ })
179
+ .catch ((err ) => {
180
+ console .log (" ERROR: " , err);
181
+ });
182
+ ```
183
+
184
+ ### Projects
185
+ #### list
186
+ Returns all projects accessible by the API key.
187
+ ``` js
188
+ deepgram .projects
189
+ .list ()
190
+ .then ((response ) => {
191
+ console .log (" list" , response);
192
+ })
193
+ .catch ((err ) => {
194
+ console .log (" err" , err);
195
+ });
196
+ ```
197
+
198
+ #### get
199
+ Retrieves a specific project based on the provided project_id.
200
+ ``` js
201
+ deepgram .projects
202
+ .get (" 84b227ad-dfac-4096-82f6-f7397006050b" )
203
+ .then ((response ) => {
204
+ console .log (" list" , response);
205
+ })
206
+ .catch ((err ) => {
207
+ console .log (" err" , err);
208
+ });
209
+ ```
210
+
211
+ #### update
212
+ Update a project.
213
+ ``` js
214
+ deepgram .projects
215
+ .update (
216
+ { project_id: " 84b227ad-dfac-4096-82f6-f7397006050b" },
217
+ {
218
+ name: " A new name" ,
219
+ }
220
+ )
221
+ .then ((response ) => {
222
+ console .log (" list" , response);
223
+ })
224
+ .catch ((err ) => {
225
+ console .log (" err" , err);
226
+ });
227
+ ```
228
+
229
+ #### delete
230
+ Delete a project.
231
+ ``` js
232
+ deepgram .projects
233
+ .delete (" 84b227ad-dfac-4096-82f6-f7397006050b" )
234
+ .then ((response ) => {
235
+ console .log (" delete" , response);
236
+ })
237
+ .catch ((err ) => {
238
+ console .log (" err" , err);
239
+ });
240
+ ```
241
+
242
+ ### Members
243
+
244
+ #### listMembers
245
+ Retrieves account objects for all of the accounts in the specified project.
246
+ ``` js
247
+ deepgram .members
248
+ .listMembers (" 84b227ad-dfac-4096-82f6-f7397006050b" )
249
+ .then ((response ) => {
250
+ console .log (" Members: " , response);
251
+ })
252
+ .catch ((err ) => {
253
+ console .log (" Members ERROR: " , err);
254
+ });
255
+ ```
256
+
257
+ #### deleteMembers
258
+ Removes member account for specified member_id.
259
+ ``` js
260
+ deepgram .members
261
+ .removeMember (
262
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
263
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1"
264
+ )
265
+ .then ((response ) => {
266
+ console .log (" Member DELETED: " , response);
267
+ })
268
+ .catch ((err ) => {
269
+ console .log (" Member DELETED ERROR: " , err);
270
+ });
271
+ ```
272
+
273
+ ### Keys
274
+ #### list
275
+ Retrieves all keys associated with the provided project_id.
276
+ ``` js
277
+ deepgram .keys
278
+ .list (" 84b227ad-dfac-4096-82f6-f7397006050b" )
279
+ .then ((res ) => {
280
+ console .log ({ res });
281
+ })
282
+ .catch ((err ) => {
283
+ console .log (" ERROR: " , err);
284
+ });
285
+ ```
286
+
287
+ #### get
288
+ Retrieves a specific key associated with the provided project_id.
289
+ ``` js
290
+ deepgram .keys
291
+ .get (
292
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
293
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1"
294
+ )
295
+ .then ((res ) => {
296
+ console .log ({ res });
297
+ })
298
+ .catch ((err ) => {
299
+ console .log (" ERROR: " , err);
300
+ });
301
+ ```
302
+
303
+ #### create
304
+ Creates an API key with the provided scopes.
305
+ ``` js
306
+ deepgram .keys
307
+ .create (
308
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
309
+ " Temporary key" ,
310
+ [" usage" ],
311
+ {
312
+ timeToLive: 5000 ,
313
+ }
314
+ )
315
+ .then ((res ) => {
316
+ console .log ({ res });
317
+ })
318
+ .catch ((err ) => {
319
+ console .log (" ERROR: " , err);
320
+ });
321
+ ```
322
+
323
+ #### delete
324
+ Deletes a specific key associated with the provided project_id.
325
+ ``` js
326
+ deepgram .keys
327
+ .delete (
328
+ " 84b227ad-dfac-4096-82f6-f7397006050b" ,
329
+ " f12cc224-282b-4de4-90f1-651d5fdf04f1"
330
+ )
331
+ .then ((response ) => {
332
+ console .log (" KEY DELTED: " , response);
333
+ })
334
+ .catch ((err ) => {
335
+ console .log (" KEY DELETED ERROR: " , err);
336
+ });
337
+ ```
338
+
339
+ ### Invitations
340
+ #### list
341
+ Retrieves all invitations associated with the provided project_id.
342
+ ``` js
343
+ deepgram .invitations
344
+ .list (" 84b227ad-dfac-4096-82f6-f7397006050b" )
345
+ .then ((res ) => {
346
+ console .log ({ res });
347
+ })
348
+ .catch ((err ) => {
349
+ console .log (" ERROR: " , err);
350
+ });
351
+ ```
352
+
353
+ #### send
354
+ Sends an invitation to the provided email address.
355
+ ``` js
356
+ deepgram .invitation
357
+ .send (" 84b227ad-dfac-4096-82f6-f7397006050b" , {
358
+
359
+ scope: " member" ,
360
+ })
361
+ .then ((response ) => {
362
+ console .log (" Invitation sent: " , response);
363
+ })
364
+ .catch ((err ) => {
365
+ console .log (" Invitation ERROR: " , err);
366
+ });
367
+ ```
368
+
369
+ #### leave
370
+ Removes the authenticated user from the project.
371
+ ``` js
372
+ deepgram .invitation
373
+ .leave (" 84b227ad-dfac-4096-82f6-f7397006050b" )
374
+ .then ((response ) => {
375
+ console .log ({response});
376
+ })
377
+ .catch ((err ) => {
378
+ console .log (" Invitation leave ERROR: " , err);
379
+ });
380
+ ```
381
+
382
+ #### delete
383
+ Removes the specified invitation from the project.
384
+ ``` js
385
+ deepgram .invitation
386
+ .
delete (
" 84b227ad-dfac-4096-82f6-f7397006050b" ,
" [email protected] " )
387
+ .then ((response ) => {
388
+ console .log ({response});
389
+ })
390
+ .catch ((err ) => {
391
+ console .log (" Invitation delete ERROR: " , err);
392
+ });
393
+ ```
394
+
395
+ ### Billing
396
+ #### listBalances
397
+ Retrieves the list of balance info for the specified project.
398
+ ``` js
399
+ deepgram .billing
400
+ .listBalances (" 84b227ad-dfac-4096-82f6-f7397006050b" )
401
+ .then ((response ) => {
402
+ console .log ({response});
403
+ })
404
+ .catch ((err ) => {
405
+ console .log (" Billing listBalances ERROR: " , err);
406
+ });
407
+ ```
408
+
409
+ #### getBalance
410
+ Retrieves the balance info for the specified project and balance_id.
411
+ ``` js
412
+ deepgram .billing
413
+ .getBalance (" 84b227ad-dfac-4096-82f6-f7397006050b" , " 21b98377-657e-471a-b75e-299fb99ec2c3" )
414
+ .then ((response ) => {
415
+ console .log ({response});
416
+ })
417
+ .catch ((err ) => {
418
+ console .log (" Billing getBalance ERROR: " , err);
419
+ });
420
+ ```
421
+
73
422
## Samples
74
423
75
424
To run the sample code, first run the following in your terminal:
0 commit comments