podcast-api 1.1.4 → 2.0.1
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.
- package/README.md +113 -101
- package/package.json +10 -12
- package/src/Constants.js +11 -0
- package/src/PodcastApiClient.js +5 -111
- package/src/PodcastApiClientForNode.js +26 -0
- package/src/PodcastApiClientForWorkers.js +83 -0
- package/src/PodcastApiMethods.js +77 -0
package/README.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# Podcast API JavaScript Library
|
|
2
2
|
|
|
3
|
-
[](https://github.com/ListenNotes/podcast-api-js/actions/workflows/node.js.yml) [](https://www.npmjs.com/package/podcast-api)
|
|
3
|
+
[](https://github.com/ListenNotes/podcast-api-js/actions/workflows/node.js.yml) [](https://github.com/ListenNotes/podcast-api-js/actions/workflows/cloudflare-workers.yml) [](https://www.npmjs.com/package/podcast-api)
|
|
4
4
|
|
|
5
|
-
The Podcast API JavaScript library provides convenient access to the [Listen Notes Podcast API](https://www.listennotes.com/
|
|
6
|
-
applications written in
|
|
5
|
+
The Podcast API JavaScript library provides convenient access to the [Listen Notes Podcast API](https://www.listennotes.com/api/) from
|
|
6
|
+
applications written in JavaScript, including
|
|
7
|
+
* Server-side Node.js: See example code [PodcastAppForNode](https://github.com/ListenNotes/podcast-api-js/tree/main/examples/PodcastAppForNode)
|
|
8
|
+
* Serverless [Cloudflare Workers](https://workers.cloudflare.com/) / [Cloudflare Pages](https://pages.cloudflare.com/) (w/ [functions](https://developers.cloudflare.com/pages/platform/functions/)): See example code [PodcastAppForWorkers](https://github.com/ListenNotes/podcast-api-js/tree/main/examples/PodcastAppForWorkers)
|
|
9
|
+
* Client-side Javascript in web browsers: See example code [PodcastAppForBrowser](https://github.com/ListenNotes/podcast-api-js/tree/main/examples/PodcastAppForBrowser)
|
|
7
10
|
|
|
8
11
|
Simple and no-nonsense podcast search & directory API. Search the meta data of all podcasts and episodes by people, places, or topics. It's the same API that powers [the best podcast search engine Listen Notes](https://www.listennotes.com/).
|
|
9
12
|
|
|
10
|
-
**Note**: We don't recommend using
|
|
13
|
+
**Note**: We don't recommend using our Podcast API in client-side JavaScript in the browser, because it'll leak your API key in the code.
|
|
11
14
|
|
|
12
15
|
If you have any questions, please contact [hello@listennotes.com](hello@listennotes.com?subject=Questions+about+the+JS+SDK+of+Listen+API)
|
|
13
16
|
|
|
@@ -57,7 +60,7 @@ yarn add podcast-api
|
|
|
57
60
|
|
|
58
61
|
### Requirements
|
|
59
62
|
|
|
60
|
-
- Node
|
|
63
|
+
- Node 18 or higher
|
|
61
64
|
|
|
62
65
|
## Usage
|
|
63
66
|
|
|
@@ -68,12 +71,21 @@ value:
|
|
|
68
71
|
|
|
69
72
|
<!-- prettier-ignore -->
|
|
70
73
|
```js
|
|
74
|
+
// If you use our Podcast API with Node.js or browser javascript, then use the Client class.
|
|
71
75
|
const { Client } = require('podcast-api');
|
|
72
|
-
|
|
73
76
|
const client = Client({
|
|
74
77
|
apiKey: process.env.LISTEN_API_KEY || null,
|
|
75
78
|
});
|
|
76
79
|
|
|
80
|
+
// If you use our Podcast API with Cloudflare Workers / Pages, then use the ClientForWorkers class.
|
|
81
|
+
// Please make sure you store LISTEN_API_KEY as a secret. See example code:
|
|
82
|
+
// - https://github.com/ListenNotes/podcast-api-js/blob/main/examples/PodcastAppForWorkers/src/index.js
|
|
83
|
+
// const { ClientForWorkers } = require('podcast-api');
|
|
84
|
+
// const client = ClientForWorkers({
|
|
85
|
+
// apiKey: env.LISTEN_API_KEY || null,
|
|
86
|
+
// });
|
|
87
|
+
|
|
88
|
+
|
|
77
89
|
client.search({
|
|
78
90
|
q: 'elon musk',
|
|
79
91
|
}).then((response) => {
|
|
@@ -104,7 +116,7 @@ client.search({
|
|
|
104
116
|
});
|
|
105
117
|
```
|
|
106
118
|
|
|
107
|
-
If `apiKey` is null, then we'll connect to a [mock server](https://
|
|
119
|
+
If `apiKey` is null, then we'll connect to a [mock server](https://www.listennotes.help/article/48-how-to-test-the-podcast-api-without-an-api-key) that returns fake data for testing purposes.
|
|
108
120
|
|
|
109
121
|
|
|
110
122
|
|
|
@@ -113,7 +125,7 @@ If `apiKey` is null, then we'll connect to a [mock server](https://help.listenno
|
|
|
113
125
|
## API Reference
|
|
114
126
|
|
|
115
127
|
Each function is a wrapper to send an HTTP request to the corresponding endpoint on the
|
|
116
|
-
[API Docs](https://www.listennotes.com/
|
|
128
|
+
[API Docs](https://www.listennotes.com/api/docs/).
|
|
117
129
|
|
|
118
130
|
|
|
119
131
|
|
|
@@ -152,7 +164,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
152
164
|
|
|
153
165
|
<details>
|
|
154
166
|
<summary>Click to see example response</summary>
|
|
155
|
-
|
|
167
|
+
|
|
156
168
|
```json
|
|
157
169
|
{
|
|
158
170
|
"took": 0.966,
|
|
@@ -533,14 +545,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
533
545
|
],
|
|
534
546
|
"next_offset": 10
|
|
535
547
|
}
|
|
536
|
-
```
|
|
548
|
+
```
|
|
537
549
|
</details>
|
|
538
550
|
|
|
539
551
|
|
|
540
552
|
|
|
541
553
|
<details>
|
|
542
554
|
<summary>Click to see response schema</summary>
|
|
543
|
-
|
|
555
|
+
|
|
544
556
|
```json
|
|
545
557
|
{
|
|
546
558
|
"type": "object",
|
|
@@ -978,7 +990,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
978
990
|
}
|
|
979
991
|
}
|
|
980
992
|
}
|
|
981
|
-
```
|
|
993
|
+
```
|
|
982
994
|
</details>
|
|
983
995
|
|
|
984
996
|
|
|
@@ -1014,7 +1026,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1014
1026
|
|
|
1015
1027
|
<details>
|
|
1016
1028
|
<summary>Click to see example response</summary>
|
|
1017
|
-
|
|
1029
|
+
|
|
1018
1030
|
```json
|
|
1019
1031
|
{
|
|
1020
1032
|
"terms": [
|
|
@@ -1080,14 +1092,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1080
1092
|
}
|
|
1081
1093
|
]
|
|
1082
1094
|
}
|
|
1083
|
-
```
|
|
1095
|
+
```
|
|
1084
1096
|
</details>
|
|
1085
1097
|
|
|
1086
1098
|
|
|
1087
1099
|
|
|
1088
1100
|
<details>
|
|
1089
1101
|
<summary>Click to see response schema</summary>
|
|
1090
|
-
|
|
1102
|
+
|
|
1091
1103
|
```json
|
|
1092
1104
|
{
|
|
1093
1105
|
"type": "object",
|
|
@@ -1188,7 +1200,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1188
1200
|
}
|
|
1189
1201
|
}
|
|
1190
1202
|
}
|
|
1191
|
-
```
|
|
1203
|
+
```
|
|
1192
1204
|
</details>
|
|
1193
1205
|
|
|
1194
1206
|
|
|
@@ -1226,7 +1238,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1226
1238
|
|
|
1227
1239
|
<details>
|
|
1228
1240
|
<summary>Click to see example response</summary>
|
|
1229
|
-
|
|
1241
|
+
|
|
1230
1242
|
```json
|
|
1231
1243
|
{
|
|
1232
1244
|
"id": "4d3fe717742d4963a85562e9f84d8c79",
|
|
@@ -1448,14 +1460,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1448
1460
|
"update_frequency_hours": 24,
|
|
1449
1461
|
"listen_score_global_rank": "1%"
|
|
1450
1462
|
}
|
|
1451
|
-
```
|
|
1463
|
+
```
|
|
1452
1464
|
</details>
|
|
1453
1465
|
|
|
1454
1466
|
|
|
1455
1467
|
|
|
1456
1468
|
<details>
|
|
1457
1469
|
<summary>Click to see response schema</summary>
|
|
1458
|
-
|
|
1470
|
+
|
|
1459
1471
|
```json
|
|
1460
1472
|
{
|
|
1461
1473
|
"type": "object",
|
|
@@ -1770,7 +1782,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1770
1782
|
}
|
|
1771
1783
|
}
|
|
1772
1784
|
}
|
|
1773
|
-
```
|
|
1785
|
+
```
|
|
1774
1786
|
</details>
|
|
1775
1787
|
|
|
1776
1788
|
|
|
@@ -1806,7 +1818,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1806
1818
|
|
|
1807
1819
|
<details>
|
|
1808
1820
|
<summary>Click to see example response</summary>
|
|
1809
|
-
|
|
1821
|
+
|
|
1810
1822
|
```json
|
|
1811
1823
|
{
|
|
1812
1824
|
"id": "6b6d65930c5a4f71b254465871fed370",
|
|
@@ -1885,14 +1897,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
1885
1897
|
"maybe_audio_invalid": false,
|
|
1886
1898
|
"listennotes_edit_url": "https://www.listennotes.com/e/6b6d65930c5a4f71b254465871fed370/#edit"
|
|
1887
1899
|
}
|
|
1888
|
-
```
|
|
1900
|
+
```
|
|
1889
1901
|
</details>
|
|
1890
1902
|
|
|
1891
1903
|
|
|
1892
1904
|
|
|
1893
1905
|
<details>
|
|
1894
1906
|
<summary>Click to see response schema</summary>
|
|
1895
|
-
|
|
1907
|
+
|
|
1896
1908
|
```json
|
|
1897
1909
|
{
|
|
1898
1910
|
"type": "object",
|
|
@@ -2204,7 +2216,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2204
2216
|
}
|
|
2205
2217
|
}
|
|
2206
2218
|
}
|
|
2207
|
-
```
|
|
2219
|
+
```
|
|
2208
2220
|
</details>
|
|
2209
2221
|
|
|
2210
2222
|
|
|
@@ -2241,7 +2253,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2241
2253
|
|
|
2242
2254
|
<details>
|
|
2243
2255
|
<summary>Click to see example response</summary>
|
|
2244
|
-
|
|
2256
|
+
|
|
2245
2257
|
```json
|
|
2246
2258
|
{
|
|
2247
2259
|
"languages": [
|
|
@@ -2321,14 +2333,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2321
2333
|
"Vietnamese"
|
|
2322
2334
|
]
|
|
2323
2335
|
}
|
|
2324
|
-
```
|
|
2336
|
+
```
|
|
2325
2337
|
</details>
|
|
2326
2338
|
|
|
2327
2339
|
|
|
2328
2340
|
|
|
2329
2341
|
<details>
|
|
2330
2342
|
<summary>Click to see response schema</summary>
|
|
2331
|
-
|
|
2343
|
+
|
|
2332
2344
|
```json
|
|
2333
2345
|
{
|
|
2334
2346
|
"type": "object",
|
|
@@ -2375,7 +2387,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2375
2387
|
}
|
|
2376
2388
|
}
|
|
2377
2389
|
}
|
|
2378
|
-
```
|
|
2390
|
+
```
|
|
2379
2391
|
</details>
|
|
2380
2392
|
|
|
2381
2393
|
|
|
@@ -2415,7 +2427,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2415
2427
|
|
|
2416
2428
|
<details>
|
|
2417
2429
|
<summary>Click to see example response</summary>
|
|
2418
|
-
|
|
2430
|
+
|
|
2419
2431
|
```json
|
|
2420
2432
|
{
|
|
2421
2433
|
"genres": [
|
|
@@ -2526,14 +2538,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2526
2538
|
}
|
|
2527
2539
|
]
|
|
2528
2540
|
}
|
|
2529
|
-
```
|
|
2541
|
+
```
|
|
2530
2542
|
</details>
|
|
2531
2543
|
|
|
2532
2544
|
|
|
2533
2545
|
|
|
2534
2546
|
<details>
|
|
2535
2547
|
<summary>Click to see response schema</summary>
|
|
2536
|
-
|
|
2548
|
+
|
|
2537
2549
|
```json
|
|
2538
2550
|
{
|
|
2539
2551
|
"type": "object",
|
|
@@ -2571,7 +2583,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2571
2583
|
}
|
|
2572
2584
|
}
|
|
2573
2585
|
}
|
|
2574
|
-
```
|
|
2586
|
+
```
|
|
2575
2587
|
</details>
|
|
2576
2588
|
|
|
2577
2589
|
|
|
@@ -2613,7 +2625,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
2613
2625
|
|
|
2614
2626
|
<details>
|
|
2615
2627
|
<summary>Click to see example response</summary>
|
|
2616
|
-
|
|
2628
|
+
|
|
2617
2629
|
```json
|
|
2618
2630
|
{
|
|
2619
2631
|
"id": 93,
|
|
@@ -3733,14 +3745,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
3733
3745
|
"next_page_number": 3,
|
|
3734
3746
|
"previous_page_number": 1
|
|
3735
3747
|
}
|
|
3736
|
-
```
|
|
3748
|
+
```
|
|
3737
3749
|
</details>
|
|
3738
3750
|
|
|
3739
3751
|
|
|
3740
3752
|
|
|
3741
3753
|
<details>
|
|
3742
3754
|
<summary>Click to see response schema</summary>
|
|
3743
|
-
|
|
3755
|
+
|
|
3744
3756
|
```json
|
|
3745
3757
|
{
|
|
3746
3758
|
"type": "object",
|
|
@@ -4041,7 +4053,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4041
4053
|
}
|
|
4042
4054
|
}
|
|
4043
4055
|
}
|
|
4044
|
-
```
|
|
4056
|
+
```
|
|
4045
4057
|
</details>
|
|
4046
4058
|
|
|
4047
4059
|
|
|
@@ -4078,7 +4090,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4078
4090
|
|
|
4079
4091
|
<details>
|
|
4080
4092
|
<summary>Click to see example response</summary>
|
|
4081
|
-
|
|
4093
|
+
|
|
4082
4094
|
```json
|
|
4083
4095
|
{
|
|
4084
4096
|
"regions": {
|
|
@@ -4234,14 +4246,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4234
4246
|
"zw": "Zimbabwe"
|
|
4235
4247
|
}
|
|
4236
4248
|
}
|
|
4237
|
-
```
|
|
4249
|
+
```
|
|
4238
4250
|
</details>
|
|
4239
4251
|
|
|
4240
4252
|
|
|
4241
4253
|
|
|
4242
4254
|
<details>
|
|
4243
4255
|
<summary>Click to see response schema</summary>
|
|
4244
|
-
|
|
4256
|
+
|
|
4245
4257
|
```json
|
|
4246
4258
|
{
|
|
4247
4259
|
"type": "object",
|
|
@@ -4260,7 +4272,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4260
4272
|
}
|
|
4261
4273
|
}
|
|
4262
4274
|
}
|
|
4263
|
-
```
|
|
4275
|
+
```
|
|
4264
4276
|
</details>
|
|
4265
4277
|
|
|
4266
4278
|
|
|
@@ -4296,7 +4308,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4296
4308
|
|
|
4297
4309
|
<details>
|
|
4298
4310
|
<summary>Click to see example response</summary>
|
|
4299
|
-
|
|
4311
|
+
|
|
4300
4312
|
```json
|
|
4301
4313
|
{
|
|
4302
4314
|
"recommendations": [
|
|
@@ -4768,14 +4780,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
4768
4780
|
}
|
|
4769
4781
|
]
|
|
4770
4782
|
}
|
|
4771
|
-
```
|
|
4783
|
+
```
|
|
4772
4784
|
</details>
|
|
4773
4785
|
|
|
4774
4786
|
|
|
4775
4787
|
|
|
4776
4788
|
<details>
|
|
4777
4789
|
<summary>Click to see response schema</summary>
|
|
4778
|
-
|
|
4790
|
+
|
|
4779
4791
|
```json
|
|
4780
4792
|
{
|
|
4781
4793
|
"type": "object",
|
|
@@ -5023,7 +5035,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5023
5035
|
}
|
|
5024
5036
|
}
|
|
5025
5037
|
}
|
|
5026
|
-
```
|
|
5038
|
+
```
|
|
5027
5039
|
</details>
|
|
5028
5040
|
|
|
5029
5041
|
|
|
@@ -5059,7 +5071,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5059
5071
|
|
|
5060
5072
|
<details>
|
|
5061
5073
|
<summary>Click to see example response</summary>
|
|
5062
|
-
|
|
5074
|
+
|
|
5063
5075
|
```json
|
|
5064
5076
|
{
|
|
5065
5077
|
"recommendations": [
|
|
@@ -5273,14 +5285,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5273
5285
|
}
|
|
5274
5286
|
]
|
|
5275
5287
|
}
|
|
5276
|
-
```
|
|
5288
|
+
```
|
|
5277
5289
|
</details>
|
|
5278
5290
|
|
|
5279
5291
|
|
|
5280
5292
|
|
|
5281
5293
|
<details>
|
|
5282
5294
|
<summary>Click to see response schema</summary>
|
|
5283
|
-
|
|
5295
|
+
|
|
5284
5296
|
```json
|
|
5285
5297
|
{
|
|
5286
5298
|
"type": "object",
|
|
@@ -5408,7 +5420,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5408
5420
|
}
|
|
5409
5421
|
}
|
|
5410
5422
|
}
|
|
5411
|
-
```
|
|
5423
|
+
```
|
|
5412
5424
|
</details>
|
|
5413
5425
|
|
|
5414
5426
|
|
|
@@ -5445,7 +5457,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5445
5457
|
|
|
5446
5458
|
<details>
|
|
5447
5459
|
<summary>Click to see example response</summary>
|
|
5448
|
-
|
|
5460
|
+
|
|
5449
5461
|
```json
|
|
5450
5462
|
{
|
|
5451
5463
|
"episodes": [
|
|
@@ -5503,14 +5515,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5503
5515
|
}
|
|
5504
5516
|
]
|
|
5505
5517
|
}
|
|
5506
|
-
```
|
|
5518
|
+
```
|
|
5507
5519
|
</details>
|
|
5508
5520
|
|
|
5509
5521
|
|
|
5510
5522
|
|
|
5511
5523
|
<details>
|
|
5512
5524
|
<summary>Click to see response schema</summary>
|
|
5513
|
-
|
|
5525
|
+
|
|
5514
5526
|
```json
|
|
5515
5527
|
{
|
|
5516
5528
|
"type": "object",
|
|
@@ -5638,7 +5650,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5638
5650
|
}
|
|
5639
5651
|
}
|
|
5640
5652
|
}
|
|
5641
|
-
```
|
|
5653
|
+
```
|
|
5642
5654
|
</details>
|
|
5643
5655
|
|
|
5644
5656
|
|
|
@@ -5681,7 +5693,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
5681
5693
|
|
|
5682
5694
|
<details>
|
|
5683
5695
|
<summary>Click to see example response</summary>
|
|
5684
|
-
|
|
5696
|
+
|
|
5685
5697
|
```json
|
|
5686
5698
|
{
|
|
5687
5699
|
"podcasts": [
|
|
@@ -6664,14 +6676,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
6664
6676
|
],
|
|
6665
6677
|
"next_episode_pub_date": 1556519451000
|
|
6666
6678
|
}
|
|
6667
|
-
```
|
|
6679
|
+
```
|
|
6668
6680
|
</details>
|
|
6669
6681
|
|
|
6670
6682
|
|
|
6671
6683
|
|
|
6672
6684
|
<details>
|
|
6673
6685
|
<summary>Click to see response schema</summary>
|
|
6674
|
-
|
|
6686
|
+
|
|
6675
6687
|
```json
|
|
6676
6688
|
{
|
|
6677
6689
|
"type": "object",
|
|
@@ -7038,7 +7050,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
7038
7050
|
}
|
|
7039
7051
|
}
|
|
7040
7052
|
}
|
|
7041
|
-
```
|
|
7053
|
+
```
|
|
7042
7054
|
</details>
|
|
7043
7055
|
|
|
7044
7056
|
|
|
@@ -7074,7 +7086,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
7074
7086
|
|
|
7075
7087
|
<details>
|
|
7076
7088
|
<summary>Click to see example response</summary>
|
|
7077
|
-
|
|
7089
|
+
|
|
7078
7090
|
```json
|
|
7079
7091
|
{
|
|
7080
7092
|
"id": "a62a0cb1b27b452190a2db339da56d41",
|
|
@@ -7102,14 +7114,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
7102
7114
|
"maybe_audio_invalid": false,
|
|
7103
7115
|
"listennotes_edit_url": "https://www.listennotes.com/e/a62a0cb1b27b452190a2db339da56d41/#edit"
|
|
7104
7116
|
}
|
|
7105
|
-
```
|
|
7117
|
+
```
|
|
7106
7118
|
</details>
|
|
7107
7119
|
|
|
7108
7120
|
|
|
7109
7121
|
|
|
7110
7122
|
<details>
|
|
7111
7123
|
<summary>Click to see response schema</summary>
|
|
7112
|
-
|
|
7124
|
+
|
|
7113
7125
|
```json
|
|
7114
7126
|
{
|
|
7115
7127
|
"type": "object",
|
|
@@ -7226,7 +7238,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
7226
7238
|
}
|
|
7227
7239
|
}
|
|
7228
7240
|
}
|
|
7229
|
-
```
|
|
7241
|
+
```
|
|
7230
7242
|
</details>
|
|
7231
7243
|
|
|
7232
7244
|
|
|
@@ -7264,7 +7276,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
7264
7276
|
|
|
7265
7277
|
<details>
|
|
7266
7278
|
<summary>Click to see example response</summary>
|
|
7267
|
-
|
|
7279
|
+
|
|
7268
7280
|
```json
|
|
7269
7281
|
{
|
|
7270
7282
|
"id": "SDFKduyJ47r",
|
|
@@ -8122,14 +8134,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
8122
8134
|
"source_domain": "www.buzzfeed.com",
|
|
8123
8135
|
"listennotes_url": "https://www.listennotes.com/curated-podcasts/16-brilliant-indian-podcasts-thatll-SDFKduyJ47r/"
|
|
8124
8136
|
}
|
|
8125
|
-
```
|
|
8137
|
+
```
|
|
8126
8138
|
</details>
|
|
8127
8139
|
|
|
8128
8140
|
|
|
8129
8141
|
|
|
8130
8142
|
<details>
|
|
8131
8143
|
<summary>Click to see response schema</summary>
|
|
8132
|
-
|
|
8144
|
+
|
|
8133
8145
|
```json
|
|
8134
8146
|
{
|
|
8135
8147
|
"type": "object",
|
|
@@ -8415,7 +8427,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
8415
8427
|
}
|
|
8416
8428
|
}
|
|
8417
8429
|
}
|
|
8418
|
-
```
|
|
8430
|
+
```
|
|
8419
8431
|
</details>
|
|
8420
8432
|
|
|
8421
8433
|
|
|
@@ -8452,7 +8464,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
8452
8464
|
|
|
8453
8465
|
<details>
|
|
8454
8466
|
<summary>Click to see example response</summary>
|
|
8455
|
-
|
|
8467
|
+
|
|
8456
8468
|
```json
|
|
8457
8469
|
{
|
|
8458
8470
|
"total": 4130,
|
|
@@ -9654,14 +9666,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9654
9666
|
"next_page_number": 3,
|
|
9655
9667
|
"previous_page_number": 1
|
|
9656
9668
|
}
|
|
9657
|
-
```
|
|
9669
|
+
```
|
|
9658
9670
|
</details>
|
|
9659
9671
|
|
|
9660
9672
|
|
|
9661
9673
|
|
|
9662
9674
|
<details>
|
|
9663
9675
|
<summary>Click to see response schema</summary>
|
|
9664
|
-
|
|
9676
|
+
|
|
9665
9677
|
```json
|
|
9666
9678
|
{
|
|
9667
9679
|
"type": "object",
|
|
@@ -9798,7 +9810,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9798
9810
|
}
|
|
9799
9811
|
}
|
|
9800
9812
|
}
|
|
9801
|
-
```
|
|
9813
|
+
```
|
|
9802
9814
|
</details>
|
|
9803
9815
|
|
|
9804
9816
|
|
|
@@ -9835,20 +9847,20 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9835
9847
|
|
|
9836
9848
|
<details>
|
|
9837
9849
|
<summary>Click to see example response</summary>
|
|
9838
|
-
|
|
9850
|
+
|
|
9839
9851
|
```json
|
|
9840
9852
|
{
|
|
9841
9853
|
"status": "in review",
|
|
9842
9854
|
"podcast": {}
|
|
9843
9855
|
}
|
|
9844
|
-
```
|
|
9856
|
+
```
|
|
9845
9857
|
</details>
|
|
9846
9858
|
|
|
9847
9859
|
|
|
9848
9860
|
|
|
9849
9861
|
<details>
|
|
9850
9862
|
<summary>Click to see response schema</summary>
|
|
9851
|
-
|
|
9863
|
+
|
|
9852
9864
|
```json
|
|
9853
9865
|
{
|
|
9854
9866
|
"type": "object",
|
|
@@ -9914,7 +9926,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9914
9926
|
}
|
|
9915
9927
|
}
|
|
9916
9928
|
}
|
|
9917
|
-
```
|
|
9929
|
+
```
|
|
9918
9930
|
</details>
|
|
9919
9931
|
|
|
9920
9932
|
|
|
@@ -9951,19 +9963,19 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9951
9963
|
|
|
9952
9964
|
<details>
|
|
9953
9965
|
<summary>Click to see example response</summary>
|
|
9954
|
-
|
|
9966
|
+
|
|
9955
9967
|
```json
|
|
9956
9968
|
{
|
|
9957
9969
|
"status": "in review"
|
|
9958
9970
|
}
|
|
9959
|
-
```
|
|
9971
|
+
```
|
|
9960
9972
|
</details>
|
|
9961
9973
|
|
|
9962
9974
|
|
|
9963
9975
|
|
|
9964
9976
|
<details>
|
|
9965
9977
|
<summary>Click to see response schema</summary>
|
|
9966
|
-
|
|
9978
|
+
|
|
9967
9979
|
```json
|
|
9968
9980
|
{
|
|
9969
9981
|
"type": "object",
|
|
@@ -9982,7 +9994,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
9982
9994
|
}
|
|
9983
9995
|
}
|
|
9984
9996
|
}
|
|
9985
|
-
```
|
|
9997
|
+
```
|
|
9986
9998
|
</details>
|
|
9987
9999
|
|
|
9988
10000
|
|
|
@@ -10014,7 +10026,7 @@ const client = Client({
|
|
|
10014
10026
|
});
|
|
10015
10027
|
|
|
10016
10028
|
client.fetchPlaylistById({
|
|
10017
|
-
id: 'm1pe7z60bsw', type: 'episode_list', sort: 'recent_published_first',
|
|
10029
|
+
id: 'm1pe7z60bsw', type: 'episode_list', sort: 'recent_published_first',
|
|
10018
10030
|
}).then((response) => {
|
|
10019
10031
|
console.log(response.data);
|
|
10020
10032
|
}).catch((error) => {
|
|
@@ -10028,7 +10040,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
10028
10040
|
|
|
10029
10041
|
<details>
|
|
10030
10042
|
<summary>Click to see example response</summary>
|
|
10031
|
-
|
|
10043
|
+
|
|
10032
10044
|
```json
|
|
10033
10045
|
{
|
|
10034
10046
|
"id": "m1pe7z60bsw",
|
|
@@ -10665,14 +10677,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
10665
10677
|
"last_timestamp_ms": 1564614350360,
|
|
10666
10678
|
"total_audio_length_sec": 108657
|
|
10667
10679
|
}
|
|
10668
|
-
```
|
|
10680
|
+
```
|
|
10669
10681
|
</details>
|
|
10670
10682
|
|
|
10671
10683
|
|
|
10672
10684
|
|
|
10673
10685
|
<details>
|
|
10674
10686
|
<summary>Click to see response schema</summary>
|
|
10675
|
-
|
|
10687
|
+
|
|
10676
10688
|
```json
|
|
10677
10689
|
{
|
|
10678
10690
|
"type": "object",
|
|
@@ -11194,7 +11206,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11194
11206
|
}
|
|
11195
11207
|
}
|
|
11196
11208
|
}
|
|
11197
|
-
```
|
|
11209
|
+
```
|
|
11198
11210
|
</details>
|
|
11199
11211
|
|
|
11200
11212
|
|
|
@@ -11232,7 +11244,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11232
11244
|
|
|
11233
11245
|
<details>
|
|
11234
11246
|
<summary>Click to see example response</summary>
|
|
11235
|
-
|
|
11247
|
+
|
|
11236
11248
|
```json
|
|
11237
11249
|
{
|
|
11238
11250
|
"total": 3,
|
|
@@ -11280,14 +11292,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11280
11292
|
"next_page_number": 2,
|
|
11281
11293
|
"previous_page_number": 0
|
|
11282
11294
|
}
|
|
11283
|
-
```
|
|
11295
|
+
```
|
|
11284
11296
|
</details>
|
|
11285
11297
|
|
|
11286
11298
|
|
|
11287
11299
|
|
|
11288
11300
|
<details>
|
|
11289
11301
|
<summary>Click to see response schema</summary>
|
|
11290
|
-
|
|
11302
|
+
|
|
11291
11303
|
```json
|
|
11292
11304
|
{
|
|
11293
11305
|
"type": "object",
|
|
@@ -11387,7 +11399,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11387
11399
|
}
|
|
11388
11400
|
}
|
|
11389
11401
|
}
|
|
11390
|
-
```
|
|
11402
|
+
```
|
|
11391
11403
|
</details>
|
|
11392
11404
|
|
|
11393
11405
|
|
|
@@ -11423,7 +11435,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11423
11435
|
|
|
11424
11436
|
<details>
|
|
11425
11437
|
<summary>Click to see example response</summary>
|
|
11426
|
-
|
|
11438
|
+
|
|
11427
11439
|
```json
|
|
11428
11440
|
{
|
|
11429
11441
|
"terms": [
|
|
@@ -11439,14 +11451,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11439
11451
|
"Sheryl Sandberg"
|
|
11440
11452
|
]
|
|
11441
11453
|
}
|
|
11442
|
-
```
|
|
11454
|
+
```
|
|
11443
11455
|
</details>
|
|
11444
11456
|
|
|
11445
11457
|
|
|
11446
11458
|
|
|
11447
11459
|
<details>
|
|
11448
11460
|
<summary>Click to see response schema</summary>
|
|
11449
|
-
|
|
11461
|
+
|
|
11450
11462
|
```json
|
|
11451
11463
|
{
|
|
11452
11464
|
"type": "object",
|
|
@@ -11468,7 +11480,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11468
11480
|
}
|
|
11469
11481
|
}
|
|
11470
11482
|
}
|
|
11471
|
-
```
|
|
11483
|
+
```
|
|
11472
11484
|
</details>
|
|
11473
11485
|
|
|
11474
11486
|
|
|
@@ -11504,7 +11516,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11504
11516
|
|
|
11505
11517
|
<details>
|
|
11506
11518
|
<summary>Click to see example response</summary>
|
|
11507
|
-
|
|
11519
|
+
|
|
11508
11520
|
```json
|
|
11509
11521
|
{
|
|
11510
11522
|
"terms": [
|
|
@@ -11518,14 +11530,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11518
11530
|
"evergrande debt"
|
|
11519
11531
|
]
|
|
11520
11532
|
}
|
|
11521
|
-
```
|
|
11533
|
+
```
|
|
11522
11534
|
</details>
|
|
11523
11535
|
|
|
11524
11536
|
|
|
11525
11537
|
|
|
11526
11538
|
<details>
|
|
11527
11539
|
<summary>Click to see response schema</summary>
|
|
11528
|
-
|
|
11540
|
+
|
|
11529
11541
|
```json
|
|
11530
11542
|
{
|
|
11531
11543
|
"type": "object",
|
|
@@ -11548,7 +11560,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11548
11560
|
}
|
|
11549
11561
|
}
|
|
11550
11562
|
}
|
|
11551
|
-
```
|
|
11563
|
+
```
|
|
11552
11564
|
</details>
|
|
11553
11565
|
|
|
11554
11566
|
|
|
@@ -11584,7 +11596,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11584
11596
|
|
|
11585
11597
|
<details>
|
|
11586
11598
|
<summary>Click to see example response</summary>
|
|
11587
|
-
|
|
11599
|
+
|
|
11588
11600
|
```json
|
|
11589
11601
|
{
|
|
11590
11602
|
"tokens": [
|
|
@@ -11601,14 +11613,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11601
11613
|
],
|
|
11602
11614
|
"corrected_text_html": "<b><i>evergrande</i></b> <b><i>stock</i></b>"
|
|
11603
11615
|
}
|
|
11604
|
-
```
|
|
11616
|
+
```
|
|
11605
11617
|
</details>
|
|
11606
11618
|
|
|
11607
11619
|
|
|
11608
11620
|
|
|
11609
11621
|
<details>
|
|
11610
11622
|
<summary>Click to see response schema</summary>
|
|
11611
|
-
|
|
11623
|
+
|
|
11612
11624
|
```json
|
|
11613
11625
|
{
|
|
11614
11626
|
"type": "object",
|
|
@@ -11648,7 +11660,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11648
11660
|
}
|
|
11649
11661
|
}
|
|
11650
11662
|
}
|
|
11651
|
-
```
|
|
11663
|
+
```
|
|
11652
11664
|
</details>
|
|
11653
11665
|
|
|
11654
11666
|
|
|
@@ -11684,7 +11696,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11684
11696
|
|
|
11685
11697
|
<details>
|
|
11686
11698
|
<summary>Click to see example response</summary>
|
|
11687
|
-
|
|
11699
|
+
|
|
11688
11700
|
```json
|
|
11689
11701
|
{
|
|
11690
11702
|
"by_regions": [
|
|
@@ -11922,14 +11934,14 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11922
11934
|
}
|
|
11923
11935
|
]
|
|
11924
11936
|
}
|
|
11925
|
-
```
|
|
11937
|
+
```
|
|
11926
11938
|
</details>
|
|
11927
11939
|
|
|
11928
11940
|
|
|
11929
11941
|
|
|
11930
11942
|
<details>
|
|
11931
11943
|
<summary>Click to see response schema</summary>
|
|
11932
|
-
|
|
11944
|
+
|
|
11933
11945
|
```json
|
|
11934
11946
|
{
|
|
11935
11947
|
"type": "object",
|
|
@@ -11954,7 +11966,7 @@ See all available parameters on the [API Docs page](https://www.listennotes.com/
|
|
|
11954
11966
|
}
|
|
11955
11967
|
}
|
|
11956
11968
|
}
|
|
11957
|
-
```
|
|
11969
|
+
```
|
|
11958
11970
|
</details>
|
|
11959
11971
|
|
|
11960
11972
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podcast-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "JavaScript bindings for the Listen Notes Podcast API",
|
|
5
5
|
"main": "src/PodcastApiClient.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rm -rf ./.nyc_output ./node_modules/.cache",
|
|
8
8
|
"lint": "eslint --ext .js,.jsx .",
|
|
9
|
-
"test": "jest"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"testMatch": [
|
|
13
|
-
"**/tests/*Test.js"
|
|
14
|
-
],
|
|
15
|
-
"testEnvironment": "node"
|
|
9
|
+
"test": "jest --config jest.config.node.json && jest --config jest.config.minifare.json",
|
|
10
|
+
"test-node": "jest --config jest.config.node.json",
|
|
11
|
+
"test-workers": "jest --config jest.config.minifare.json"
|
|
16
12
|
},
|
|
17
13
|
"repository": {
|
|
18
14
|
"type": "git",
|
|
@@ -23,7 +19,9 @@
|
|
|
23
19
|
"podcast",
|
|
24
20
|
"api",
|
|
25
21
|
"podcast search",
|
|
26
|
-
"search engine"
|
|
22
|
+
"search engine",
|
|
23
|
+
"Cloudflare Workers",
|
|
24
|
+
"Node.js"
|
|
27
25
|
],
|
|
28
26
|
"engines": {
|
|
29
27
|
"node": ">=10.*"
|
|
@@ -33,16 +31,16 @@
|
|
|
33
31
|
"bugs": {
|
|
34
32
|
"url": "https://github.com/ListenNotes/podcast-api-js/issues"
|
|
35
33
|
},
|
|
36
|
-
"homepage": "https://
|
|
34
|
+
"homepage": "https://www.listennotes.com/api/",
|
|
37
35
|
"dependencies": {
|
|
38
|
-
"axios": "^0.21.1"
|
|
39
|
-
"query-string": "^7.0.1"
|
|
36
|
+
"axios": "^0.21.1"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
39
|
"eslint": "^7.25.0",
|
|
43
40
|
"eslint-plugin-import": "^2.22.1",
|
|
44
41
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
45
42
|
"jest": "^26.6.3",
|
|
43
|
+
"jest-environment-miniflare": "^2.10.0",
|
|
46
44
|
"mocha": "^8.3.2",
|
|
47
45
|
"prettier": "^2.2.1"
|
|
48
46
|
}
|
package/src/Constants.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const API_BASE_PROD = 'https://listen-api.listennotes.com/api/v2';
|
|
2
|
+
|
|
3
|
+
const API_BASE_TEST = 'https://listen-api-test.listennotes.com/api/v2';
|
|
4
|
+
|
|
5
|
+
const defaultUserAgent = 'podcasts-api-js';
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
API_BASE_PROD,
|
|
9
|
+
API_BASE_TEST,
|
|
10
|
+
defaultUserAgent,
|
|
11
|
+
};
|
package/src/PodcastApiClient.js
CHANGED
|
@@ -1,114 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const API_BASE_PROD = 'https://listen-api.listennotes.com/api/v2';
|
|
5
|
-
|
|
6
|
-
const API_BASE_TEST = 'https://listen-api-test.listennotes.com/api/v2';
|
|
7
|
-
|
|
8
|
-
const defaultUserAgent = 'podcasts-api-js';
|
|
9
|
-
|
|
10
|
-
const Client = (config = {}) => {
|
|
11
|
-
this.config = config;
|
|
12
|
-
|
|
13
|
-
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
14
|
-
this.httpClient = axios.create({
|
|
15
|
-
baseURL: config.apiKey ? API_BASE_PROD : API_BASE_TEST,
|
|
16
|
-
timeout: 30000,
|
|
17
|
-
headers: {
|
|
18
|
-
'X-ListenAPI-Key': config.apiKey || '',
|
|
19
|
-
'User-Agent': config.userAgent || defaultUserAgent,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
this._post = (path, params) => this.httpClient.post(path, queryString.stringify(params));
|
|
24
|
-
|
|
25
|
-
this.search = (params) => this.httpClient.get('/search', { params });
|
|
26
|
-
|
|
27
|
-
this.typeahead = (params) => this.httpClient.get('/typeahead', { params });
|
|
28
|
-
|
|
29
|
-
this.spellcheck = (params) => this.httpClient.get('/spellcheck', { params });
|
|
30
|
-
|
|
31
|
-
this.fetchRelatedSearches = (params) => this.httpClient.get('/related_searches', { params });
|
|
32
|
-
|
|
33
|
-
this.fetchTrendingSearches = (params) => this.httpClient.get('/trending_searches', { params });
|
|
34
|
-
|
|
35
|
-
this.fetchBestPodcasts = (params) => this.httpClient.get('/best_podcasts', { params });
|
|
36
|
-
|
|
37
|
-
this.fetchPodcastById = (params) => {
|
|
38
|
-
const { id, ...otherParams } = params;
|
|
39
|
-
return this.httpClient.get(`/podcasts/${id}`, {
|
|
40
|
-
params: otherParams,
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
this.fetchEpisodeById = (params) => {
|
|
45
|
-
const { id, ...otherParams } = params;
|
|
46
|
-
return this.httpClient.get(`/episodes/${id}`, {
|
|
47
|
-
params: otherParams,
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
this.batchFetchPodcasts = (params) => this._post('/podcasts', params);
|
|
52
|
-
|
|
53
|
-
this.batchFetchEpisodes = (params) => this._post('/episodes', params);
|
|
54
|
-
|
|
55
|
-
this.fetchCuratedPodcastsListById = (params) => {
|
|
56
|
-
const { id, ...otherParams } = params;
|
|
57
|
-
return this.httpClient.get(`/curated_podcasts/${id}`, {
|
|
58
|
-
params: otherParams,
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this.fetchCuratedPodcastsLists = (params) => this.httpClient.get('/curated_podcasts', { params });
|
|
63
|
-
|
|
64
|
-
this.fetchPodcastGenres = (params) => this.httpClient.get('/genres', { params });
|
|
65
|
-
|
|
66
|
-
this.fetchPodcastRegions = (params) => this.httpClient.get('/regions', { params });
|
|
67
|
-
|
|
68
|
-
this.fetchPodcastLanguages = (params) => this.httpClient.get('/languages', { params });
|
|
69
|
-
|
|
70
|
-
this.justListen = (params) => this.httpClient.get('/just_listen', { params });
|
|
71
|
-
|
|
72
|
-
this.fetchRecommendationsForPodcast = (params) => {
|
|
73
|
-
const { id, ...otherParams } = params;
|
|
74
|
-
return this.httpClient.get(`/podcasts/${id}/recommendations`, {
|
|
75
|
-
params: otherParams,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
this.fetchRecommendationsForEpisode = (params) => {
|
|
80
|
-
const { id, ...otherParams } = params;
|
|
81
|
-
return this.httpClient.get(`/episodes/${id}/recommendations`, {
|
|
82
|
-
params: otherParams,
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
this.fetchPlaylistById = (params) => {
|
|
87
|
-
const { id, ...otherParams } = params;
|
|
88
|
-
return this.httpClient.get(`/playlists/${id}`, {
|
|
89
|
-
params: otherParams,
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
this.fetchMyPlaylists = (params) => this.httpClient.get('/playlists', { params });
|
|
94
|
-
|
|
95
|
-
this.submitPodcast = (params) => this._post('/podcasts/submit', params);
|
|
96
|
-
|
|
97
|
-
this.deletePodcast = (params) => {
|
|
98
|
-
const { id, reason } = params;
|
|
99
|
-
return this.httpClient.delete(`/podcasts/${id}?reason=${reason || ''}`);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
this.fetchAudienceForPodcast = (params) => {
|
|
103
|
-
const { id, ...otherParams } = params;
|
|
104
|
-
return this.httpClient.get(`/podcasts/${id}/audience`, {
|
|
105
|
-
params: otherParams,
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return this;
|
|
110
|
-
};
|
|
1
|
+
const { ClientForNode } = require('./PodcastApiClientForNode');
|
|
2
|
+
const { ClientForWorkers } = require('./PodcastApiClientForWorkers');
|
|
111
3
|
|
|
112
4
|
module.exports = {
|
|
113
|
-
Client,
|
|
5
|
+
Client: ClientForNode,
|
|
6
|
+
ClientForNode,
|
|
7
|
+
ClientForWorkers,
|
|
114
8
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { API_BASE_PROD, API_BASE_TEST, defaultUserAgent } = require('./Constants');
|
|
2
|
+
const { addApiMethodsToClient } = require('./PodcastApiMethods');
|
|
3
|
+
|
|
4
|
+
const ClientForNode = (config = {}) => {
|
|
5
|
+
const axios = require('axios');
|
|
6
|
+
|
|
7
|
+
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
8
|
+
this.httpClient = axios.create({
|
|
9
|
+
baseURL: config.apiKey ? API_BASE_PROD : API_BASE_TEST,
|
|
10
|
+
timeout: 30000,
|
|
11
|
+
headers: {
|
|
12
|
+
'X-ListenAPI-Key': config.apiKey || '',
|
|
13
|
+
'User-Agent': config.userAgent || defaultUserAgent,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
this.httpClient._get = (path, params) => this.httpClient.get(path, { params });
|
|
18
|
+
this.httpClient._post = (path, params) => this.httpClient.post(path, new URLSearchParams(params).toString());
|
|
19
|
+
this.httpClient._delete = (path) => this.httpClient.delete(path);
|
|
20
|
+
|
|
21
|
+
return addApiMethodsToClient(this);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
ClientForNode,
|
|
26
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const {API_BASE_PROD, API_BASE_TEST, defaultUserAgent} = require('./Constants');
|
|
2
|
+
const {addApiMethodsToClient} = require('./PodcastApiMethods');
|
|
3
|
+
|
|
4
|
+
const _fetch = (path, config, method = 'GET', queryParams = {}, formParams = null) => {
|
|
5
|
+
let url = `${config.apiKey ? API_BASE_PROD : API_BASE_TEST}${path}`;
|
|
6
|
+
const headers = {
|
|
7
|
+
'X-ListenAPI-Key': config.apiKey || '',
|
|
8
|
+
'User-Agent': config.userAgent || defaultUserAgent,
|
|
9
|
+
};
|
|
10
|
+
const fetchConfig = {
|
|
11
|
+
method,
|
|
12
|
+
headers,
|
|
13
|
+
};
|
|
14
|
+
let formParamsString = null;
|
|
15
|
+
if (formParams) {
|
|
16
|
+
fetchConfig.body = formParams;
|
|
17
|
+
formParamsString = [...formParams.entries()].map(
|
|
18
|
+
x => `${encodeURIComponent(x[0])}=${encodeURIComponent(x[1])}`).join('&');
|
|
19
|
+
}
|
|
20
|
+
if (queryParams) {
|
|
21
|
+
url = `${url}?${new URLSearchParams(queryParams).toString()}`
|
|
22
|
+
}
|
|
23
|
+
const responseConfig = {
|
|
24
|
+
params: queryParams,
|
|
25
|
+
data: formParamsString,
|
|
26
|
+
url: path,
|
|
27
|
+
method: method.toLowerCase(),
|
|
28
|
+
};
|
|
29
|
+
const responseHeaders = {};
|
|
30
|
+
return fetch(url, fetchConfig).then((response) => {
|
|
31
|
+
if (response.headers) {
|
|
32
|
+
for (const pair of response.headers.entries()) {
|
|
33
|
+
responseHeaders[pair[0]] = pair[1];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (response.ok) {
|
|
38
|
+
return response;
|
|
39
|
+
} else {
|
|
40
|
+
const err = new Error(`HTTP ${response.status}`);
|
|
41
|
+
err.response = response;
|
|
42
|
+
err.response.config = responseConfig;
|
|
43
|
+
err.response.headers = responseHeaders;
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}).then((response) => {
|
|
47
|
+
return response.json();
|
|
48
|
+
}).then((data) => {
|
|
49
|
+
return {
|
|
50
|
+
config: responseConfig,
|
|
51
|
+
headers: responseHeaders,
|
|
52
|
+
data,
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const ClientForWorkers = (config = {}) => {
|
|
58
|
+
this.httpClient = {
|
|
59
|
+
_get: (path, params) => {
|
|
60
|
+
return _fetch(path, config, 'GET', params);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
_post: (path, params) => {
|
|
64
|
+
let formData = null;
|
|
65
|
+
if (params && Object.keys(params).length > 0) {
|
|
66
|
+
formData = new FormData();
|
|
67
|
+
Object.keys(params).forEach(function (key) {
|
|
68
|
+
formData.append(key, params[key]);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return _fetch(path, config, 'POST', {}, formData)
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
_delete: (path) => {
|
|
75
|
+
return _fetch(path, config, 'DELETE')
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
return addApiMethodsToClient(this);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
ClientForWorkers,
|
|
83
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const addApiMethodsToClient = (client) => {
|
|
2
|
+
client.search = (params) => client.httpClient._get('/search', params);
|
|
3
|
+
|
|
4
|
+
client.typeahead = (params) => client.httpClient._get('/typeahead', params);
|
|
5
|
+
|
|
6
|
+
client.spellcheck = (params) => client.httpClient._get('/spellcheck', params);
|
|
7
|
+
|
|
8
|
+
client.fetchRelatedSearches = (params) => client.httpClient._get('/related_searches', params);
|
|
9
|
+
|
|
10
|
+
client.fetchTrendingSearches = (params) => client.httpClient._get('/trending_searches', params);
|
|
11
|
+
|
|
12
|
+
client.fetchBestPodcasts = (params) => client.httpClient._get('/best_podcasts', params);
|
|
13
|
+
|
|
14
|
+
client.fetchPodcastById = (params) => {
|
|
15
|
+
const { id, ...otherParams } = params;
|
|
16
|
+
return client.httpClient._get(`/podcasts/${id}`, otherParams);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
client.fetchEpisodeById = (params) => {
|
|
20
|
+
const { id, ...otherParams } = params;
|
|
21
|
+
return client.httpClient._get(`/episodes/${id}`, otherParams);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
client.batchFetchPodcasts = (params) => client.httpClient._post('/podcasts', params);
|
|
25
|
+
|
|
26
|
+
client.batchFetchEpisodes = (params) => client.httpClient._post('/episodes', params);
|
|
27
|
+
|
|
28
|
+
client.fetchCuratedPodcastsListById = (params) => {
|
|
29
|
+
const { id, ...otherParams } = params;
|
|
30
|
+
return client.httpClient._get(`/curated_podcasts/${id}`, otherParams);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
client.fetchCuratedPodcastsLists = (params) => client.httpClient._get('/curated_podcasts', params);
|
|
34
|
+
|
|
35
|
+
client.fetchPodcastGenres = (params) => client.httpClient._get('/genres', params);
|
|
36
|
+
|
|
37
|
+
client.fetchPodcastRegions = (params) => client.httpClient._get('/regions', params);
|
|
38
|
+
|
|
39
|
+
client.fetchPodcastLanguages = (params) => client.httpClient._get('/languages', params);
|
|
40
|
+
|
|
41
|
+
client.justListen = (params) => client.httpClient._get('/just_listen', params);
|
|
42
|
+
|
|
43
|
+
client.fetchRecommendationsForPodcast = (params) => {
|
|
44
|
+
const { id, ...otherParams } = params;
|
|
45
|
+
return client.httpClient._get(`/podcasts/${id}/recommendations`, otherParams);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
client.fetchRecommendationsForEpisode = (params) => {
|
|
49
|
+
const { id, ...otherParams } = params;
|
|
50
|
+
return client.httpClient._get(`/episodes/${id}/recommendations`, otherParams);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
client.fetchPlaylistById = (params) => {
|
|
54
|
+
const { id, ...otherParams } = params;
|
|
55
|
+
return client.httpClient._get(`/playlists/${id}`, otherParams);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
client.fetchMyPlaylists = (params) => client.httpClient._get('/playlists', params);
|
|
59
|
+
|
|
60
|
+
client.submitPodcast = (params) => client.httpClient._post('/podcasts/submit', params);
|
|
61
|
+
|
|
62
|
+
client.deletePodcast = (params) => {
|
|
63
|
+
const { id, reason } = params;
|
|
64
|
+
return client.httpClient._delete(`/podcasts/${id}?reason=${reason || ''}`);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
client.fetchAudienceForPodcast = (params) => {
|
|
68
|
+
const { id, ...otherParams } = params;
|
|
69
|
+
return client.httpClient._get(`/podcasts/${id}/audience`, otherParams);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return client;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports = {
|
|
76
|
+
addApiMethodsToClient,
|
|
77
|
+
};
|