@lorenzopant/tmdb 1.21.0 → 1.21.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/llms-full.txt +316 -0
- package/llms.txt +63 -0
- package/package.json +4 -2
package/llms-full.txt
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# @lorenzopant/tmdb
|
|
2
|
+
|
|
3
|
+
`@lorenzopant/tmdb` is a fully typed TypeScript SDK for The Movie Database (TMDB) API. It wraps TMDB v3 endpoints in a single `TMDB` client and exposes TMDB v4 auth/account/list APIs through `tmdb.v4` when the client is created with a JWT bearer token.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lorenzopant/tmdb
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Primary entrypoints
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { TMDB, TMDBError } from "@lorenzopant/tmdb";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Main public exports include:
|
|
18
|
+
- `TMDB`
|
|
19
|
+
- `TMDBv4`
|
|
20
|
+
- `TMDBError`
|
|
21
|
+
- Standalone endpoint classes such as `MoviesAPI`, `SearchAPI`, `GenresAPI`, `PeopleAPI`, `ListsAPI`, `AuthenticationAPI`, `V4AuthAPI`, `V4AccountAPI`, and `V4ListsAPI`
|
|
22
|
+
- Package types via the root entrypoint and `@lorenzopant/tmdb/types`
|
|
23
|
+
- Utility exports from `@lorenzopant/tmdb`, including pagination helpers and retry types
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { TMDB } from "@lorenzopant/tmdb";
|
|
29
|
+
|
|
30
|
+
const tmdb = new TMDB(process.env.TMDB_ACCESS_TOKEN!, {
|
|
31
|
+
language: "en-US",
|
|
32
|
+
region: "US",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const movie = await tmdb.movies.details({ movie_id: 550 });
|
|
36
|
+
console.log(movie.title);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Constructor
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const tmdb = new TMDB(accessToken, options?);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`accessToken` is required. Supported options include:
|
|
46
|
+
- `language`: default ISO 639-1 language for requests
|
|
47
|
+
- `region`: default ISO 3166-1 region
|
|
48
|
+
- `timezone`: default timezone for supported TV queries
|
|
49
|
+
- `images`: image URL behavior and image-language prioritization
|
|
50
|
+
- `logger`: `true` for built-in logging or a custom logger function
|
|
51
|
+
- `deduplication`: defaults to `true`
|
|
52
|
+
- `interceptors`: request and response hooks
|
|
53
|
+
- `rate_limit`: `true` or `{ max_requests, per_ms }`
|
|
54
|
+
- `retry`: `true` or a `RetryOptions` object
|
|
55
|
+
- `cache`: `true` or a cache options object
|
|
56
|
+
|
|
57
|
+
Important defaults and constraints:
|
|
58
|
+
- `deduplication` is on by default
|
|
59
|
+
- `cache`, `retry`, and `rate_limit` are off by default
|
|
60
|
+
- `tmdb.v4` requires a JWT bearer token and throws if the client was created with a non-JWT token
|
|
61
|
+
- `tmdb.cache` is only available when caching is enabled
|
|
62
|
+
|
|
63
|
+
## Namespaces
|
|
64
|
+
|
|
65
|
+
The `TMDB` instance exposes modular namespaces that map closely to TMDB APIs:
|
|
66
|
+
- `movies`
|
|
67
|
+
- `movie_lists`
|
|
68
|
+
- `tv_series`
|
|
69
|
+
- `tv_lists`
|
|
70
|
+
- `tv_seasons`
|
|
71
|
+
- `tv_episodes`
|
|
72
|
+
- `tv_episode_groups`
|
|
73
|
+
- `search`
|
|
74
|
+
- `discover`
|
|
75
|
+
- `trending`
|
|
76
|
+
- `people`
|
|
77
|
+
- `people_lists`
|
|
78
|
+
- `collections`
|
|
79
|
+
- `companies`
|
|
80
|
+
- `networks`
|
|
81
|
+
- `genres`
|
|
82
|
+
- `keywords`
|
|
83
|
+
- `reviews`
|
|
84
|
+
- `credits`
|
|
85
|
+
- `configuration`
|
|
86
|
+
- `changes`
|
|
87
|
+
- `find`
|
|
88
|
+
- `watch_providers`
|
|
89
|
+
- `authentication`
|
|
90
|
+
- `account`
|
|
91
|
+
- `guest_sessions`
|
|
92
|
+
- `lists`
|
|
93
|
+
- `images`
|
|
94
|
+
- `v4`
|
|
95
|
+
|
|
96
|
+
The `tmdb.v4` namespace exposes:
|
|
97
|
+
- `tmdb.v4.auth`
|
|
98
|
+
- `tmdb.v4.account`
|
|
99
|
+
- `tmdb.v4.lists`
|
|
100
|
+
|
|
101
|
+
## Common usage patterns
|
|
102
|
+
|
|
103
|
+
### Fetch a movie
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const movie = await tmdb.movies.details({ movie_id: 550 });
|
|
107
|
+
console.log(movie.title);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Search
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const results = await tmdb.search.movies({
|
|
114
|
+
query: "Inception",
|
|
115
|
+
page: 1,
|
|
116
|
+
language: "en-US",
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Discover
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const response = await tmdb.discover.movies({
|
|
124
|
+
with_genres: "28",
|
|
125
|
+
sort_by: "vote_average.desc",
|
|
126
|
+
"vote_count.gte": 1000,
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### TV series and seasons
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
const show = await tmdb.tv_series.details({ series_id: 1396 });
|
|
134
|
+
const season = await tmdb.tv_seasons.details({
|
|
135
|
+
series_id: 1396,
|
|
136
|
+
season_number: 1,
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Append related resources
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const movie = await tmdb.movies.details({
|
|
144
|
+
movie_id: 550,
|
|
145
|
+
append_to_response: ["credits", "videos"],
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
console.log(movie.credits.cast[0]?.name);
|
|
149
|
+
console.log(movie.videos.results[0]?.key);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Build image URLs
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const movie = await tmdb.movies.details({ movie_id: 550 });
|
|
156
|
+
|
|
157
|
+
const posterUrl = tmdb.images.poster(movie.poster_path!, "w500");
|
|
158
|
+
const backdropUrl = tmdb.images.backdrop(movie.backdrop_path!, "w1280");
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Auto-enrich image paths in API responses
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const tmdb = new TMDB(token, {
|
|
165
|
+
images: {
|
|
166
|
+
autocomplete_paths: true,
|
|
167
|
+
default_image_sizes: { posters: "original" },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Paginate through any paginated endpoint
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { paginate, fetchAllPages, getPageInfo } from "@lorenzopant/tmdb";
|
|
176
|
+
|
|
177
|
+
for await (const page of paginate((p) => tmdb.search.movies({ query: "batman", page: p }))) {
|
|
178
|
+
console.log(getPageInfo(page));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const movies = await fetchAllPages((p) => tmdb.movie_lists.now_playing({ page: p }), {
|
|
182
|
+
maxPages: 3,
|
|
183
|
+
deduplicateBy: (movie) => movie.id,
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Retry transient failures
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const tmdb = new TMDB(token, { retry: true });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Custom retry:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { TMDB, TMDBError } from "@lorenzopant/tmdb";
|
|
197
|
+
|
|
198
|
+
const tmdb = new TMDB(token, {
|
|
199
|
+
retry: {
|
|
200
|
+
max_retries: 5,
|
|
201
|
+
base_delay_ms: 200,
|
|
202
|
+
shouldRetry: (error, attempt) => {
|
|
203
|
+
if (error instanceof TMDBError) return error.http_status_code >= 500 || error.http_status_code === 429;
|
|
204
|
+
return attempt <= 2;
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Enable in-memory caching
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const tmdb = new TMDB(token, {
|
|
214
|
+
cache: {
|
|
215
|
+
ttl: 60_000,
|
|
216
|
+
max_size: 500,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
tmdb.cache?.invalidate("/movie/now_playing");
|
|
221
|
+
tmdb.cache?.clear();
|
|
222
|
+
console.log(tmdb.cache?.size);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Enable rate limiting
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
const tmdb = new TMDB(token, {
|
|
229
|
+
rate_limit: { max_requests: 20, per_ms: 1_000 },
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Add interceptors
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const tmdb = new TMDB(token, {
|
|
237
|
+
interceptors: {
|
|
238
|
+
request: (ctx) => ({
|
|
239
|
+
...ctx,
|
|
240
|
+
params: { ...ctx.params, include_adult: false },
|
|
241
|
+
}),
|
|
242
|
+
response: {
|
|
243
|
+
onError: (error) => {
|
|
244
|
+
console.error(error.message);
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Handle errors
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import { TMDB, TMDBError } from "@lorenzopant/tmdb";
|
|
255
|
+
|
|
256
|
+
try {
|
|
257
|
+
await tmdb.movies.details({ movie_id: 0 });
|
|
258
|
+
} catch (error) {
|
|
259
|
+
if (error instanceof TMDBError) {
|
|
260
|
+
console.error(error.message);
|
|
261
|
+
console.error(error.http_status_code);
|
|
262
|
+
console.error(error.tmdb_status_code);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## v4 usage
|
|
268
|
+
|
|
269
|
+
Use `tmdb.v4` only when the `TMDB` instance was created with a JWT bearer token.
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
const { request_token } = await tmdb.v4.auth.create_request_token({
|
|
273
|
+
redirect_to: "https://yourapp.com/callback",
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const { access_token, account_id } = await tmdb.v4.auth.create_access_token({
|
|
277
|
+
request_token,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const profile = await tmdb.v4.account.details(account_id);
|
|
281
|
+
|
|
282
|
+
const list = await tmdb.v4.lists.create({
|
|
283
|
+
name: "My list",
|
|
284
|
+
iso_639_1: "en",
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Package behavior summary
|
|
289
|
+
|
|
290
|
+
- Strong typing is a primary goal; endpoint params and responses are exported as TypeScript types
|
|
291
|
+
- The client groups endpoints by domain instead of exposing a generic low-level fetch wrapper
|
|
292
|
+
- Standalone endpoint classes are also exported if you do not want the full `TMDB` aggregator
|
|
293
|
+
- Image URL helpers are available even when you do not call an API endpoint
|
|
294
|
+
- Pagination helpers are exported separately and can wrap any paginated method
|
|
295
|
+
- Cache only applies to `GET` requests
|
|
296
|
+
- Response interceptors cannot suppress thrown `TMDBError` values
|
|
297
|
+
|
|
298
|
+
## Best practices for AI agents and code generators
|
|
299
|
+
|
|
300
|
+
- Prefer `new TMDB(token, options)` unless there is a strong reason to instantiate standalone endpoint classes
|
|
301
|
+
- Use `tmdb.v4` only when you know the token is a JWT bearer token
|
|
302
|
+
- When showing examples, prefer real namespace names from the package such as `movie_lists`, `tv_series`, `tv_lists`, and `watch_providers`
|
|
303
|
+
- For bulk reads, consider `rate_limit`, `retry`, `cache`, and pagination helpers together
|
|
304
|
+
- For image URLs, use `tmdb.images.poster(...)`, `backdrop(...)`, `profile(...)`, `logo(...)`, or `still(...)`
|
|
305
|
+
- For localized data, set `language`, `region`, and `timezone` at the client level when appropriate
|
|
306
|
+
|
|
307
|
+
## Documentation links
|
|
308
|
+
|
|
309
|
+
- Docs home: https://lorenzopant-tmdb-docs.vercel.app/docs
|
|
310
|
+
- Getting started: https://lorenzopant-tmdb-docs.vercel.app/docs/getting-started
|
|
311
|
+
- Authentication guide: https://lorenzopant-tmdb-docs.vercel.app/docs/getting-started/authentication
|
|
312
|
+
- Pagination guide: https://lorenzopant-tmdb-docs.vercel.app/docs/getting-started/pagination
|
|
313
|
+
- Options reference: https://lorenzopant-tmdb-docs.vercel.app/docs/getting-started/options
|
|
314
|
+
- API reference index: https://lorenzopant-tmdb-docs.vercel.app/docs/api-reference
|
|
315
|
+
- Types index: https://lorenzopant-tmdb-docs.vercel.app/docs/types
|
|
316
|
+
- Changelog: https://lorenzopant-tmdb-docs.vercel.app/docs/changelog
|
package/llms.txt
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @lorenzopant/tmdb
|
|
2
|
+
|
|
3
|
+
`@lorenzopant/tmdb` is a TypeScript-first SDK for The Movie Database (TMDB) API.
|
|
4
|
+
|
|
5
|
+
Use this package when you need:
|
|
6
|
+
- Fully typed TMDB API access from TypeScript
|
|
7
|
+
- A single `TMDB` client with modular namespaces like `movies`, `tv_series`, `search`, and `discover`
|
|
8
|
+
- Built-in helpers for images, pagination, caching, retry, rate limiting, and interceptors
|
|
9
|
+
- Access to TMDB v4 auth/account/list APIs through `tmdb.v4` when using a JWT bearer token
|
|
10
|
+
|
|
11
|
+
Install:
|
|
12
|
+
```bash
|
|
13
|
+
npm install @lorenzopant/tmdb
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Basic usage:
|
|
17
|
+
```ts
|
|
18
|
+
import { TMDB } from "@lorenzopant/tmdb";
|
|
19
|
+
|
|
20
|
+
const tmdb = new TMDB(process.env.TMDB_ACCESS_TOKEN!, {
|
|
21
|
+
language: "en-US",
|
|
22
|
+
region: "US",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const movie = await tmdb.movies.details({ movie_id: 550 });
|
|
26
|
+
console.log(movie.title);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Main exports:
|
|
30
|
+
- `TMDB`
|
|
31
|
+
- `TMDBv4`
|
|
32
|
+
- `TMDBError`
|
|
33
|
+
- Standalone endpoint classes like `MoviesAPI`, `SearchAPI`, `PeopleAPI`, `ListsAPI`, and `V4ListsAPI`
|
|
34
|
+
- Utility exports including pagination helpers and `RetryOptions`
|
|
35
|
+
- All public request/response types via `@lorenzopant/tmdb` and `@lorenzopant/tmdb/types`
|
|
36
|
+
|
|
37
|
+
Core namespaces on `TMDB`:
|
|
38
|
+
- `movies`, `movie_lists`
|
|
39
|
+
- `tv_series`, `tv_lists`, `tv_seasons`, `tv_episodes`, `tv_episode_groups`
|
|
40
|
+
- `search`, `discover`, `trending`
|
|
41
|
+
- `people`, `people_lists`
|
|
42
|
+
- `collections`, `companies`, `networks`
|
|
43
|
+
- `genres`, `keywords`, `reviews`, `credits`
|
|
44
|
+
- `configuration`, `changes`, `find`, `watch_providers`
|
|
45
|
+
- `authentication`, `account`, `guest_sessions`, `lists`
|
|
46
|
+
- `images`
|
|
47
|
+
- `v4`
|
|
48
|
+
|
|
49
|
+
Important behavior:
|
|
50
|
+
- Constructor signature: `new TMDB(accessToken, options?)`
|
|
51
|
+
- `tmdb.v4` requires a JWT bearer token; it throws if the client was created with an API key
|
|
52
|
+
- `cache`, `rate_limit`, and `retry` are opt-in
|
|
53
|
+
- `deduplication` is enabled by default
|
|
54
|
+
- `tmdb.cache` is available only when caching is enabled
|
|
55
|
+
|
|
56
|
+
Useful docs:
|
|
57
|
+
- Docs home: https://lorenzopant-tmdb-docs.vercel.app/docs
|
|
58
|
+
- Getting started: https://lorenzopant-tmdb-docs.vercel.app/docs/getting-started
|
|
59
|
+
- API reference: https://lorenzopant-tmdb-docs.vercel.app/docs/api-reference
|
|
60
|
+
- Types: https://lorenzopant-tmdb-docs.vercel.app/docs/types
|
|
61
|
+
- Changelog: https://lorenzopant-tmdb-docs.vercel.app/docs/changelog
|
|
62
|
+
|
|
63
|
+
For fuller package guidance, examples, and AI-oriented reference, see `llms-full.txt`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lorenzopant/tmdb",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "A completely type-safe The Movie Database (TMDB) API wrapper for typescript applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"README.md"
|
|
23
|
+
"README.md",
|
|
24
|
+
"llms.txt",
|
|
25
|
+
"llms-full.txt"
|
|
24
26
|
],
|
|
25
27
|
"type": "module",
|
|
26
28
|
"main": "dist/index.mjs",
|