An open API service indexing awesome lists of open source software.

https://github.com/thenoim/youtubelibrary

Nils little youtube library :)
https://github.com/thenoim/youtubelibrary

api browser data nodejs simple youtube

Last synced: about 2 months ago
JSON representation

Nils little youtube library :)

Awesome Lists containing this project

README

          

# Nils little youtube library
### For nodejs and every happy browser

The only thing you need is a google api key :) (https://console.developers.google.com/) which is enabled for the YouTube Data API

# FAQ
### How can I install it ?
For the browser you should use bower (https://bower.io):
`bower install little-ytlib --save`
In NodeJS yarn (https://yarnpkg.com/lang/en/) or npm (... https://nodejs.org/en/):
Yarn: `yarn add little-ytlib`
NPM: `npm install little-ytlib --save`

### How can I use it now ?
If you want to use it in your browser, you need to include the bundle.min.js
```html

var yt = new YTLib("MY_API_KEY");
// Now you can use it

```
If you want to use it with NodeJS, simply require it:
```javascript
const YTLib = require('little-ytlib');
const yt = new YTLib("MY_API_KEY");
// Now you can use it
```

### How do I known which methods I can use ?
I think I doucmented the library very good with JSDoc. You can simply look in the source file on this repository (https://raw.githubusercontent.com/TheNoim/YouTubeLibrary/master/YouTubeLibrary.js)

# Documentation

## Classes


YouTubeLibrary


## Typedefs



YouTubeVideoResource : Object



VideoSnippet : Object



VideoStatistics : Object



YouTubePageInfo : Object



searchListResponse : Object



PlaylistInformation : Object



PlaylistSnippet : Object



PlaylistContentDetails : Object



Video : Object



PlayListWithVideos : Object


## YouTubeLibrary
**Kind**: global class
**Author:** Nils Bergmann

* [YouTubeLibrary](#YouTubeLibrary)
* [new YouTubeLibrary(APIKey)](#new_YouTubeLibrary_new)
* [.getVideoInformation(videoId, [Callback])](#YouTubeLibrary+getVideoInformation) ⇒ Promise.<(VideoSnippet\|Array.<VideoSnippet>)>
* [.searchOnYouTube(SearchText, [type], [Order], [maxResults], [pages], [nextPageToken])](#YouTubeLibrary+searchOnYouTube) ⇒ [Promise.<searchListResponse>](#searchListResponse)
* [.getPlaylistInformation(playlistId, [Callback])](#YouTubeLibrary+getPlaylistInformation) ⇒ [Promise.<PlaylistInformation>](#PlaylistInformation)
* [.getPlaylist(playlistId, [Callback])](#YouTubeLibrary+getPlaylist) ⇒ Promise
* [.getPlaylistVideos(playlistId, [Callback])](#YouTubeLibrary+getPlaylistVideos) ⇒ Promise.<Array>
* [.getChannelID(forUsername, [Callback])](#YouTubeLibrary+getChannelID) ⇒ Promise.<String>
* [.getChannelPlaylists(channelId, [Callback])](#YouTubeLibrary+getChannelPlaylists) ⇒ Promise.<Array.<PlayListWithVideos>>
* [.getChannelPlaylistsByUsername(Username, [Callback])](#YouTubeLibrary+getChannelPlaylistsByUsername) ⇒ Promise.<Array.<PlayListWithVideos>>
* [.getChannel(channelID, [Callback])](#YouTubeLibrary+getChannel) ⇒ Promise.<Object>
* [.getChannelByUsername(Username, [Callback])](#YouTubeLibrary+getChannelByUsername) ⇒ Promise.<Object>

### new YouTubeLibrary(APIKey)
Nils little youtube library

| Param | Description |
| --- | --- |
| APIKey | API Key to access the youtube data api |

### youTubeLibrary.getVideoInformation(videoId, [Callback]) ⇒ Promise.<(VideoSnippet\|Array.<VideoSnippet>)>
Get the video information's of the videoId

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| videoId | string | array |
| [Callback] | function |

### youTubeLibrary.searchOnYouTube(SearchText, [type], [Order], [maxResults], [pages], [nextPageToken]) ⇒ [Promise.<searchListResponse>](#searchListResponse)
Search on youtube with the given parameters

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| SearchText | string | | |
| [type] | string | "video,channel,playlist" | |
| [Order] | string | "relevance" | |
| [maxResults] | int | 20 | Max result per page |
| [pages] | int | 10 | how many pages to query |
| [nextPageToken] | string | | |

### youTubeLibrary.getPlaylistInformation(playlistId, [Callback]) ⇒ [Promise.<PlaylistInformation>](#PlaylistInformation)
Get all important information's of a playlist

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| playlistId | string |
| [Callback] | function |

### youTubeLibrary.getPlaylist(playlistId, [Callback]) ⇒ Promise
Get all information's of a playlist including the videos. The videos are resolved to youtube#video

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| playlistId | string |
| [Callback] | function |

### youTubeLibrary.getPlaylistVideos(playlistId, [Callback]) ⇒ Promise.<Array>
Get only the resolved videos of a playlist. Videos are in the format youtube#video

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| playlistId | string |
| [Callback] | function |

### youTubeLibrary.getChannelID(forUsername, [Callback]) ⇒ Promise.<String>
Get the channelId of an username

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| forUsername | string |
| [Callback] | function |

### youTubeLibrary.getChannelPlaylists(channelId, [Callback]) ⇒ Promise.<Array.<PlayListWithVideos>>
Get all playlist's of a channel. The videos are in the format youtube#video

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| channelId | string |
| [Callback] | function |

### youTubeLibrary.getChannelPlaylistsByUsername(Username, [Callback]) ⇒ Promise.<Array.<PlayListWithVideos>>
Same as getChannelPlaylists() but you can use the channel username instead of the channel id

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| Username | string |
| [Callback] | function |

### youTubeLibrary.getChannel(channelID, [Callback]) ⇒ Promise.<Object>
Get channel information's

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| channelID | string |
| [Callback] | function |

### youTubeLibrary.getChannelByUsername(Username, [Callback]) ⇒ Promise.<Object>
Same as getChannel() but you can use the channel username instead of the channel id

**Kind**: instance method of [YouTubeLibrary](#YouTubeLibrary)

| Param | Type |
| --- | --- |
| Username | |
| [Callback] | function |

## YouTubeVideoResource : Object
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| kind | string | Type (youtube#video) |
| etag | string | |
| id | string | VideoId |
| snippet | [VideoSnippet](#VideoSnippet) | |
| statistics | [VideoStatistics](#VideoStatistics) | |

## VideoSnippet : Object
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| publishedAt | string | Date in ISO 8601 format |
| channelId | string | |
| title | string | Video title |
| description | string | |
| thumbnails | Object | |
| channelTitle | string | The displayname of the channel which published the video |
| tags | Array.<string> | List of tags for the video |
| categoryId | string | https://developers.google.com/youtube/v3/docs/videoCategories/list |
| liveBroadcastContent | string | |
| defaultLanguage | string | |
| localized | Object | |
| defaultAudioLanguage | string | |

## VideoStatistics : Object
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| viewCount | int | |
| likeCount | int | |
| dislikeCount | int | |
| favoriteCount | int | This property has been deprecated. The deprecation is effective as of August 28, 2015. The property's value is now always set to 0. |
| commentCount | int | |

## YouTubePageInfo : Object
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| totalResults | int |
| resultsPerPage | int |

## searchListResponse : Object
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| kind | string |
| etag | string |
| nextPageToken | string |
| regionCode | string |
| pageInfo | [YouTubePageInfo](#YouTubePageInfo) |
| items | Array |

## PlaylistInformation : Object
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| kind | string |
| etag | string |
| id | id |
| snippet | [PlaylistSnippet](#PlaylistSnippet) |
| contentDetails | [PlaylistContentDetails](#PlaylistContentDetails) |

## PlaylistSnippet : Object
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| publishedAt | string | Date in ISO 8601 format |
| channelId | string | |
| title | string | |
| description | string | |
| thumbnails | Object | |
| channelTitle | string | The displayname of the channel which published the playlist |
| tags | Array.<string> | List of tags for the playlist |
| defaultLanguage | string | |
| localized | Object | |

## PlaylistContentDetails : Object
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| itemCount | int | The count how much items the playlist contains |

## Video : Object
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| kind | string |
| etag | string |
| id | string |
| snippet | Object |
| contentDetails | Object |
| statistics | Object |

## PlayListWithVideos : Object
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| kind | string |
| etag | string |
| id | string |
| snippet | Object |
| contentDetails | Object |
| videos | [Array.<Video>](#Video) |