|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Trakt.tv | Trakt API Wrapper |
3 | 3 | // @description Exposes an authenticated Trakt API Wrapper. Intended to run alongside other userscripts which require (authenticated) access to the Trakt API. |
4 | | -// @version 1.0.1 |
| 4 | +// @version 1.0.2 |
5 | 5 | // @namespace f785bub0 |
6 | 6 | // @updateURL https://update.greasyfork.org/scripts/564750.meta.js |
7 | 7 | // @icon https://trakt.tv/assets/logos/logomark.square.gradient-b644b16c38ff775861b4b1f58c1230f6a097a2466ab33ae00445a505c33fcb91.svg |
|
32 | 32 |
|
33 | 33 | ### Usage |
34 | 34 | - The wrapper is exposed through `window.userscriptTraktApiWrapper` and can be used like:<br> |
35 | | - `const data = await userscriptTraktApiWrapper.search.id({ id_type: 'trakt', id: 1234, type: 'episode', extended: 'full', _auth: true, _meta: true, _revalidate: true });`<br> |
| 35 | + `const { data, meta } = await userscriptTraktApiWrapper.search.id({ id_type: 'trakt', id: 1234, type: 'episode', extended: 'full', _auth: true, _meta: true, _revalidate: true });`<br> |
36 | 36 | There are two types of props you can pass to a method, parameters corresponding to those listed in the Trakt API docs and options (denoted by a leading `_`) for the wrapper itself. |
37 | 37 | - ***Parameters***<br> |
38 | 38 | There are three categories: path parameters, search parameters, and the props for the request's body. First the mandatory and optional parameters for the path |
|
51 | 51 | `limit` gets decremented (= 5 retries) and `req_delay` doubled. If you want to turn it off you can just override it with `_retry: null`. |
52 | 52 | - In the userscript storage tab you can change the `apiUrl` to `https://api-staging.trakt.tv` for a sandbox environment |
53 | 53 | and you can activate console logging of all api requests with `logApiRequests`. |
54 | | -- There's built-in rate-limiting for authed `POST`/`PUT`/`DELETE` requests (1/sec), which is complemented by the default `_retry` config, so you can just make a bunch of these |
55 | | - requests at once and they'll be queued up and executed one by one in the same order in which you made them. This is complemented by the default `_retry` config where in this case |
56 | | - a retried request delays all other queued requests. |
| 54 | +- There's built-in rate-limiting for authed `POST`/`PUT`/`DELETE` requests (1/sec), which is complemented by the default `_retry` config, so you can just make a bunch of |
| 55 | + requests at once and they'll be queued up and executed one by one in the same order in which you made them (retries will block the queue). |
57 | 56 | */ |
58 | 57 |
|
59 | 58 |
|
|
0 commit comments