Wednesday, October 2, 2013

Spice up your channel with the InVideo Programming API

If you’ve used InVideo Programming before, you know that it’s a powerful way to attract subscribers to your channel. By featuring a watermark or a hit video on all videos on your channel, you can showcase the best of what your channel has to offer. You can also add a link to your home on social networks with a custom message to drive two-way conversation with your viewers on multiple fronts.

“That’s awesome,” you might say. “I’m already using it via the YouTube.com website!” Well, great! But did you know these options are available via our v3 Data API? The API enables all kinds of interesting use cases. Some examples:

  • Update the message to tease your latest tweet. When users click on your link, they are taken to your Twitter page
  • Feature the most recent upload to any channel on YouTube
  • Run a channel about television? You can write a script to rotate the featured video depending on whether it is the afternoon or the evening, a weekday or a weekend! Or, rotate the featured video daily to drive more views, reshares and discussion of quality content that might not be as fresh
  • Build a widget on your website or mobile app that lets your subscribers vote for a video to be featured every week! The video doesn’t have to be a video from your channel - it can be any video on YouTube!

InVideo Programming options are set as part of the channels resource, passed as a parameter to youtube.channels.update() in the invideoPromotion field. For instance, to feature this recent “YouTube Developers Live” show featuring our team’s favorite moments, I would structure the invideoPromotion field in my API request’s payload body like this:

invideoPromotion": {
"items": [
 {
  "id": {
   "type": "video",
   "videoId": "lzaYch2mqlU"
  },
  "timing": {
   "type": "offsetFromStart",
   "offsetMs": "0",
   "durationMs": "15000"
  }
 }
]
}

Other options for the type field in the id object include website and recentUpload, which correspond to InVideo Programming featuring a link, or automatically updating InVideo Programming featuring the latest video in a channel. For more information, see the documentation describing the invideoPromotion object in the channels resource.



A video featuring a watermark (top right) and InVideo Programming (bottom left)

Chances are good, though, that you’re using one of our API client libraries, which will help translate these API requests and responses into programmatic objects that you can manipulate and pass around in your code.

InVideo Programming functionality is relatively new, so if you are using an API client for a language like Java or .NET, you will need to make sure your client libraries are up-to-date before you can take advantage of these new features. Our samples are sorted by programming language on our Github page.

You can also set a channel’s watermark using the Data API’s watermarks.set() method. Watermarks are images that appear in the upper right hand corner of your videos that will link viewers to your channel on web and in the YouTube mobile apps for Android and iOS. This is usefu

InVideo Programming lets you reinforce your channel’s brand and drive viewers to other videos or social channels. The API makes it easy for your team to integrate InVideo Programming into your tools and workflow to make them more dynamic and interesting. Integrating the API into your tools and workflow only help to make your InVideo Programming more dynamic.

Happy coding!

Thursday, September 12, 2013

What to watch? Our APIs can help!

It’s an age-old question: what to watch? Applications that integrate with YouTube have access to countless hours of videos, and, as a developer, you have an interest in helping your users find the videos and channel most relevant to them. This blog post will walk you through a few ways that you can use the latest YouTube Data API to discover great content.

If you have an OAuth 2 token for the current user, your application can make a call to youtube.activities.list(part=”snippet”, home=true) to get back a list of videos and channels similar to the recommendations that the user would see on the YouTube.com home page. These results are customized for each individual user, and the list is kept fresh automatically, so it’s a great way to present your users with content they’re likely to enjoy.

Even if your users are not logged in, there are still are a few charts and guides at your disposal to aid in discovery.

To find popular videos your users might want to watch, youtube.videos.list(part=”snippet”, chart=”mostPopular”) is the basic API call to use. By default, it will return a list of videos in any category that are considered popular globally. If this is too broad a list, though, you can narrow things down using the regionCode or videoCategoryId (or both) parameters. regionCode can be set to a two-letter country code to retrieve a list of videos popular in that specific country (though not every country is currently supported). videoCategoryId needs to be set to an ID corresponding to one of our existing video categories—you can retrieve a list of valid categories and their corresponding IDs via youtube.videoCategories.list(part=”snippet”, regionCode=”XX”), where “XX” is also a two-letter country code.

There’s an analogous set of API calls that you could make to find channels your users might be interested in. youtube.guideCategories.list(part=”snippet”, regionCode=”XX”) will return a list of all the channel categories that are available in a given country. Once a user has chosen a category, you can get back a list of the most relevant channels in that category via a call to youtube.channels.list(part=”snippet”, categoryId=”CATEGORY_ID”), where “CATEGORY_ID” is the ID of the guide category you’re interested in. At that point, you could display a list of the most recent videos associated with each channel, and give your users the option of subscribing (assuming they grant OAuth 2 authorization first).

