https://github.com/johnnythetank/angular-youtube-api-factory
AngularJS Factory for Youtube JSON REST API requests
https://github.com/johnnythetank/angular-youtube-api-factory
angular angular-factory angularjs api factory youtube youtube-api
Last synced: 3 months ago
JSON representation
AngularJS Factory for Youtube JSON REST API requests
- Host: GitHub
- URL: https://github.com/johnnythetank/angular-youtube-api-factory
- Owner: JohnnyTheTank
- License: mit
- Created: 2015-11-08T14:48:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T08:20:02.000Z (over 8 years ago)
- Last Synced: 2024-11-17T04:51:40.592Z (over 1 year ago)
- Topics: angular, angular-factory, angularjs, api, factory, youtube, youtube-api
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 20
- Watchers: 4
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**angular-youtube-api-factory** is an angularjs module with a youtube api factory.
[](https://badge.fury.io/js/angular-youtube-api-factory)
[](https://badge.fury.io/bo/angular-youtube-api-factory)
Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
## Usage
1. Install via either [bower](http://bower.io/), [npm](https://www.npmjs.com/) or downloaded files:
1. `bower install --save angular-youtube-api-factory`
2. `npm install --save angular-youtube-api-factory`
3. download [angular-youtube-api-factory.zip](https://github.com/JohnnyTheTank/angular-youtube-api-factory/zipball/master)
2. Include dependencies in your HTML.
1. When using bower:
```html
```
2. When using npm:
```html
```
3. when using downloaded files
```html
```
3. Add **`jtt_youtube`** to your application's module dependencies
```JavaScript
angular.module('app', ['jtt_youtube']);
```
4. Use the factory `youtubeFactory`
```JavaScript
angular.module('app')
.controller('appController', function($scope, youtubeFactory){
youtubeFactory.getVideosFromSearchByParams({
q: 'fcbayern',
key: ''
}).then(function (data) {
console.info('videos from search by query', data);
});
});
```
### factory methods
#### getVideo
```js
//docs: https://developers.google.com/youtube/v3/docs/videos/list
youtubeFactory.getVideoById({
videoId: "",
part: "", // (optional) default: 'id,snippet,contentDetails,statistics'
key: "",
}).then(function (_data) {
//on success
}).catch(function (_data) {
//on error
});
```
#### getVideos
```js
//docs: https://developers.google.com/youtube/v3/docs/channels/list
youtubeFactory.getVideosFromChannelById({
channelId: "", // converter: http://johnnythetank.github.io/youtube-channel-name-converter/
q: "", // (optional) search string
location: "", // (optional) The parameter value is a string that specifies latitude/longitude coordinates e.g. '37.42307,-122.08427'.
locationRadius: "", // (optional) valid values e.g. '1500m', '5km', '10000ft', and '0.75mi' | default: '5000m'
order: "", // (optional) valid values: 'date', 'rating', 'relevance', 'title', 'videoCount', 'viewCount' | default: 'date'
maxResults: "", // (optional) valid values: 0-50 | default: 5
publishedAfter: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z)
publishedBefore: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z)
regionCode: "", // (optional) ISO 3166-1 alpha-2 country code
relevanceLanguage: "", // (optional) ISO 639-1 two-letter language code
safeSearch: "", // (optional) valid values: 'moderate','none','strict' | defaut: 'moderate'
maxResults: "", // (optional) valid values: 0-50 | default: 5
videoEmbeddable: "", // (optional) valid values: 'true', 'any' | default: 'true'
videoLicense: "", // (optional) valid values: 'any','creativeCommon','youtube'
videoSyndicated: "", // (optional) restrict a search to only videos that can be played outside youtube.com. valid values: 'any','true' | default: 'any'
fields: "", // (optional) Selector specifying which fields to include in a partial response
nextPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
prevPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
part: "", // (optional) default: 'id,snippet'
key: "",
}).then(function (_data) {
//on success
}).catch(function (_data) {
//on error
});
```
```js
//docs: https://developers.google.com/youtube/v3/docs/search/list
youtubeFactory.getVideosFromSearchByParams({
q: "", // (optional) search string
location: "", // (optional) The parameter value is a string that specifies latitude/longitude coordinates e.g. '37.42307,-122.08427'.
locationRadius: "", // (optional) valid values e.g. '1500m', '5km', '10000ft', and '0.75mi' | default: '5000m'
order: "", // (optional) valid values: 'date', 'rating', 'relevance', 'title', 'videoCount', 'viewCount' | default: 'date'
maxResults: "", // (optional) valid values: 0-50 | default: 5
publishedAfter: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z)
publishedBefore: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z)
regionCode: "", // (optional) ISO 3166-1 alpha-2 country code
relevanceLanguage: "", // (optional) ISO 639-1 two-letter language code
safeSearch: "", // (optional) valid values: 'moderate','none','strict' | defaut: 'moderate'
maxResults: "", // (optional) valid values: 0-50 | default: 5
videoEmbeddable: "", // (optional) valid values: 'true', 'any' | default: 'true'
videoLicense: "", // (optional) valid values: 'any','creativeCommon','youtube'
videoSyndicated: "", // (optional) restrict a search to only videos that can be played outside youtube.com. valid values: 'any','true' | default: 'any'
fields: "", // (optional) Selector specifying which fields to include in a partial response
nextPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
prevPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
part: "", // (optional) default: 'id,snippet'
key: "",
}).then(function (_data) {
//on success
}).catch(function (_data) {
//on error
});
```
```js
//docs: https://developers.google.com/youtube/v3/docs/playlists/list
youtubeFactory.getVideosFromPlaylistById({
playlistId: "",
maxResults: "", // (optional) valid values: 0-50 // default: 5
nextPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
prevPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
part: "", // (optional) default: 'id,snippet'
key: "",
}).then(function (_data) {
//on success
}).catch(function (_data) {
//on error
});
```
#### getChannel
```js
// docs: https://developers.google.com/youtube/v3/docs/search/list
youtubeFactory.getChannelById({
channelId: "", // converter: http://johnnythetank.github.io/youtube-channel-name-converter/
nextPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
prevPageToken: "", // (optional) either 'nextPageToken' or 'prevPageToken'
part: "", // (optional) default: 'id,snippet'
key: "",
}).then(function (_data) {
//on success
}).catch(function (_data) {
//on error
});
```
## Youtube Data JSON API
* Docs: https://developers.google.com/youtube/v3/docs/
* API Explorer: https://developers.google.com/apis-explorer/#p/youtube/v3/
* Youtube Username to Channel ID Converter: http://johnnythetank.github.io/youtube-channel-name-converter/
## More angular-api-factories
[bandsintown](https://github.com/JohnnyTheTank/angular-bandsintown-api-factory) - [dailymotion](https://github.com/JohnnyTheTank/angular-dailymotion-api-factory) - [facebook](https://github.com/JohnnyTheTank/angular-facebook-api-factory) - [flickr](https://github.com/JohnnyTheTank/angular-flickr-api-factory) - [footballdata](https://github.com/JohnnyTheTank/angular-footballdata-api-factory) - [github](https://github.com/JohnnyTheTank/angular-github-api-factory) - [openweathermap](https://github.com/JohnnyTheTank/angular-openweathermap-api-factory) - [tumblr](https://github.com/JohnnyTheTank/angular-tumblr-api-factory) - [vimeo](https://github.com/JohnnyTheTank/angular-vimeo-api-factory) - [wikipedia](https://github.com/JohnnyTheTank/angular-wikipedia-api-factory) - **youtube**
## License
MIT