/iTunesSearchAPI

Simple iTunes Search API written in Swift

Primary LanguageSwiftMIT LicenseMIT

iTunesSearchAPI

CI Status codecov Version License Platform Carthage compatible

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
  • tvOS 9.0

Installation

Carthage

github "svenbacia/iTunesSearchAPI"

Cocoapods

iTunesSearchAPI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "iTunesSearchAPI"

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.