1 | > A Node.JS wrapper for The Movie DB API.
|
2 |
|
3 | [![install size](https://packagephobia.now.sh/badge?p=node-themoviedb)](https://packagephobia.now.sh/result?p=node-themoviedb)
|
4 | [![npm](https://img.shields.io/npm/dm/node-themoviedb?style=flat)](https://www.npmjs.com/package/node-themoviedb)
|
5 | [![npm](https://img.shields.io/npm/v/node-themoviedb)](https://www.npmjs.com/package/node-themoviedb)
|
6 | ![GitHub last commit](https://img.shields.io/github/last-commit/andywampir/node-themoviedb)
|
7 |
|
8 | # Highlights
|
9 | - [Installation](#install)
|
10 | - [Usage](#usage)
|
11 | - [Common Usage of Methods](#common-usage-of-methods)
|
12 | - [API](#api)
|
13 |
|
14 | # Install
|
15 | ```bash
|
16 | yarn add node-themoviedb
|
17 | ```
|
18 | or
|
19 | ```bash
|
20 | npm install node-themoviedb
|
21 | ```
|
22 |
|
23 | # Usage
|
24 | ```js
|
25 | const MovieDB = require('node-themoviedb');
|
26 | // ES6 Style
|
27 | // import MovieDB from 'node-themoviedb';
|
28 | const mdb = new MovieDB(/* Your API Key */, options);
|
29 |
|
30 | (async () => {
|
31 | try {
|
32 | const args = {
|
33 | pathParameters: {
|
34 | movie_id: 384018,
|
35 | },
|
36 | };
|
37 | const movie = await mdb.movie.getDetails(args);
|
38 | console.log(movie);
|
39 | /*
|
40 | {
|
41 | data: Object. Parsed json data of response
|
42 | headers: Object. Headers of response
|
43 | }
|
44 | */
|
45 | } catch (error) {
|
46 | console.error(error);
|
47 | }
|
48 | })();
|
49 | ```
|
50 | ## Common Usage of Methods
|
51 | ```js
|
52 | const args = {
|
53 | pathParameters: {
|
54 | // path parameters for query, i.e. tv_id
|
55 | },
|
56 | query: {
|
57 | // query string, i.e. session_id
|
58 | // NOTE: api_key and language will be added to query by default, don't need specify these values
|
59 | },
|
60 | body: {
|
61 | // data for request body
|
62 | },
|
63 | };
|
64 | const response = await mdb.tv.getVideos(args);
|
65 | // Or nested methods
|
66 | // const response = await mdb.tv.episode.rateTVEpisode(args);
|
67 | ```
|
68 |
|
69 | # API
|
70 |
|
71 | ## constructor(apiKey[, options])
|
72 |
|
73 | ### apiKey
|
74 |
|
75 | Your API key. [How to get API key](https://developers.themoviedb.org/3/getting-started/introduction)
|
76 |
|
77 | ### options
|
78 |
|
79 | - language - Optional. Default is `'en-US'`
|
80 |
|
81 | Additional options, which will be override the default settings
|
82 |
|
83 | ## setApiKey(apiKey)
|
84 |
|
85 | Sets API key
|
86 |
|
87 | ### apiKey
|
88 |
|
89 | Your API key
|
90 |
|
91 | ## setLanguage(language)
|
92 |
|
93 | Sets language for data of response
|
94 |
|
95 | ### language
|
96 |
|
97 | Language in ISO 639-1 format. I.e. `'en-US'`
|
98 |
|
99 |
|
100 | ## Methods
|
101 | - account
|
102 | - [getDetails](https://developers.themoviedb.org/3/account/get-account-details)
|
103 | - [getCreatedList](https://developers.themoviedb.org/3/account/get-created-lists)
|
104 | - [getFavoriteMovies](https://developers.themoviedb.org/3/account/get-favorite-movies)
|
105 | - [getFavoriteTVShows](https://developers.themoviedb.org/3/account/get-favorite-tv-shows)
|
106 | - [markAsFavorite](https://developers.themoviedb.org/3/account/mark-as-favorite)
|
107 | - [getRatedMovies](https://developers.themoviedb.org/3/account/get-rated-movies)
|
108 | - [getRatedTVShows](https://developers.themoviedb.org/3/account/get-rated-tv-shows)
|
109 | - [getRatedTVEpisodes](https://developers.themoviedb.org/3/account/get-rated-tv-episodes)
|
110 | - [getMovieWatchlist](https://developers.themoviedb.org/3/account/get-movie-watchlist)
|
111 | - [getTVShowWatchlist](https://developers.themoviedb.org/3/account/get-tv-show-watchlist)
|
112 | - [addToWatchlist](https://developers.themoviedb.org/3/account/add-to-watchlist)
|
113 | - authentication
|
114 | - [createGuestSession](https://developers.themoviedb.org/3/authentication/create-guest-session)
|
115 | - [createRequestToken](https://developers.themoviedb.org/3/authentication/create-request-token)
|
116 | - [createSession](https://developers.themoviedb.org/3/authentication/create-session)
|
117 | - [createSessionWithLogin](https://developers.themoviedb.org/3/authentication/validate-request-token)
|
118 | - [createSessionFromAccessToken](https://developers.themoviedb.org/3/authentication/create-session-from-v4-access-token)
|
119 | - [deleteSession](https://developers.themoviedb.org/3/authentication/delete-session)
|
120 | - certification
|
121 | - [getMovieCertifications](https://developers.themoviedb.org/3/certifications/get-movie-certifications)
|
122 | - [getTVCertifications](https://developers.themoviedb.org/3/certifications/get-tv-certifications)
|
123 | - collection
|
124 | - [getDetails](https://developers.themoviedb.org/3/collections/get-collection-details)
|
125 | - [getImages](https://developers.themoviedb.org/3/collections/get-collection-images)
|
126 | - [getTranslations](https://developers.themoviedb.org/3/collections/get-collection-translations)
|
127 | - company
|
128 | - [getDetails](https://developers.themoviedb.org/3/companies/get-company-details)
|
129 | - [getAlternativeNames](https://developers.themoviedb.org/3/companies/get-company-alternative-names)
|
130 | - [getImages](https://developers.themoviedb.org/3/companies/get-company-images)
|
131 | - configuration
|
132 | - [getAPIConfiguration](https://developers.themoviedb.org/3/configuration/get-api-configuration)
|
133 | - [getCountries](https://developers.themoviedb.org/3/configuration/get-countries)
|
134 | - [getJobs](https://developers.themoviedb.org/3/configuration/get-jobs)
|
135 | - [getLanguages](https://developers.themoviedb.org/3/configuration/get-languages)
|
136 | - [getPrimaryTranslations](https://developers.themoviedb.org/3/configuration/get-primary-translations)
|
137 | - [getTimezones](https://developers.themoviedb.org/3/configuration/get-timezones)
|
138 | - credit
|
139 | - [getDetails](https://developers.themoviedb.org/3/credits/get-credit-details)
|
140 | - discover
|
141 | - [movie](https://developers.themoviedb.org/3/discover/movie-discover)
|
142 | - [tv](https://developers.themoviedb.org/3/discover/tv-discover)
|
143 | - find
|
144 | - [byExternalID](https://developers.themoviedb.org/3/find/find-by-id)
|
145 | - genre
|
146 | - [getMovieList](https://developers.themoviedb.org/3/genres/get-movie-list)
|
147 | - [getTVList](https://developers.themoviedb.org/3/genres/get-tv-list)
|
148 | - guestSession
|
149 | - [getRatedMovies](https://developers.themoviedb.org/3/guest-sessions/get-guest-session-rated-movies)
|
150 | - [getRatedTVShows](https://developers.themoviedb.org/3/guest-sessions/get-guest-session-rated-tv-shows)
|
151 | - [getRatedTVEpisodes](https://developers.themoviedb.org/3/guest-sessions/get-gest-session-rated-tv-episodes)
|
152 | - keyword
|
153 | - [getDetails](https://developers.themoviedb.org/3/keywords/get-keyword-details)
|
154 | - [getMovies](https://developers.themoviedb.org/3/keywords/get-movies-by-keyword)
|
155 | - list
|
156 | - [getDetails](https://developers.themoviedb.org/3/lists/get-list-details)
|
157 | - [checkItemStatus](https://developers.themoviedb.org/3/lists/check-item-status)
|
158 | - [createList](https://developers.themoviedb.org/3/lists/create-list)
|
159 | - [addMovie](https://developers.themoviedb.org/3/lists/add-movie)
|
160 | - [removeMovie](https://developers.themoviedb.org/3/lists/remove-movie)
|
161 | - [clearList](https://developers.themoviedb.org/3/lists/clear-list)
|
162 | - [deleteList](https://developers.themoviedb.org/3/lists/delete-list)
|
163 | - movie
|
164 | - [getDetails](https://developers.themoviedb.org/3/movies/get-movie-details)
|
165 | - [getAccountStates](https://developers.themoviedb.org/3/movies/get-movie-account-states)
|
166 | - [getAlternativeTitles](https://developers.themoviedb.org/3/movies/get-movie-alternative-titles)
|
167 | - [getChanges](https://developers.themoviedb.org/3/movies/get-movie-changes)
|
168 | - [getCredits](https://developers.themoviedb.org/3/movies/get-movie-credits)
|
169 | - [getExternalIDs](https://developers.themoviedb.org/3/movies/get-movie-external-ids)
|
170 | - [getImages](https://developers.themoviedb.org/3/movies/get-movie-images)
|
171 | - [getKeywords](https://developers.themoviedb.org/3/movies/get-movie-keywords)
|
172 | - [getReleaseDates](https://developers.themoviedb.org/3/movies/get-movie-release-dates)
|
173 | - [getVideos](https://developers.themoviedb.org/3/movies/get-movie-videos)
|
174 | - [getTranslations](https://developers.themoviedb.org/3/movies/get-movie-translations)
|
175 | - [getRecommendations](https://developers.themoviedb.org/3/movies/get-movie-recommendations)
|
176 | - [getSimilarMovies](https://developers.themoviedb.org/3/movies/get-similar-movies)
|
177 | - [getReviews](https://developers.themoviedb.org/3/movies/get-movie-reviews)
|
178 | - [getLists](https://developers.themoviedb.org/3/movies/get-movie-lists)
|
179 | - [rateMovie](https://developers.themoviedb.org/3/movies/rate-movie)
|
180 | - [deleteRating](https://developers.themoviedb.org/3/movies/delete-movie-rating)
|
181 | - [getLatest](https://developers.themoviedb.org/3/movies/get-latest-movie)
|
182 | - [getNowPlaying](https://developers.themoviedb.org/3/movies/get-now-playing)
|
183 | - [getPopular](https://developers.themoviedb.org/3/movies/get-popular-movies)
|
184 | - [getTopRated](https://developers.themoviedb.org/3/movies/get-top-rated-movies)
|
185 | - [getUpcoming](https://developers.themoviedb.org/3/movies/get-upcoming)
|
186 | - [getChangeList](https://developers.themoviedb.org/3/changes/get-movie-change-list)
|
187 | - network
|
188 | - [getDetails](https://developers.themoviedb.org/3/networks/get-network-details)
|
189 | - [getAlternativeNames](https://developers.themoviedb.org/3/networks/get-network-alternative-names)
|
190 | - [getImages](https://developers.themoviedb.org/3/networks/get-network-images)
|
191 | - trending
|
192 | - [getTrending](https://developers.themoviedb.org/3/trending/get-trending)
|
193 | - person
|
194 | - [getDetails](https://developers.themoviedb.org/3/people/get-person-details)
|
195 | - [getChanges](https://developers.themoviedb.org/3/people/get-person-changes)
|
196 | - [getMovieCredits](https://developers.themoviedb.org/3/people/get-person-movie-credits)
|
197 | - [getTVCredits](https://developers.themoviedb.org/3/people/get-person-tv-credits)
|
198 | - [getCombinedCredits](https://developers.themoviedb.org/3/people/get-person-combined-credits)
|
199 | - [getExternalIDs](https://developers.themoviedb.org/3/people/get-person-external-ids)
|
200 | - [getImages](https://developers.themoviedb.org/3/people/get-person-images)
|
201 | - [getTaggedImages](https://developers.themoviedb.org/3/people/get-tagged-images)
|
202 | - [getTranslations](https://developers.themoviedb.org/3/people/get-person-translations)
|
203 | - [getLatest](https://developers.themoviedb.org/3/people/get-latest-person)
|
204 | - [getPopular](https://developers.themoviedb.org/3/people/get-popular-people)
|
205 | - [getChangeList](https://developers.themoviedb.org/3/changes/get-person-change-list)
|
206 | - review
|
207 | - [getDetails](https://developers.themoviedb.org/3/reviews/get-review-details)
|
208 | - search
|
209 | - [companies](https://developers.themoviedb.org/3/search/search-companies)
|
210 | - [collections](https://developers.themoviedb.org/3/search/search-collections)
|
211 | - [keywords](https://developers.themoviedb.org/3/search/search-keywords)
|
212 | - [movies](https://developers.themoviedb.org/3/search/search-movies)
|
213 | - [multi](https://developers.themoviedb.org/3/search/multi-search)
|
214 | - [people](https://developers.themoviedb.org/3/search/search-people)
|
215 | - [TVShows](https://developers.themoviedb.org/3/search/search-tv-shows)
|
216 | - tv
|
217 | - [getDetails](https://developers.themoviedb.org/3/tv/get-tv-details)
|
218 | - [getAccountStates](https://developers.themoviedb.org/3/tv/get-tv-account-states)
|
219 | - [getAlternativeTitles](https://developers.themoviedb.org/3/tv/get-tv-alternative-titles)
|
220 | - [getChanges](https://developers.themoviedb.org/3/tv/get-tv-changes)
|
221 | - [getContentRatings](https://developers.themoviedb.org/3/tv/get-tv-content-ratings)
|
222 | - [getCredits](https://developers.themoviedb.org/3/tv/get-tv-credits)
|
223 | - [getEpisodeGroups](https://developers.themoviedb.org/3/tv/get-tv-episode-groups)
|
224 | - [getExternalIDs](https://developers.themoviedb.org/3/tv/get-tv-external-ids)
|
225 | - [getImages](https://developers.themoviedb.org/3/tv/get-tv-images)
|
226 | - [getKeywords](https://developers.themoviedb.org/3/tv/get-tv-keywords)
|
227 | - [getRecommendations](https://developers.themoviedb.org/3/tv/get-tv-recommendations)
|
228 | - [getReviews](https://developers.themoviedb.org/3/tv/get-tv-reviews)
|
229 | - [getScreenedTheatrically](https://developers.themoviedb.org/3/tv/get-screened-theatrically)
|
230 | - [getSimilarTVShows](https://developers.themoviedb.org/3/tv/get-similar-tv-shows)
|
231 | - [getTranslations](https://developers.themoviedb.org/3/tv/get-tv-translations)
|
232 | - [getVideos](https://developers.themoviedb.org/3/tv/get-tv-videos)
|
233 | - [rateTVShow](https://developers.themoviedb.org/3/tv/rate-tv-show)
|
234 | - [deleteRating](https://developers.themoviedb.org/3/tv/delete-tv-show-rating)
|
235 | - [getLatest](https://developers.themoviedb.org/3/tv/get-latest-tv)
|
236 | - [getAiringToday](https://developers.themoviedb.org/3/tv/get-tv-airing-today)
|
237 | - [getOnAir](https://developers.themoviedb.org/3/tv/get-tv-on-the-air)
|
238 | - [getPopular](https://developers.themoviedb.org/3/tv/get-popular-tv-shows)
|
239 | - [getTopRated](https://developers.themoviedb.org/3/tv/get-top-rated-tv)
|
240 | - [getChangeList](https://developers.themoviedb.org/3/changes/get-tv-change-list)
|
241 | - season
|
242 | - [getDetails](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-details)
|
243 | - [getChanges](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-changes)
|
244 | - [getAccountStates](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-account-states)
|
245 | - [getCredits](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-credits)
|
246 | - [getExternalIDs](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-external-ids)
|
247 | - [getImages](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-images)
|
248 | - [getVideos](https://developers.themoviedb.org/3/tv-seasons/get-tv-season-videos)
|
249 | - episode
|
250 | - [getDetails](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-details)
|
251 | - [getChanges](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-changes)
|
252 | - [getAccountStates](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-account-states)
|
253 | - [getCredits](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-credits)
|
254 | - [getExternalIDs](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-external-ids)
|
255 | - [getImages](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-images)
|
256 | - [getTranslations](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-translations)
|
257 | - [rateTVEpisode](https://developers.themoviedb.org/3/tv-episodes/rate-tv-episode)
|
258 | - [deleteRating](https://developers.themoviedb.org/3/tv-episodes/delete-tv-episode-rating)
|
259 | - [getVideos](https://developers.themoviedb.org/3/tv-episodes/get-tv-episode-videos)
|
260 | - group
|
261 | - [getDetails](https://developers.themoviedb.org/3/tv-episode-groups/get-tv-episode-group-details)
|
262 |
|
263 | # Errors
|
264 |
|
265 | > All errors extends [Node's Error](https://nodejs.org/dist/latest-v12.x/docs/api/errors.html#errors_class_error)
|
266 |
|
267 | ## BadRequest
|
268 |
|
269 | Throws when server responses with http status code 400
|
270 |
|
271 | - code - Number. Usually to `0`
|
272 | - errorCode - Number. Equals to `400`
|
273 |
|
274 | ## UnauthorizedError
|
275 |
|
276 | Throws when set invalid api key
|
277 |
|
278 | - code - Number. Usually equals to `7`
|
279 | - errorCode - Number. Equals to `401`
|
280 |
|
281 | ## NotFoundError
|
282 |
|
283 | Throws when requested resource couldn't be found
|
284 |
|
285 | - code - Number. Usually equals to `34`
|
286 | - errorCode - Number. Equals to `404`
|
287 |
|
288 | ## RequestTimeout
|
289 |
|
290 | Throws when request timed out
|
291 |
|
292 | - code - Number. Usually equals to `0`
|
293 | - errorCode - Number. Equals to `408`
|
294 |
|
295 | ## TooManyRequests (deprecated)
|
296 |
|
297 | Throws when expired rate limit
|
298 |
|
299 | - code - Number. Usually equals to `0`
|
300 | - errorCode - Number. Equals to `429`
|