YouTube API: Dive In

4,286 views

Published on

The YouTube API discovery presentation. Defines the API in general terms and outlines the way in which you can interact with YouTube assets.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,286
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
73
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

YouTube API: Dive In

  1. 1. YouTube API: Dive-In<br />HigEdWebDev 2009<br />Ron West<br />
  2. 2. Google&apos;s mission <br />…is to organize the world&apos;s information and make it universally accessible and useful. Sometimes making information accessible requires making it available in contexts other than a web browser.<br />
  3. 3. Agenda<br />Introduction<br />Getting Started<br />Get Content<br />Interaction<br />Pulling it Together<br />Developer Community<br />
  4. 4. Introduction<br />YouTube in Review<br />REST<br />Google Data API<br />YouTube Data API<br />Entries/Feeds<br />Authentication<br />
  5. 5. YouTube in Review<br />Videos<br />Comments<br />Ratings<br />Users<br />Categories<br />Keywords/Tags<br />Channels<br />Subscriptions<br /><ul><li>Messages
  6. 6. Activity Feeds
  7. 7. Recommendations
  8. 8. Friends
  9. 9. Related Videos
  10. 10. Captions
  11. 11. Favorites
  12. 12. Insight Data</li></li></ul><li>REST<br />REpresentationalState Transfer<br />Architectural Style – NOT – Standard<br />More akin to Doc Literal than RPC based Web Service<br />Logical URL’s vs. Static URL’s<br />
  13. 13. REST<br />Client-Server<br />Stateless<br />Cacheable<br />Uniform Interface<br />Layered<br />
  14. 14. REST<br />HTTP Methods<br />Get = List or Retrieve<br />Put = Replace or Update<br />Post = Create<br />Delete = Delete<br />
  15. 15. Pros <br /><ul><li>Single endpoint for all calls
  16. 16. Lanugage, platform and transport agnostic
  17. 17. Built in error handling</li></ul>Cons<br /><ul><li>Conceptually more difficult
  18. 18. Harder to develop with (requires tools)</li></ul>SOAP (RPC/Doc Literal) Web Services<br />
  19. 19. Multiple Endpoints<br />Pros<br /><ul><li>Language and platform agnostic
  20. 20. Simpler to develop than SOAP
  21. 21. Concise</li></ul>Cons<br /><ul><li>Lack of standards
  22. 22. Tied to HTTP transport</li></ul>REST Web Services<br />
  23. 23. Get API URL’s for:<br /><ul><li>Comments
  24. 24. Related Videos
  25. 25. Ratings
  26. 26. Mobile
  27. 27. Versions
  28. 28. Get Video(s)
  29. 29. Edit Video
  30. 30. Delete Video</li></li></ul><li>Google Data API<br />RSS vs. Atom<br />APP<br />Get vs. Post vs. Put vs. Delete<br />
  31. 31. Response Codes<br />Same response codes for HTTP<br />200, 201, 301, 400, 500 etc..<br />Codes have similar meaning for each type of call<br />200 (OK)<br />400 (Bad Request)<br />401 (Not Authorized)<br />404 (Not Found)<br />500 (Internal Error)<br />Accompanied with error details (XML in payload)<br />
  32. 32. YouTube Data API<br />Version 1<br />Version 2 (recommended)<br />
  33. 33. YouTubeData API<br />Search for Videos<br />Keywords (tags)<br />Categories<br />Query Params (metadata)<br />Search for Playlists<br />Keywords (tags)<br />Categories<br />Search for Channels<br />Keywords (tags)<br />Categories<br />
  34. 34. YouTube Data API<br />Retrieve<br />Videos<br />Comments<br />Captions<br />Related Videos<br />Video Responses<br />Categories<br />Keywords<br />Playlists<br />Subscriptions<br />Profiles<br />Contacts<br />Messages<br />Activity Feeds<br />Insight Data Feed<br />Favorites<br />
  35. 35. YouTube Data API (cont.)<br />Create<br />Videos<br />Comments<br />Captions<br />Related Videos<br />Video Responses<br />Complaint<br />Rating<br />Contact<br />Message<br />Favorite<br />Playlist<br />Subscription<br />
  36. 36. YouTube Data API (cont.)<br />Update<br />Video Metadata<br />Captions<br />Profiles<br />Playlists<br />Contacts<br />Delete<br />Video<br />Message<br />Favorite<br />Playlist<br />Subscription<br />Contact<br />
  37. 37. YouTube Data API<br />Batch Processing<br />Process multiple types of calls in a single request<br />Each Request in its own &lt;entry&gt; tag<br />
  38. 38. Sample Interaction<br />Query API for videos tagged with “SHU”<br />Display Videos in List<br />Allow user to Select Video to Display<br />Display Single Video<br />Retrieve Comments for that Video<br />Post Comment<br />Login<br />Add to Playlist<br />
  39. 39. Feed<br />&lt;feed [namespaces]&gt;<br /> … metadata …<br /> &lt;openSearch:totalResults /&gt;<br /> &lt;openSearch:startIndex /&gt;<br /> &lt;openSearch: itemsPerPage /&gt;<br /> &lt;entry&gt;<br /> … metadata …<br /> &lt;media:group/&gt;<br /> &lt;/entry&gt;<br /> &lt;entry&gt;<br /> … metadata …<br /> &lt;media:group/&gt;<br /> &lt;/entry&gt;<br /> …<br />&lt;/feed&gt;<br />
  40. 40. Entry (video)<br />&lt;entry [namespaces]&gt;<br /> &lt;title/&gt;<br /> &lt;content/&gt;<br /> … metadata …<br /> &lt;link rel=“http://gdata.youtube.com/schemas/2007#video.responses “/&gt;<br /> &lt;link rel=“http://gdata.youtube.com/schemas/2007#video.related” /&gt;<br /> &lt;link rel=“http://gdata.youtube.com/schemas/2007#mobile”/&gt;<br /> &lt;media:group&gt;<br /> &lt;media:contentyt:format=“t” url=“…”/&gt;<br /> &lt;media:thumbnailurl=“…” width=“…” height=“…”/&gt;<br /> &lt;yt: duration /&gt;<br /> &lt;yt:videoid /&gt;<br /> &lt;/ media:group &gt;<br />&lt;/entry&gt;<br />
  41. 41. Authentication<br />AuthSub – YouTube Authentication with “callback” API [difficult]<br />OAuth – Standardized Approach (similar in nature to OpenID) [most difficult]<br />ClientLogin – Custom Authentication – you call YouTube API track token [easiest]<br />
  42. 42. Getting Started<br />Google Developers Key<br />Development Environment<br />Samples<br />
  43. 43. Google Developers Key<br />http://code.google.com/apis/youtube/dashboard/<br />
  44. 44. Development Environment<br />Accessing dev servers<br />Plugging in Developers Key<br />
  45. 45. Getting YouTube Content<br />Standard Feeds<br />Discovering Videos<br />Channels<br />Playlists<br />Displaying Videos<br />
  46. 46. Standard Feeds<br />http://code.google.com/apis/youtube/2.0/reference.html#Standard_feeds<br />Top Rated<br />Top Favorites<br />Most Viewed<br />Most Popular<br />Most Recent<br />Etc…<br />Filter by Time<br />Filter by Region<br />Filter by Category<br />
  47. 47. Discovering Videos<br />Keywords<br />Categories<br />Categories/Keywords<br />Users<br />
  48. 48. Categories<br />http://gdata.youtube.com/schemas/2007/categories.cat<br />&lt;app:categories [namespaces]&gt;<br />&lt;atom:category term=&quot;Film&quot; label=&quot;Film &amp; Animation&quot; xml:lang=&quot;en-US&quot;&gt;<br /> &lt;yt:assignable/&gt;<br /> &lt;yt:browsable<br /> regions=&quot;AU BR CA CZ DE ES FR GB HK IE IL IN IT JP KR MX NL NZ PL PT RU SE TW US&quot;/&gt;<br />&lt;/atom:category&gt;<br />&lt;/app&gt;<br />
  49. 49. Video by Keyword/Tag<br />http://gdata.youtube.com/feeds/api/videos/<br />Append /-/keyword/ to video feed URL<br />Use query string ?category=keyword<br />Not (-) Or (|)<br />/-/Kennedy/-Bobby/-Ted/-Patrick<br />/-/Kennedy/Bobby|Ted|Patrick<br />
  50. 50. Video by Category<br />http://gdata.youtube.com/feeds/api/videos/<br />Append /-/Category/ to video feed URL<br />Use query string ?category=Category<br />Multiple Categories<br />/-/Comedy/Music/Shortmov/<br />?category=Comedy,Music,Shortmov<br />Category ARE case sensitive<br />
  51. 51. Channels<br />http://gdata.youtube.com/feeds/api/channels?v=2<br />Search just like videos using “?q=keywords/tags”<br />&lt;feed [namespaces&gt;<br /> … metadata …<br /> &lt;openSearch:totalResults /&gt;<br /> &lt;openSearch:startIndex /&gt;<br /> &lt;openSearch: itemsPerPage /&gt;<br /> &lt;entry&gt;<br /> &lt;title /&gt;<br /> &lt;summary /&gt;<br /> &lt;gd:feedlinkurl=“…” hitcount=“…”&gt;<br /> &lt;/entry&gt;<br />&lt;/feed&gt;<br />
  52. 52. Playlists<br />http://gdata.youtube.com/feeds/api/playlists/snippets?v=2<br />Searchjustlike a Channel<br />&lt;feed [namespaces&gt;<br /> … metadata …<br /> &lt;openSearch:totalResults /&gt;<br /> &lt;openSearch:startIndex /&gt;<br /> &lt;openSearch: itemsPerPage /&gt;<br /> &lt;entry&gt;<br /> &lt;title /&gt;<br /> &lt;summary /&gt;<br /> &lt;content src=“…”&gt;<br /> &lt;yt:countHint /&gt;<br /> &lt;yt:playlistId /&gt;<br /> &lt;/entry&gt;<br />&lt;/feed&gt;<br />
  53. 53. Displaying Videos<br />JavaScript API<br />Flash API<br />
  54. 54. Interacting with YouTube Content<br />Authentication<br />Comments<br />Ratings<br />Updating<br />Uploading<br />
  55. 55. ClientLogin<br />https://www.google.com/youtube/accounts/ClientLogin<br />Pass in:<br />Email<br />Passwd<br />Receive:<br /> Auth=AIwbFARksypDdUSGGYRI_5v7Z9TaijoPQqpIfCEjTFPAikn_---OC-I1VJtQ<br />YouTubeUser=testuser<br />Send into all requests:<br />Header:<br />Authorization = “GoogleLogin auth= AIwbFARksypDdUSGGYRI_5v7Z9TaijoPQqpIfCEjTFPAikn_---OC-I1VJtQ”<br />
  56. 56. Comments<br />Get Video Feed<br />Look for:<br />&lt;gd:comments&gt;<br />&lt;gd:feedlinkhref=“…” countHint=“…” /&gt;<br />&lt;/gd:comments&gt;<br />Pass in<br />
  57. 57. Ratings<br />Link embeded in the video feed<br />&lt;link rel=&apos;http://gdata.youtube.com/schemas/2007#video.ratings&apos; type=&apos;application/atom+xml&apos; href=&apos;http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/ratings&apos;/&gt;<br />Send back to this URL:<br />&lt;entry [namespaces]&gt;<br /> &lt;gd:rating value=&quot;4&quot; min=&quot;1&quot; max=&quot;5&quot;/&gt;<br />&lt;/entry&gt; <br />
  58. 58. Updating<br />Link embeded in the video feed<br />&lt;link rel=&apos;edit&apos; type=&apos;application/atom+xml&apos; href=&apos;http://gdata.youtube.com/feeds/api/users/andyland74/uploads/914IMX9RSTE&apos;&gt; <br />Send Back to this URL:<br />&lt;entry [namespaces]&gt;<br />&lt;media:group&gt;<br /> &lt;media:title type=“…“ /&gt;<br /> &lt;media:description type=“…“ /&gt;<br /> &lt;media:category scheme=“…“ /&gt;<br /> &lt;media:keywords /&gt;<br />&lt;/media:group&gt; <br />&lt;/entry&gt; <br />
  59. 59. Uploading<br />http://uploads.gdata.youtube.com/feeds/api/users<br />Include in Header<br />Authentication<br />Slug (filename)<br />Include in Body<br />Video File<br />&lt;entry [namespace]&gt;<br /> &lt;media:group&gt;<br /> &lt;media:title type=”...” /&gt;<br /> &lt;media:description type=“…“ /&gt;<br /> &lt;media:keywords /&gt;<br /> &lt;media:categoryscheme=“…“ /&gt;<br />&lt;/media:group&gt;<br />&lt;/entry&gt;<br />
  60. 60. Challenges<br />Documentation is poor<br />No true congruity in related links<br />Error messages are non-descriptive<br />
  61. 61. Developer Resources<br />Google Group<br />http://groups.google.com/group/youtube-api-gdata<br />Google Code Help<br />http://code.google.com/support/bin/topic.py?topic=12357<br />
  62. 62. Contact<br />Ron West<br />@notronwest<br />facebook.com/notronwest<br />www.notronwest.com/blog<br />

×