{"id":15254646,"url":"https://github.com/idavide94/trakt.tv-userscript","last_synced_at":"2025-10-05T22:30:47.601Z","repository":{"id":186562510,"uuid":"672811053","full_name":"iDavide94/trakt.tv-userscript","owner":"iDavide94","description":"A Trakt.tv API wrapper for userscripts","archived":false,"fork":true,"pushed_at":"2024-09-26T17:15:41.000Z","size":340,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-09-29T23:05:17.054Z","etag":null,"topics":["trakt","trakt-api","userscript","userscripts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"vankasteelj/trakt.tv","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iDavide94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-31T08:11:33.000Z","updated_at":"2023-10-25T23:52:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/iDavide94/trakt.tv-userscript","commit_stats":null,"previous_names":["idavide94/trakt.tv","idavide94/trakt.tv-userscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDavide94%2Ftrakt.tv-userscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDavide94%2Ftrakt.tv-userscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDavide94%2Ftrakt.tv-userscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iDavide94%2Ftrakt.tv-userscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iDavide94","download_url":"https://codeload.github.com/iDavide94/trakt.tv-userscript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219877062,"owners_count":16554821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["trakt","trakt-api","userscript","userscripts"],"created_at":"2024-09-29T23:05:24.087Z","updated_at":"2025-10-05T22:30:47.590Z","avatar_url":"https://github.com/iDavide94.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@idavide94/trakt.tv-userscript`\n\n\u003e _forked from [trakt.tv](https://github.com/vankasteelj/trakt.tv)_\n\n\u003e [!CAUTION]\n\u003e This repository is no longer maintained.\n\n**Trakt.tv API wrapper for userscripts, featuring:**\n\n- [All Trakt.tv API v2 methods](docs/available_methods.md)\n- [Plugin extension](docs/plugins.md)[^wip]\n\n_For more information about the trakt.tv API, read http://docs.trakt.apiary.io/_\n\n## Example usage\n\n#### Setup\n\nAdd to a userscript via [`@require`](https://wiki.greasespot.net/Metadata_Block#@require):\n\n```javascript\n// @require   https://cdn.jsdelivr.net/npm/@idavide94/trakt.tv-userscript/dist/index.min.js\n// @grant     GM.xmlHttpRequest\n```\n\n\u003e attention: _for the proper working of the library the use of [`GM.xmlHttpRequest`](https://wiki.greasespot.net/GM.xmlHttpRequest) via [`@grant`](https://wiki.greasespot.net/@grant) is required!_\n\n#### Initialize\n\n```javascript\nconst options = {\n  client_id: '\u003cthe_client_id\u003e',\n  client_secret: '\u003cthe_client_secret\u003e',\n  redirect_uri: null, // defaults to 'urn:ietf:wg:oauth:2.0:oob'\n  api_url: null, // defaults to 'https://api.trakt.tv'\n  useragent: null, // defaults to 'trakt.tv/\u003cversion\u003e'\n  pagination: true // defaults to false, global pagination (see below)\n}\nconst trakt = new Trakt(options)\n```\n\n\u003e note: _add `debug: true` to the `options` object to get debug logs of the requests executed in your console_\n\n#### OAUTH\n\n1. Generate Auth URL\n\n```javascript\nconst traktAuthUrl = trakt.get_url()\n```\n\n2. Authentication is done at that URL, it redirects to the provided uri with a code and a state\n\n3. Verify code (and optionally state for better security) from returned auth, and get a token in exchange\n\n```javascript\ntrakt.exchange_code('code', 'csrf token (state)').then((result) =\u003e {\n  // contains tokens \u0026 session information\n  // API can now be used with authorized requests\n})\n```\n\n#### Alternate OAUTH \"device\" method\n\n```javascript\ntrakt\n  .get_codes()\n  .then((poll) =\u003e {\n    // poll.verification_url: url to visit in a browser\n    // poll.user_code: the code the user needs to enter on trakt\n\n    // verify if app was authorized\n    return trakt.poll_access(poll)\n  })\n  .catch((error) =\u003e {\n    // error.message == 'Expired' will be thrown if timeout is reached\n  })\n```\n\n#### Refresh token\n\n```javascript\ntrakt.refresh_token().then((results) =\u003e {\n  // results are auto-injected in the main module cache\n})\n```\n\n#### Storing token over sessions\n\n```javascript\n// get token, store it safely.\nconst token = trakt.export_token()\n\n// injects back stored token on new session.\ntrakt.import_token(token).then((newTokens) =\u003e {\n  // Contains token, refreshed if needed (store it back)\n})\n```\n\n#### Revoke token\n\n```javascript\ntrakt.revoke_token()\n```\n\n#### Actual API requests\n\nSee methods in [methods.json](methods.json) or [the docs](docs/available_methods.md).\n\n```javascript\ntrakt.calendars.all\n  .shows({\n    start_date: '2015-11-13',\n    days: '7',\n    extended: 'full'\n  })\n  .then((shows) =\u003e {\n    // Contains Object{} response from API (show data)\n  })\n```\n\n```javascript\ntrakt.search\n  .text({\n    query: 'tron',\n    type: 'movie,person'\n  })\n  .then((response) =\u003e {\n    // Contains Array[] response from API (search data)\n  })\n```\n\n```javascript\ntrakt.search\n  .id({\n    id_type: 'imdb',\n    id: 'tt0084827'\n  })\n  .then((response) =\u003e {\n    // Contains Array[] response from API (imdb data)\n  })\n```\n\n#### Using pagination\n\nYou can extend your calls with `pagination: true` to get the extra pagination info from headers.\n\n```javascript\ntrakt.movies\n  .popular({\n    pagination: true\n  })\n  .then((movies) =\u003e {\n    /**\n    movies = Object {\n      data: [\u003cactual data from API\u003e],\n        pagination: {\n          item-count: \"80349\",\n            limit: \"10\",\n            page: \"1\",\n            page-count: \"8035\"\n        }\n    }\n    **/\n  })\n```\n\n\u003e note: _this will contain `data` and `pagination` for all calls, even if no pagination is available (`result.pagination` will be `false`). it's typically for advanced use only_\n\n#### Load plugins[^wip]\n\nWhen calling `new Trakt()`, include desired plugins in an object (must be installed from npm):\n\n```javascript\nconst trakt = new Trakt({\n  client_id: '\u003cthe_client_id\u003e',\n    client_secret: '\u003cthe_client_secret\u003e',\n    plugins: {  // load plugins\n        images: require('trakt.tv-images')\n    }\n    options: {  // pass options to plugins\n        images: {\n          smallerImages: true\n        }\n    }\n});\n```\n\nThe plugin can be accessed with the key you specify. For example `trakt.images.get()`.\n\n#### Write plugins[^wip]\n\nSee the [documentation](docs/writing_plugins.md).\n\n#### Notes\n\n- You can use 'me' as username if the user is authenticated.\n- Timestamps (such as token _expires_ property) are Epoch in milliseconds.\n\n[^wip]: plugins, and related docs, are currently a work in progress for this fork\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidavide94%2Ftrakt.tv-userscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidavide94%2Ftrakt.tv-userscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidavide94%2Ftrakt.tv-userscript/lists"}