File size: 11,593 Bytes
95f4e64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# 🌿 yts.mx API wrapper for NodeJS

A promised based node module to interact with the yts.mx/api/v2

NOTE: The YTS API is not always working as intended. I have notified YTS about some issues, to this date I did not get any reply and the issues are not fixed.

One of the issues is that the `order_by` and `sort_by` params are not working with `seeds` and `peers`. The other *sort* options seem to be working fine.

Another problem is that some routes are not working at all, like the *movie comments* and *list upcomming* are not working and result into a `404 not found`. I have added the `@deprecated` flag to it, so you will be warned by your *IDE* when using these methods.

## πŸͺ„ Installation

```typescript
npm install yts-api-node
```

## πŸ”Œ API usage

### πŸ“ Search

###### Usage

```typescript
import { search } from 'yts-api-node';

// Search for movies with title 'The hobbit' and limit results by 50
search({ query_term: 'The hobbit', limit: 50 }).then(results => /** ... */)
```

###### Parameters
| Parameter        | Required | Type                                                                               | Default    | Description                                                          |
| ---------------- | -------- | ---------------------------------------------------------------------------------- | ---------- | -------------------------------------------------------------------- |
| `limit`          | ❌        | 1 - 50                                                                             | 20         | Limit result per page                                                |
| `page`           | ❌        |                                                                                    | 1          | Used for paging                                                      |
| `quality`        | ❌        | `720p` `1080p` `2160p` `3D` `all`                                                  | All        | Filter by quality                                                    |
| `minimum_rating` | ❌        | 0 - 9                                                                              | 0          | Filter by minimum IMDb rating                                        |
| `query_term`     | ❌        | string                                                                             | ''         | Movie Title/IMDb Code, Actor Name/IMDb Code, Director Name/IMDb Code |
| `genre`          | ❌        | string                                                                             | All        | Filter by genre                                                      |
| `sort_by`        | ❌        | `title` `year` `rating` `peers` `seeds` `download_count` `like_count` `date_added` | date_added | Sort result                                                          |
| `order_by`       | ❌        | `asc` `desc`                                                                       | desc       | Ascending or Descending order                                        |

###### Response
```typescript
"status": string;
"status_message": string;
"data": {
    "movie_count": number;
    "limit":number;
    "page_number": number;
    "movies": [
        {
            "id": number;
            "url": string;
            "imdb_code": string;
            "title": string;
            "title_english": string;
            "title_long": string;
            "slug": string;
            "year": number;
            "rating": number;
            "runtime": number;
            "genres": string[];
            "summary": string;
            "description_full": string;
            "synopsis": string;
            "yt_trailer_code": string;
            "language": string;
            "mpa_rating": string;
            "background_image": string;
            "background_image_original": string;
            "small_cover_image": string;
            "medium_cover_image": string;
            "large_cover_image": string;
            "state": string;,
            "torrents": [
                {
                    "url": string;
                    "hash": string;
                    "quality": string;
                    "type": string;
                    "seeds": number;
                    "peers": number;
                    "size": string;
                    "size_bytes": number;
                    "date_uploaded": string;
                    "date_uploaded_unix": number;
                },
                //...
            ]
        },
        //...
    ]
"@meta": {
    "server_time": number;
    "server_timezone": string;
    "api_version": number;
    "execution_time": string;
}

```

### πŸ“ Details

###### Usage

```typescript
import { details } from 'yts-api-node';

// Can be a YTS movie ID or an IMDb ID
// This example uses an IMDb ID
details({ movie_id: 'tt2267998' }).then(results => /** ... */)
```

###### Parameters
| Parameter     | Required | Type              | Default | Description               |
| ------------- | -------- | ----------------- | ------- | ------------------------- |
| `movie_id`    | βœ…        | `number` `string` |         | YTS movie ID or IMDb ID   |
| `with_images` | ❌        | boolean           | false   | Include images in result? |
| `with_cast`   | ❌        | boolean           | false   | Include cast in result?   |

###### Response
```javascript
{
    "status": string;
    "status_message": string;
    "data": {
        "movie": {
            "id": number;
            "url": string;
            "imdb_code": string;
            "title": string;
            "title_english": string;
            "title_long": string;
            "slug": string;
            "year": number;
            "rating": number;
            "runtime": number;
            "genres": string[];
            "download_count": number;
            "like_count": number;
            "description_intro": string;
            "description_full": string;
            "yt_trailer_code": string;
            "language": string;
            "mpa_rating": string;
            "background_image": string;
            "background_image_original": string;
            "small_cover_image": string;
            "medium_cover_image": string;
            "large_cover_image": string;
            "torrents": [
                {
                    "url": string;
                    "hash": string;
                    "quality": string;
                    "type": string;
                    "seeds": number;
                    "peers": number;
                    "size": string;
                    "size_bytes": number;
                    "date_uploaded": string;
                    "date_uploaded_unix": number;
                },
                // ...
            ]
            "date_uploaded": string;
            "date_uploaded_unix": number;
        }
    },
    "@meta": {
        "server_time": number;
        "server_timezone": string;
        "api_version": number;
        "execution_time": string;
    }
}
```