All of these examples assume that you’re using the latest version of the YouTube Data API, v3. Developers still using the Data API v1 or v2 should be aware of some recent changes to our older content discovery mechanism, standard feeds. As explained in the documentation, all of the previous different types of standard feeds are now returning the equivalent of the most_popular feed, with the time parameter set to “today”. If you are still using v1 or v2, there’s no time like the present (time=”today”, if you will) to make the switch to v3.

Update: For a walkthrough and demos of all the API calls, please watch this episode of YouTube Developers Live:



Cheers,

Wednesday, August 28, 2013

Here’s my playlist, so submit a video, maybe?

YouTube Direct Lite allows you to solicit videos from your users and then moderate those submissions into standard YouTube playlists for display. And now there is an app for that.

With the YouTube Direct Lite app, your fans can

  • record a new video,
  • upload an existing video from their device,
  • pick one of their own YouTube uploads

and submit to your playlist, all from their Android device. You can then moderate their submissions, which won't show up in your playlist till you explicitly approve them.

YouTube Direct Lite platform doesn’t require any server-side code that needs to be configured or deployed. As the moderator, you will see a playlist of videos waiting for your approval. The videos you approve, will be added into your channel.

Main Activity YouTube player Upload Service
Main ActivityYouTube playerUpload Service

How to start using the application

1) Register your Android app
2) Enable the Youtube Data API v3 and Google+ API in your API Console.
3) Include the Google Play Services library in your project to build this application.
4) Plug your Playlist Id into Constants.java and Android API Key into Auth.java

Open-sourced to reference best practices of YouTube APIs and Android

YouTube Direct Lite for Android is an open-sourced project and you are more than welcome to customize it for your needs as well as contribute back to the project with bug reports, feature or merge requests.

This application uses the YouTube Data API v3, YouTube Android Player API, YouTube Resumable Uploads, Google Play Services and Plus API.

In addition to mobile best practices for the YouTube APIs, this project follows the design and development guidelines for Android. This project adheres to Holo style, typography, 48dp rhythm, iconography and uses IntentService, BigPictureStyle notification, and GoogleAccountCredential.

In addition, in this video, we talk about the philosophy we followed in building the App and a few best practices for the Youtube APIs and Android development.



This App is still experimental, so stay tuned here and subscribe to the YouTube for Developers channel to keep up on the latest.

Cheers,
Ibrahim Ulukaya, YouTube API Team

Thursday, July 25, 2013

Drive YouTube subscriptions from your web site

(Cross-posted from the YouTube Creator blog.)

To build your YouTube audience from all of your web properties, you can now embed the YouTube subscribe button on your site. This lets your fans subscribe with a single click without leaving your site. Once fans subscribe, they can see your channel on their YouTube homepage, phone, tablet, Playstation 3, smart TVs and millions of other devices.

Here’s what the subscribe button looks like on Vice.com in the bottom-right corner of this screenshot:


To put the subscribe button on your site, just embed the code below like you’d embed a YouTube video.
<script src="https://apis.google.com/js/plusone.js"></script>
<div class="g-ytsubscribe" data-channel="Your Channel Name Here">
</div>

Check out this documentation if you want to customize the button or dive into the details.

Kurt Wilms, Product Manager, recently watched “Stjarnan FC show how to celebrate a goal.”

Monday, June 24, 2013

Google+ page identities and the YouTube API

As more YouTube channels start using Google+ page identities, here are some best practices to ensure that your code can make authorized API calls to access the channel.


With Google+ page identities, there can be many channels associated with a single Google Account. For example, when a user Alice Smith signs into her Google Account, she may have her “Alice Smith” (personal) channel on that account, and potentially additional channels, linked to Google+ pages, on associated accounts. These associated accounts do not have a password by default; she gets access to them by signing into her personal account, and then using a switcher to go back and forth between them.


How does this channel selection work with APIs? With API access through web-based OAuth 2, the switcher comes automatically. The web flow will ask Alice which account she wants to use, after she signs into her “Alice Smith” account. The OAuth 2 tokens your application gets back work just as they do today.


The OAuth 2 web-based “Select an account” interface, allowing a user to grant access to their personal channel or any channels linked to Google+ pages that they manage.


