Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Ingrid Elise Rekaa
Ingrid Elise Rekaa
2,268 Points

How to use YouTube API in Swift?

This is unrelated to any course. I am trying to make an app using Swift and want to use a youtube api. I found this page, but it assumes that I am using Cocoa: https://developers.google.com/youtube/v3/guides/ios_youtube_helper

Is there a YouTube api for Swift? Or do I have to combine Swift and Cocoa to make this work?

Can you accept answer?

1 Answer

There isn't a specific APi for any programming language. YouTube will return its query results using JSON. That will contain the data and links to what you want to display. So you will fetch the JSON using NSURLSession and use NSJSONSerialization to parse it. You might also look into using Swifty JSON. It's easier to use. See Github.

Ingrid Elise Rekaa
Ingrid Elise Rekaa
2,268 Points

Thanks for the really quick reply!