podcast-api 1.0.9
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/LICENSE +21 -0
- package/README.md +10836 -0
- package/package.json +49 -0
- package/src/PodcastApiClient.js +101 -0
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "podcast-api",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "JavaScript bindings for the Listen Notes Podcast API",
|
|
5
|
+
"main": "src/PodcastApiClient.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"clean": "rm -rf ./.nyc_output ./node_modules/.cache",
|
|
8
|
+
"lint": "eslint --ext .js,.jsx .",
|
|
9
|
+
"test": "jest"
|
|
10
|
+
},
|
|
11
|
+
"jest": {
|
|
12
|
+
"testMatch": [
|
|
13
|
+
"**/tests/*Test.js"
|
|
14
|
+
],
|
|
15
|
+
"testEnvironment": "node"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ListenNotes/podcast-api-js.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"Listen Notes",
|
|
23
|
+
"podcast",
|
|
24
|
+
"api",
|
|
25
|
+
"podcast search",
|
|
26
|
+
"search engine"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=10.*"
|
|
30
|
+
},
|
|
31
|
+
"author": "Listen Notes, Inc. <hello@listennotes.com> (https://www.listennotes.com/)",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/ListenNotes/podcast-api-js/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/ListenNotes/podcast-api-js",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"axios": "^0.21.1",
|
|
39
|
+
"query-string": "^7.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"eslint": "^7.25.0",
|
|
43
|
+
"eslint-plugin-import": "^2.22.1",
|
|
44
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
45
|
+
"jest": "^26.6.3",
|
|
46
|
+
"mocha": "^8.3.2",
|
|
47
|
+
"prettier": "^2.2.1"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const queryString = require('query-string');
|
|
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.fetchBestPodcasts = (params) => this.httpClient.get('/best_podcasts', { params });
|
|
30
|
+
|
|
31
|
+
this.fetchPodcastById = (params) => {
|
|
32
|
+
const { id, ...otherParams } = params;
|
|
33
|
+
return this.httpClient.get(`/podcasts/${id}`, {
|
|
34
|
+
otherParams,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
this.fetchEpisodeById = (params) => {
|
|
39
|
+
const { id, ...otherParams } = params;
|
|
40
|
+
return this.httpClient.get(`/episodes/${id}`, {
|
|
41
|
+
otherParams,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
this.batchFetchPodcasts = (params) => this._post('/podcasts', params);
|
|
46
|
+
|
|
47
|
+
this.batchFetchEpisodes = (params) => this._post('/episodes', params);
|
|
48
|
+
|
|
49
|
+
this.fetchCuratedPodcastsListById = (params) => {
|
|
50
|
+
const { id, ...otherParams } = params;
|
|
51
|
+
return this.httpClient.get(`/curated_podcasts/${id}`, {
|
|
52
|
+
otherParams,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.fetchCuratedPodcastsLists = (params) => this.httpClient.get('/curated_podcasts', { params });
|
|
57
|
+
|
|
58
|
+
this.fetchPodcastGenres = (params) => this.httpClient.get('/genres', { params });
|
|
59
|
+
|
|
60
|
+
this.fetchPodcastRegions = (params) => this.httpClient.get('/regions', { params });
|
|
61
|
+
|
|
62
|
+
this.fetchPodcastLanguages = (params) => this.httpClient.get('/languages', { params });
|
|
63
|
+
|
|
64
|
+
this.justListen = (params) => this.httpClient.get('/just_listen', { params });
|
|
65
|
+
|
|
66
|
+
this.fetchRecommendationsForPodcast = (params) => {
|
|
67
|
+
const { id, ...otherParams } = params;
|
|
68
|
+
return this.httpClient.get(`/podcasts/${id}/recommendations`, {
|
|
69
|
+
otherParams,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
this.fetchRecommendationsForEpisode = (params) => {
|
|
74
|
+
const { id, ...otherParams } = params;
|
|
75
|
+
return this.httpClient.get(`/episodes/${id}/recommendations`, {
|
|
76
|
+
otherParams,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
this.fetchPlaylistById = (params) => {
|
|
81
|
+
const { id, ...otherParams } = params;
|
|
82
|
+
return this.httpClient.get(`/playlists/${id}`, {
|
|
83
|
+
otherParams,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
this.fetchMyPlaylists = (params) => this.httpClient.get('/playlists', { params });
|
|
88
|
+
|
|
89
|
+
this.submitPodcast = (params) => this._post('/podcasts/submit', params);
|
|
90
|
+
|
|
91
|
+
this.deletePodcast = (params) => {
|
|
92
|
+
const { id, reason } = params;
|
|
93
|
+
return this.httpClient.delete(`/podcasts/${id}?reason=${reason || ''}`);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return this;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
Client,
|
|
101
|
+
};
|