If you’re not using web-based OAuth 2 (you are still relying on one of our deprecated authorization methods), or if you are an Android developer who is using OAuth 2 (there is currently no native Android account switcher), then the API will choose the “wrong” channel in some cases, or even no channel (e.g., if the personal account doesn’t have a channel). When this happens, the user has two options to specify the correct channel:


As a best practice, we recommend that you ensure users know of these options, so your application will access the correct channel. Even more importantly, we recommend that all applications provide visual feedback letting users know which channel is currently authorized. If you’re still using version 2 of the YouTube Data API, you can retrieve the profile of the special identifier default; this corresponds to the currently authorized channel’s profile. In the version 2 response, the channel’s display name is returned as an attribute of yt:username, and the profile image can be found by looking at media:thumbnail. If you’ve started using version 3, then the method to use is channels.list() with the part=snippet and mine=true parameters set. The version 3 response contains a channel’s display name in channel.snippet.title and profile image in channel.snippet.thumbnails.default.url.


To summarize, here are the high-level points to keep in mind:
  • OAuth 2 will automatically display a “Select an account” web interface, allowing users with multiple channels associated with their account to choose which one they’re authorizing access to.
    • ...this doesn’t apply to Android OAuth 2, yet.
  • Use of other authorization methods will mean some users need to specify which channel to use, either in their Advanced Account Settings (if they consistently use one channel), or by setting up login credentials for each channel, and using them as needed.
  • All developers are strongly encouraged to display visual feedback letting their users know which channel is currently authorized.


Update: This YouTube Developers Live show with Sherry Listgarten, the Product Manager responsible for Google+ and YouTube integration, goes into more details about plans for Google identities and YouTube channels. It also contains a video walkthrough of many of the points covered in this blog post.



Cheers,
Jeff Posnick, YouTube API Team

Friday, May 10, 2013

Find the hidden patterns with YouTube’s new Analytics API


Trying to figure out how YouTube’s one billion monthly users are interacting with your videos? Try the new YouTube Analytics API to get custom reports of the YouTube statistics you care about in a direct JSON or CSV response, perfect for dashboards and ad hoc reports. 

The new API includes all the standard view and engagement metrics you would expect, including views, shares, and subscriber numbers. Compared to the previous Insight Data API, you also get:
  • Watch metrics: Track estimated minutes watched across channel, content owner, or video, and dive into the video details with average view time and average view percentage.
  • Earning performance metrics: Track estimated earnings (net revenue) from select advertising sources across your content.
  • Ad performance metrics: Break down video performance with monetized playbacks, ad impressions, gross revenue, and cost per impression reports.
  • Annotation metrics: Optimize overlays/annotations with click through and close rate metrics.
Client Libraries and Code Samples
You’ll find client libraries for the languages you use most, with nine different languages available today. You can also make HTTP RESTful requests directly, and with our API Explorer, you can try out sample reports before writing any code.  

Don’t write your code from scratch! Get started with code examples in Java, JavaScript, Python, and Ruby. If you want a step-by-step walkthrough of building a complete web application, have a look at our JavaScript exercise.  

App Examples
Check out some apps that are already using the API: 

Next Big Sound
Next Big Sound
VidIQ
VidIQ
  • Next Big Sound provides analytics and insights for the music industry by tracking billions of social signals including YouTube. This enables record labels, artists, and band managers to make better decisions on everything from promotion strategies to tour locations.
  • vidIQ is an audience development suite that works with global brands to organically grow their views and subscribers. Their features include cross-platform social analytics, advanced comment management, SEO tools, social syndication and influencer identification. 
Wizdeo
Wizdeo
Vidyard
Vidyard













  • Wizdeo’s WizTracker provides in-depth analysis of YouTube channels to help with cross promotion and video comparisons during their initial launch. Users get access to detailed analytics about views, subscriber engagement, traffic sources and demographics.
  • Vidyard is a video marketing platform. With powerful analytics, built-in marketing tools, and integration with key marketing automation platforms, Vidyard helps marketers drive results with video content.  
Fullscreen
Fullscreen
  • Fullscreen is building a global network of YouTube channels with content creators and brands. Fullscreen provides a full suite of end-to-end YouTube tools and uses the new API for internal, business-intelligence tools.  

Learn More
In addition to the documentation, check out our Analytics API playlist to make getting started even easier.  



If your goal is to export all statistics for a large number of channels on a recurring basis for your data warehouse, look forward to using the upcoming scheduled reports feature of the API, expected to launch later this year.

To get more info on the YouTube APIs, subscribe to our YouTube for Developers’ channel and YouTubeDev on Google+. 

Cheers,
-- Ted Hamilton, Christoph Schwab-Ganser, and the YouTube Analytics API Team