{"id":17454755,"url":"https://github.com/ionicabizau/youtube-api","last_synced_at":"2025-05-15T00:09:04.184Z","repository":{"id":10252966,"uuid":"12360909","full_name":"IonicaBizau/youtube-api","owner":"IonicaBizau","description":":video_camera: A Node.JS module, which provides an object oriented wrapper for the YouTube v3 API.","archived":false,"fork":false,"pushed_at":"2025-02-14T02:09:02.000Z","size":132,"stargazers_count":358,"open_issues_count":8,"forks_count":60,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-03T03:29:06.324Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IonicaBizau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ionicabizau","patreon":"ionicabizau","open_collective":"ionicabizau","custom":"https://www.buymeacoffee.com/h96wwchmy"}},"created_at":"2013-08-25T15:21:11.000Z","updated_at":"2025-03-29T12:15:13.000Z","dependencies_parsed_at":"2025-03-05T16:10:21.519Z","dependency_job_id":null,"html_url":"https://github.com/IonicaBizau/youtube-api","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IonicaBizau%2Fyoutube-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IonicaBizau%2Fyoutube-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IonicaBizau%2Fyoutube-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IonicaBizau%2Fyoutube-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IonicaBizau","download_url":"https://codeload.github.com/IonicaBizau/youtube-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166859,"owners_count":21058481,"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":["hacktoberfest"],"created_at":"2024-10-18T01:41:28.213Z","updated_at":"2025-04-10T06:14:59.460Z","avatar_url":"https://github.com/IonicaBizau.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ionicabizau","https://patreon.com/ionicabizau","https://opencollective.com/ionicabizau","https://www.buymeacoffee.com/h96wwchmy","https://www.buymeacoffee.com/H96WwChMy","https://www.patreon.com/ionicabizau","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RVXDDLKKLQRJW"],"categories":[],"sub_categories":[],"readme":"\u003c!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. --\u003e\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# youtube-api\n\n [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Downloads](https://img.shields.io/npm/dt/youtube-api.svg)](https://www.npmjs.com/package/youtube-api) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/@johnnyb?utm_source=github\u0026utm_medium=button\u0026utm_term=johnnyb\u0026utm_campaign=github)\n\n\u003ca href=\"https://www.buymeacoffee.com/H96WwChMy\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png\" alt=\"Buy Me A Coffee\"\u003e\u003c/a\u003e\n\n\n\n\n\n\n\n\u003e A Node.JS module, which provides an object oriented wrapper for the Youtube v3 API.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## :cloud: Installation\n\n```sh\n# Using npm\nnpm install --save youtube-api\n\n# Using yarn\nyarn add youtube-api\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n## :clipboard: Example\n\n\n\n```js\n/**\n * This script uploads a video (specifically `video.mp4` from the current\n * directory) to YouTube,\n *\n * To run this script you have to create OAuth2 credentials and download them\n * as JSON and replace the `credentials.json` file. Then install the\n * dependencies:\n *\n * npm i r-json lien opn bug-killer\n *\n * Don't forget to run an `npm i` to install the `youtube-api` dependencies.\n * */\n\nconst Youtube = require(\"youtube-api\")\n    , fs = require(\"fs\")\n    , readJson = require(\"r-json\")\n    , Lien = require(\"lien\")\n    , Logger = require(\"bug-killer\")\n    , opn = require(\"opn\")\n    , prettyBytes = require(\"pretty-bytes\")\n    ;\n\n// I downloaded the file from OAuth2 -\u003e Download JSON\nconst CREDENTIALS = readJson(`${__dirname}/credentials.json`);\n\n// Init lien server\nlet server = new Lien({\n    host: \"localhost\"\n  , port: 5000\n});\n\n// Authenticate\n// You can access the Youtube resources via OAuth2 only.\n// https://developers.google.com/youtube/v3/guides/moving_to_oauth#service_accounts\nlet oauth = Youtube.authenticate({\n    type: \"oauth\"\n  , client_id: CREDENTIALS.web.client_id\n  , client_secret: CREDENTIALS.web.client_secret\n  , redirect_url: CREDENTIALS.web.redirect_uris[0]\n});\n\nopn(oauth.generateAuthUrl({\n    access_type: \"offline\"\n  , scope: [\"https://www.googleapis.com/auth/youtube.upload\"]\n}));\n\n// Handle oauth2 callback\nserver.addPage(\"/oauth2callback\", lien =\u003e {\n    Logger.log(\"Trying to get the token using the following code: \" + lien.query.code);\n    oauth.getToken(lien.query.code, (err, tokens) =\u003e {\n\n        if (err) {\n            lien.lien(err, 400);\n            return Logger.log(err);\n        }\n\n        Logger.log(\"Got the tokens.\");\n\n        oauth.setCredentials(tokens);\n\n        lien.end(\"The video is being uploaded. Check out the logs in the terminal.\");\n\n        var req = Youtube.videos.insert({\n            resource: {\n                // Video title and description\n                snippet: {\n                    title: \"Testing YoutTube API NodeJS module\"\n                  , description: \"Test video upload via YouTube API\"\n                }\n                // I don't want to spam my subscribers\n              , status: {\n                    privacyStatus: \"private\"\n                }\n            }\n            // This is for the callback function\n          , part: \"snippet,status\"\n\n            // Create the readable stream to upload the video\n          , media: {\n                body: fs.createReadStream(\"video.mp4\")\n            }\n        }, (err, data) =\u003e {\n            console.log(\"Done.\");\n            process.exit();\n        });\n\n        setInterval(function () {\n            Logger.log(`${prettyBytes(req.req.connection._bytesDispatched)} bytes uploaded.`);\n        }, 250);\n    });\n});\n```\n\n\n\n\n\n\n\n\n\n\n\n\n## :question: Get Help\n\nThere are few ways to get help:\n\n\n\n 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.\n 2. For bug reports and feature requests, open issues. :bug:\n 3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:\n\n\n\n\n\n\n\n## :memo: Documentation\n\nThe [official Youtube documentation](https://developers.google.com/youtube/v3/docs/) is a very useful resource.\n\n - [Activities](https://developers.google.com/youtube/v3/docs/activities)\n - [ChannelBanners](https://developers.google.com/youtube/v3/docs/channelBanners)\n - [Channels](https://developers.google.com/youtube/v3/docs/channels)\n - [GuideCategories](https://developers.google.com/youtube/v3/docs/guideCategories)\n - [PlaylistItems](https://developers.google.com/youtube/v3/docs/playlistItems)\n - [Playlists](https://developers.google.com/youtube/v3/docs/playlists)\n - [Search](https://developers.google.com/youtube/v3/docs/search)\n - [Subscriptions](https://developers.google.com/youtube/v3/docs/subscriptions)\n - [Thumbnails](https://developers.google.com/youtube/v3/docs/thumbnails)\n - [VideoCategories](https://developers.google.com/youtube/v3/docs/videoCategories)\n - [Videos](https://developers.google.com/youtube/v3/docs/videos)\n\nIf you have any questions, please [ask them on **Stack Overflow**](https://stackoverflow.com/questions/ask) and eventually [open an issue](https://github.com/IonicaBizau/youtube-api/issues/new) and link your question there.\n\n### Authentication\n\n\n#### OAuth (Access Token)\n\n```js\nYoutube.authenticate({\n    type: \"oauth\"\n  , token: \"your access token\"\n});\n```\n\n#### OAuth (Refresh Token)\n\n```js\nYoutube.authenticate({\n    type: \"oauth\"\n  , refresh_token: \"your refresh token\"\n  , client_id: \"your client id\"\n  , client_secret: \"your client secret\"\n  , redirect_url: \"your refresh url\"\n});\n```\n\n#### Server Key\n\nOnly for requests that don't require [user authorization](https://developers.google.com/youtube/v3/guides/authentication) (certain list operations)\n```js\nYoutube.authenticate({\n    type: \"key\"\n  , key: \"your server key\"\n});\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n## :yum: How to contribute\nHave an idea? Found a bug? See [how to contribute][contributing].\n\n\n## :sparkling_heart: Support my projects\nI open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,\nthis takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).\n\nHowever, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:\n\n\n - Starring and sharing the projects you like :rocket:\n - [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:\n - [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:\n - [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).\n - **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`\n\n    ![](https://i.imgur.com/z6OQI95.png)\n\n\nThanks! :heart:\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## :scroll: License\n\n[MIT][license] © [Ionică Bizău][website]\n\n\n\n\n\n\n[license]: /LICENSE\n[website]: https://ionicabizau.net\n[contributing]: /CONTRIBUTING.md\n[docs]: /DOCUMENTATION.md\n[badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg\n[badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg\n[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg\n[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg\n[patreon]: https://www.patreon.com/ionicabizau\n[amazon]: http://amzn.eu/hRo9sIZ\n[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RVXDDLKKLQRJW\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fionicabizau%2Fyoutube-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fionicabizau%2Fyoutube-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fionicabizau%2Fyoutube-api/lists"}