@@ -147,28 +147,42 @@ HttpResponse<String> response=Unirest.post("https://api.amberscript.com/api/jobs
147
147
```
148
148
149
149
``` javascript
150
- const request = require (' request' );
151
- const fs = require (' fs' );
152
-
153
- let options = {
154
- method: ' POST' ,
155
- url: ' https://api.amberscript.com/api/jobs/upload-media' ,
156
- qs: {
157
- apiKey: ' YOUR_API_KEY' ,
158
- transcriptionType: ' transcription' ,
159
- jobType: ' direct' ,
160
- language: ' nl' ,
161
- numberOfSpeakers: ' 2'
162
- },
163
- headers: {' content-type' : ' multipart/form-data' },
164
- formData: {file: fs .createReadStream (" ./path/to/my_file.mp3" )}
165
- };
166
-
167
- request (options, function (error , response , body ) {
168
- if (error) throw new Error (error);
150
+ import axios from ' axios' ;
151
+ import FormData from ' form-data' ;
152
+ import fs from ' fs' ;
153
+
154
+ async function uploadMedia () {
155
+ const apiKey = ' YOUR_API_KEY' ;
156
+ const transcriptionType = ' transcription' ;
157
+ const jobType = ' perfect' ;
158
+ const language = ' nl' ;
159
+ const numberOfSpeakers = ' 2' ;
160
+
161
+ const formData = new FormData ();
162
+ formData .append (' file' , fs .createReadStream (' ./path/to/my_file.mp3' ));
163
+
164
+ const url = ' https://api.amberscript.com/api/jobs/upload-media' ;
165
+ const queryString = new URLSearchParams ({
166
+ apiKey,
167
+ transcriptionType,
168
+ jobType,
169
+ language,
170
+ numberOfSpeakers
171
+ }).toString ();
172
+
173
+ const options = {
174
+ headers: {
175
+ ... formData .getHeaders ()
176
+ }
177
+ };
169
178
170
- console .log (body);
171
- });
179
+ try {
180
+ const response = await axios .post (` ${ url} ?${ queryString} ` , formData, options);
181
+ console .log (response .data );
182
+ } catch (error) {
183
+ console .error (' Error:' , error .response .data )
184
+ }
185
+ }
172
186
```
173
187
174
188
``` python
@@ -333,30 +347,37 @@ HttpResponse<String> response=Unirest.post("https://api.amberscript.com/api/jobs
333
347
```
334
348
335
349
```javascript
336
- const request = require('request');
337
- const fs = require('fs');
338
-
339
- let options = {
340
- method: 'POST',
341
- url: 'https://api.amberscript.com/api/jobs/upload-media-from-url',
342
- qs: {
343
- apiKey: 'YOUR_API_KEY'
344
- },
345
- body: {
346
- " sourceUrl" : " https: // www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4",
347
- " transcriptionType" : " transcription" ,
348
- " jobType" : " direct" ,
349
- " language" : " nl" ,
350
- " numberOfSpeakers" : " 2"
351
- },
352
- headers: {' content-type' : ' application/json' }
353
- };
354
-
355
- request(options, function (error, response, body) {
356
- if (error) throw new Error (error);
350
+ import axios from 'axios';
351
+
352
+ async function uploadMediaFromUrl() {
353
+ const apiKey = 'YOUR_API_KEY';
354
+
355
+ const url = 'https://api.amberscript.com/api/jobs/upload-media-from-url';
356
+ const queryString = new URLSearchParams({
357
+ apiKey
358
+ }).toString();
359
+
360
+ const body = {
361
+ sourceUrl: 'https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4',
362
+ transcriptionType: 'transcription',
363
+ jobType: 'direct',
364
+ language: 'nl',
365
+ numberOfSpeakers: '2'
366
+ };
367
+
368
+ const options = {
369
+ headers: {
370
+ 'content-type': 'application/json'
371
+ }
372
+ };
357
373
358
- console. log(body);
359
- });
374
+ try {
375
+ const response = await axios.post(`${url}?${queryString}`, body, options);
376
+ console.log(response.data);
377
+ } catch (error) {
378
+ console.error('Error:', error.response.data)
379
+ }
380
+ }
360
381
```
361
382
362
383
```python
@@ -583,19 +604,22 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
583
604
```
584
605
585
606
```javascript
586
- var request = require( " request " ) ;
607
+ import axios from ' axios ' ;
587
608
588
- var options = {
589
- method: ' GET' ,
590
- url: ' https://api.amberscript.com/api/jobs/status' ,
591
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
592
- };
609
+ async function createTranslatedSubtitles() {
610
+ const sourceJobId = ' SOURCE_JOB_ID' ;
611
+ const targetLanguage = ' nl' ;
612
+ const apiKey = ' YOUR_API_KEY' ;
593
613
594
- request(options, function (error, response, body) {
595
- if (error) throw new Error (error);
614
+ const url = `https: // api.amberscript.com/api/jobs/translatedSubtitles?sourceJobId=${sourceJobId}&targetLanguage=${targetLanguage}&apiKey=${apiKey}`;
596
615
597
- console. log(body);
598
- });
616
+ try {
617
+ const response = await axios. post(url, {}, { headers: { ' content-type' : ' application/json' } });
618
+ console. log(response. data);
619
+ } catch (error) {
620
+ console. error(' Error:' , error. response. data)
621
+ }
622
+ }
599
623
```
600
624
601
625
```python
@@ -727,19 +751,19 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
727
751
```
728
752
729
753
```javascript
730
- var request = require(" request" );
731
-
732
- var options = {
733
- method: ' GET' ,
734
- url: ' https://api.amberscript.com/api/jobs/export-srt' ,
735
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
736
- };
754
+ async function exportSTL() {
755
+ const jobId = ' JOB_ID' ;
756
+ const apiKey = ' YOUR_API_KEY' ;
737
757
738
- request(options, function (error, response, body) {
739
- if (error) throw new Error (error);
758
+ const url = `https: // api.amberscript.com/api/jobs/export-stl?jobId=${jobId}&apiKey=${apiKey}`;
740
759
741
- console. log(body);
742
- });
760
+ try {
761
+ const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
762
+ console. log(response. data);
763
+ } catch (error) {
764
+ console. error(' Error:' , error. response. data);
765
+ }
766
+ }
743
767
```
744
768
745
769
```python
@@ -805,19 +829,19 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
805
829
```
806
830
807
831
```javascript
808
- var request = require(" request" );
832
+ async function exportVTT() {
833
+ const jobId = ' JOB_ID' ;
834
+ const apiKey = ' YOUR_API_KEY' ;
809
835
810
- var options = {
811
- method: ' GET' ,
812
- url: ' https://api.amberscript.com/api/jobs/export-vtt' ,
813
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
814
- };
836
+ const url = `https: // api.amberscript.com/api/jobs/export-vtt?jobId=${jobId}&apiKey=${apiKey}`;
815
837
816
- request(options, function (error, response, body) {
817
- if (error) throw new Error (error);
818
-
819
- console. log(body);
820
- });
838
+ try {
839
+ const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
840
+ console. log(response. data);
841
+ } catch (error) {
842
+ console. error(' Error:' , error. response. data);
843
+ }
844
+ }
821
845
```
822
846
823
847
```python
@@ -885,19 +909,19 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
885
909
```
886
910
887
911
```javascript
888
- var request = require(" request" );
912
+ async function exportTXT() {
913
+ const jobId = ' JOB_ID' ;
914
+ const apiKey = ' YOUR_API_KEY' ;
889
915
890
- var options = {
891
- method: ' GET' ,
892
- url: ' https://api.amberscript.com/api/jobs/export-txt' ,
893
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
894
- };
895
-
896
- request(options, function (error, response, body) {
897
- if (error) throw new Error (error);
916
+ const url = `https: // api.amberscript.com/api/jobs/export-txt?jobId=${jobId}&apiKey=${apiKey}`;
898
917
899
- console. log(body);
900
- });
918
+ try {
919
+ const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
920
+ console. log(response. data);
921
+ } catch (error) {
922
+ console. error(' Error:' , error. response. data);
923
+ }
924
+ }
901
925
```
902
926
903
927
```python
@@ -948,19 +972,19 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
948
972
```
949
973
950
974
```javascript
951
- var request = require(" request" );
952
-
953
- var options = {
954
- method: ' GET' ,
955
- url: ' https://api.amberscript.com/api/jobs/export-json' ,
956
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
957
- };
975
+ async function exportJSON() {
976
+ const jobId = ' JOB_ID' ;
977
+ const apiKey = ' YOUR_API_KEY' ;
958
978
959
- request(options, function (error, response, body) {
960
- if (error) throw new Error (error);
979
+ const url = `https: // api.amberscript.com/api/jobs/export-json?jobId=${jobId}&apiKey=${apiKey}`;
961
980
962
- console. log(body);
963
- });
981
+ try {
982
+ const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
983
+ console. log(response. data);
984
+ } catch (error) {
985
+ console. error(' Error:' , error. response. data);
986
+ }
987
+ }
964
988
```
965
989
966
990
```python
@@ -1059,19 +1083,19 @@ HttpResponse<String> response=Unirest.delete("https://api.amberscript.com/api/jo
1059
1083
```
1060
1084
1061
1085
```javascript
1062
- var request = require(" request" );
1063
-
1064
- var options = {
1065
- method: ' DELETE' ,
1066
- url: ' https://api.amberscript.com/api/jobs' ,
1067
- qs: {jobId: ' JOB_ID' , apiKey: ' YOUR_API_KEY' }
1068
- };
1086
+ async function deleteJob() {
1087
+ const jobId = ' 6638de0ba17717297470040c' ;
1088
+ const apiKey = ' YOUR_API_KEY' ;
1069
1089
1070
- request(options, function (error, response, body) {
1071
- if (error) throw new Error (error);
1090
+ const url = `https: // api.amberscript.com/api/jobs?jobId=${jobId}&apiKey=${apiKey}`;
1072
1091
1073
- console. log(body);
1074
- });
1092
+ try {
1093
+ const response = await axios. delete(url, { headers: { ' Content-Type' : ' application/json' } });
1094
+ console. log(response. data);
1095
+ } catch (error) {
1096
+ console. error(' Error:' , error. response. data)
1097
+ }
1098
+ }
1075
1099
```
1076
1100
1077
1101
```python
@@ -1119,19 +1143,18 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs?
1119
1143
```
1120
1144
1121
1145
```javascript
1122
- var request = require(" request" );
1146
+ async function listJobs() {
1147
+ const apiKey = ' YOUR_API_KEY' ;
1123
1148
1124
- var options = {
1125
- method: ' GET' ,
1126
- url: ' https://api.amberscript.com/api/jobs' ,
1127
- qs: {apiKey: ' YOUR_API_KEY' }
1128
- };
1149
+ const url = `https: // api.amberscript.com/api/jobs?apiKey=${apiKey}`;
1129
1150
1130
- request(options, function (error, response, body) {
1131
- if (error) throw new Error (error);
1132
-
1133
- console. log(body);
1134
- });
1151
+ try {
1152
+ const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
1153
+ console. log(response. data);
1154
+ } catch (error) {
1155
+ console. error(' Error:' , error. response. data)
1156
+ }
1157
+ }
1135
1158
```
1136
1159
1137
1160
```python
0 commit comments