iTunesSearchAPI 1.0

iTunesSearchAPI 1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2018
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Sven Bacia.



iTunesSearchAPI






Simple wrapper for the iTunes Search API written in Swift.

Usage

Basics

To be able to use the iTunes Search API wrapper you need an iTunes client.

iTunes(session: URLSession = URLSession.shared, debug: Bool = false)

When debug is enabled, you get some information about the url which will be requested.

Search

For the most basic search you only have to provide a search term and a completion handler. The result of the search will be passed as a Result containing either the successfully decoded JSON or a SearchError.

itunes.search(for: "Castle") { result in
  // handle the Result<Any, SearchError>
}

Specified Media Type

When you are looking for something specific you can add a specific media type.

itunes.search(for: "Castle", ofType: .tvShow(.tvSeason)) { result in
  // handle the Result<Any, SearchError>
}

Each Media type can take an additional parameter of type Entity. This entity parameter specifies the return type. In the example above we are only looking for TV Seasons of the show Castle.

Lookup

Similar to the search you can use the lookup function. The lookup function takes a LookupType and a completion handler.

itunes.lookup(by: .id("12345")) { result in
  // handle the Result<Any, SearchError>
}

Options

Both search() and lookup() can take an addtitional parameter of type Option. There you can specify information like limit, language or country.

Requirements

  • Swift 4.0
  • iOS 8.4
  • watchOS 2
  • tvOS 9.0
  • OSX 10.10

Installation

Manually

You can also add the specific target manually to your project.

Author

Created and maintained by @svenbacia

License

iTunesSearchAPI is available under the MIT license. See the LICENSE file for more info.