Moshe
Moshe

Reputation: 58097

Is there a RESTful YouTube API for iOS?

I'm trying to access YouTube from within an iOS app, but the iOS SDK is a bit outdated and the source is abysmal. I'm trying to access the playlist of a particular account and show it as part of an app.

Is there any API or URL endpoint I can use? Do I need to use the SDK, or can I manually craft HTTP requests using Objective-C? (I'm thinking LRResty or something similar.)

Edit:

Do I need to have an API key to use the RESTful API? If so, how do I obtain one?

Upvotes: 15

Views: 12844

Answers (5)

felixwcf
felixwcf

Reputation: 2107

I can give you the example about grabbing youtube channel public activities feed(comments, likes, uploads...) in json forma, without going through login authentication.

  1. Login your Google account and go to https://code.google.com/apis/console to create an API project.
  2. Select Create Another Client ID, select Installed Application (iOS), insert your redirect URL and press Create.
  3. Go to Service(left grey panel), and go to the bottom of page to enable YouTube Data API v3 service.
  4. In your Xcode, by using iOS native HTTP protocol, you can just grab the user's channel activities feed by requesting the API: https://www.googleapis.com/youtube/v3/activities?channelId=YOUR_CHANNEL_ID&key=YOUR_API_KEY&part=snippet,contentDetails

  5. You will get a bunch of data. For video feed, you'll see there's a "videoId". Grab it by using your json-dictionary parser and requesting the API for video: https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID&key=YOUR_API_KEY&part=player and you will get the video URL in the json "embedHtml" parameter!

  6. Use your native iOS video player to play the video.

API Parameter Reference: https://developers.google.com/youtube/v3/docs/channels/list Video API parameter Reference: https://developers.google.com/youtube/v3/docs/videos/list

Upvotes: 4

Kim
Kim

Reputation: 1918

You can do that with RESTful way with YouTube Data API.

Here is working example which uses it.

Upvotes: 4

Looks like there is a new Objective-C api to use google's JSON services: http://code.google.com/p/google-api-objectivec-client/

Upvotes: 3

MobileOverlord
MobileOverlord

Reputation: 4610

I'm not sure if this is the SDK you are talking about being outdated, but the GDataLibrary for Objective-C can make the connections for you.

http://code.google.com/p/gdata-objectivec-client/

I have been using it to make connections to Google Spreadsheets and its been working pretty well. You can choose to implement select services from the Project so it doesn't weigh your project down at compile time with code that doesn't mean anything to you.

I believe that this library is a pretty looking wrapper for Google Services API's in Objective-C

Here is information on how to set it up for use with your project.

GData Introduction

Upvotes: 3

Noah Witherspoon
Noah Witherspoon

Reputation: 57149

Yep: you want the Youtube Data API, probably the playlist feed. Standard HTTP requests will work fine.

Upvotes: 11

Related Questions