Code Monkey home page Code Monkey logo

youtube-v3-api's Introduction

youtube-v3-api

An Asynchronous promise based wrapper around the YouTube Data API.

Build Status npm version DUB

Usage

Open terminal from the project folder execute the following command to install the package :

yarn add youtube-v3-api
--------OR--------
npm install youtube-v3-api 

Sample code snippet :

const { YoutubeDataAPI } = require("youtube-v3-api")
const API_KEY = '<ENTER YOUR API KEY HERE>';

const api = new YoutubeDataAPI(API_KEY);

api.searchAll(API_KEY,"Node Js",25).then((data) => {
    console.log(data);
},(err) => {
    console.error(err);
})

Documentation

searchAll

Returns a collection of search results that match the query parameters specified in the API request. By default, a search result set identifies matching video, channel, and playlist resources, but you can also configure queries to only retrieve a specific type of resource.

searchAll(q: string, maxResults: number, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • q : Search query.
  • maxResults : The maximum number of search results (0 - 50, for more results check out next and previous page call).
  • args (Optional) : Additional parameters, to know more click here.

searchVideo

Returns a list of videos that match the API request parameters.

searchVideo(id: string, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • id : Video Id.
  • args (Optional) : Additional parameters, to know more click here.

searchChannel

Returns a collection of zero or more channel resources that match the request criteria.

searchChannel(id: string, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • id : Channel Id.
  • args (Optional) : Additional parameters, to know more click here.

searchChannelSections

Returns a list of videos that match the API request parameters.

searchChannelSections(channelId: string, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • channelId : Channel Id.
  • args (Optional) : Additional parameters, to know more click here.

searchComments

Returns a list of comments that match the API request parameters.

searchComments(parentId: string, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • parentId : The parent comment is the first comment on a video.
  • args (Optional) : Additional parameters, to know more click here.

searchCommentThreads

Returns a list of comment threads that match the API request parameters.

searchCommentThreads(videoId: string, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • videoId : Video Id.
  • args (Optional) : Additional parameters, to know more click here.

searchPlaylist

Returns a collection of playlists that match the API request parameters. For example, you can retrieve all playlists that the authenticated user owns, or you can retrieve one or more playlists by their unique IDs.

searchPlaylist(channelId: string, maxResults: number, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • channelId : Channel Id.
  • maxResults : The maximum number of search results (0 - 50, for more results check out next and previous page call).
  • args (Optional) : Additional parameters, to know more click here.

searchPlaylistItems

Returns a collection of playlist items that match the API request parameters. You can retrieve all of the playlist items in a specified playlist or retrieve one or more playlist items by their unique IDs.

searchPlaylistItems(playlistId: string, maxResults: number, args?: any): Promise<{}>
  • API_KEY : The youtube API Key. See here to know about how to get an API KEY.
  • playlistId : Playlist Id.
  • maxResults : The maximum number of search results (0 - 50, for more results check out next and previous page call).
  • args (Optional) : Additional parameters, to know more click here.

Todo

  • Use the default Http module so that this module can be free from dependency.
  • Any missing basic API calls.
  • next and previous page.
  • Make typescript classes for the data returned so that additional functions can be attached like next page and previous page.
  • Embed all OAuth2 API's.
  • Add the additional API calls which need OAuth2 Access.

NOTE : Everything must Promised.

youtube-v3-api's People

Contributors

kanishkarj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

youtube-v3-api's Issues

When running file "TypeError: YoutubedataAPI is not a constructor" occurs.

This is my code:

const youApiKey = "< I'm not going to show my key >";
const { YoutubedataAPI } = require("youtube-v3-api");

const youApi = new YoutubedataAPI(youApiKey);

When ran, this error occurs:

C:\Users\Talon\Documents\Jarvis\bot.js:19
const youApi = new YoutubedataAPI(youApiKey);
               ^

TypeError: YoutubedataAPI is not a constructor
    at Object.<anonymous> (C:\Users\Talon\Documents\Jarvis\bot.js:19:16)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11

I have no idea why this is happening. Please, help me.

How upload video file?

I like to upload a video file (Ex. video.mp4). In the readme, I can't found how can I upload video directly

Update README.md to avoid confusion when using API methods

The code used under the Sample code snippet section, e.g.

`const { YoutubeDataAPI } = require("youtube-v3-api")
const API_KEY = '';

const api = new YoutubeDataAPI(API_KEY);

api.searchAll(API_KEY,"Node Js",25).then((data) => {
console.log(data);
},(err) => {
console.error(err);
})`

Is slightly misleading because the method "searchAll()" doesn't actually require "API_KEY" as a parameter.

I started referencing it when using this method and saw an error in the console, which got me started on troubleshooting (googling the console error, pulling down this library and running the mocha tests, etc).

Updating the README avoids any confusion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.