### πŸ“ Suggestions

###### Usage

```typescript
import { suggestions } from 'yts-api-node';

// Movie ID must be an YTS movie ID, IMDb ID's are not working
suggestions({ movie_id: 10 }).then(results => /** ... */)
```

###### Parameters
| Parameter  | Required | Type              | Default | Description  |
| ---------- | -------- | ----------------- | ------- | ------------ |
| `movie_id` | βœ…        | `number` `string` |         | YTS movie ID |

###### Response

```typescript
{
    "status": string;
    "status_message": string;
    "data": {
        "movie_count": number;
        "movies": [
            "id": number;
            "url": string;
            "imdb_code": string;
            "title": string;
            "title_english": string;
            "title_long": string;
            "slug": string;
            "year": number;
            "rating": number;
            "runtime": number;
            "genres": string[];
            "summary": string;
            "description_full": string;
            "synopsis": string;
            "yt_trailer_code": string;
            "language": string;
            "mpa_rating": string;
            "background_image": string;
            "background_image_original": string;
            "small_cover_image": string;
            "medium_cover_image": string;
            "state": "ok",
            "torrents": [
                {
                    "url": string;
                    "hash": string;
                    "quality": string;
                    "seeds": number;
                    "peers": number;
                    "size": string;
                    "size_bytes": number;
                    "date_uploaded": string;
                    "date_uploaded_unix": number;
                },
                // ...
            ],
            "date_uploaded": string;
            "date_uploaded_unix": number;
        ]
    },
    "@meta": {
        "server_time": number;
        "server_timezone": string;
        "api_version": number;
        "execution_time": string;
    }
}
```

### πŸ“ Comments (not working)
Route does not exist on [yts.mx/api/v2/](https://yts.mx/api/v2/movie_comments.json).

https://yts.mx/api#movie_comments

###### Usage

```typescript
import { comments } from 'yts-api-node';

// Movie ID must be an YTS movie ID, IMDb ID's are not working
comments({ movie_id: 10 }).then(results => /** ... */)
```

###### Parameters
| Parameter  | Required | Type              | Default | Description  |
| ---------- | -------- | ----------------- | ------- | ------------ |
| `movie_id` | βœ…        | `number` `string` |         | YTS movie ID |

### πŸ“ Reviews (not working)
Route does not exist on [yts.mx/api/v2/](https://yts.mx/api/v2/movie_reviews.json). 

https://yts.mx/api#movie_reviews

###### Usage

```typescript
import { reviews } from 'yts-api-node';

// Movie ID must be an YTS movie ID, IMDb ID's are not working
reviews({ movie_id: 10 }).then(results => /** ... */)
```

###### Parameters
| Parameter  | Required | Type              | Default | Description  |
| ---------- | -------- | ----------------- | ------- | ------------ |
| `movie_id` | βœ…        | `number` `string` |         | YTS movie ID |

### πŸ“ Parentals

This is apparently not implemented yet in the YTS API, returned results show

```javascript
"parental_guide_text": "Parental Guide for all the movies will be republished soon. Thank you for understanding!"
```

###### Usage

```typescript
import { parentals } from 'yts-api-node';

// Movie ID must be an YTS movie ID, IMDb ID's are not working
parentals({ movie_id: 10 }).then(results => /** ... */)
```

###### Parameters
| Parameter  | Required | Type              | Default | Description  |
| ---------- | -------- | ----------------- | ------- | ------------ |
| `movie_id` | βœ…        | `number` `string` |         | YTS movie ID |

```typescript
{
    "status": string;
    "status_message": string;
    "data": {
        "parental_guide_count": number;
        "parental_guides": [
            {
                "type": string;
                "parental_guide_text":string;
            }
        ]
    },
    "@meta": {
        "server_time": number;
        "server_timezone": string;
        "api_version": number;
        "execution_time": string;
    }
}
```

### πŸ“ Upcomming (not working)
Route does not exist on [yts.mx/api/v2/](https://yts.mx/api/v2/list_upcoming.json). 

https://yts.mx/api#list_upcoming

```typescript
import { upcomming } from 'yts-api-node';

upcomming().then(results => /** ... */)
```