Skip to content
George Kye edited this page Mar 9, 2016 · 12 revisions

Get the primary information about a TV series by id.

     TVMDB.tv(apikey, tvShowID: 870, language: "en"){
            apiReturn in
            if( apiReturn.error == nil){
                let tv = apiReturn.MBDBReturn as! TVDetailedMDB
                print(tv.name)
                print(tv.last_air_date)
                print(tv.seasons)
            }
        }

Get the alternative titles for a specific show ID.

        TVMDB.alternativeTitles(apikey, tvShowID: 60735){
            apiReturn in
            let altTitles = apiReturn.MBDBReturn as! Alternative_TitlesMDB
            print(altTitles.titles[0])
            print(altTitles.id)
        }

Get the content ratings for a specific TV show id.

 TVMDB.content_ratings(apikey, tvShowID: 1396){
            apiReturn in
            let ratings = apiReturn.MBDBReturn as! [Content_RatingsMDB]
            for rating in ratings {
                print(rating.iso_3166_1)
                print(rating.rating)
            }
        }

Get the cast & crew information about a TV series. Just like the website, this information is from the last season of the series.

  TVMDB.credits(apikey, tvShowID: 1396){
            apiReturn in
            let castCrew = apiReturn.MBDBReturn as! TVCreditsMDB
            for crew in castCrew.crew{
                print(crew.job)
                print(crew.name)
                print(crew.department)
            }
            for cast in castCrew.cast{
                print(cast.character)
                print(cast.name)
                print(cast.order)
            }
        }

Get the external ids that we have stored for a TV series.

   TVMDB.externalIDS(apikey, tvShowID: 1396, language: "en"){
            apiReturn in
            let exIds = apiReturn.MBDBReturn as! ExternalIdsMDB
            print(exIds.freebase_id)
            print(exIds.imdb_id)
            print(exIds.tvrage_id)
            print(exIds.id)
            
        }

Get the images (posters and backdrops) for a TV series.

    TVMDB.images(apikey, tvShowID: 60735, language: "en"){
            apiReturn in
            let tvImages = apiReturn.MBDBReturn as! ImagesMDB
            print(tvImages.backdrops[0].height)
            print(tvImages.posters[0].file_path)
        }

Get the plot keywords for a specific TV show id.

       TVMDB.keywords(apikey, tvShowID: 1396){
            apiReturn in
            let keywords = apiReturn.MBDBReturn as! [KeywordsMDB]
            for keyword in keywords{
                print(keyword.id)
                print(keyword.name)
            }
        }

Get the similar TV shows for a specific tv id.

   TVMDB.similar(apikey, tvShowID: 1398, page: 1, language: "en"){
            apiReturn in
            if( apiReturn.error == nil){
                let tv = apiReturn.MBDBReturn as! [TVMDB]
                if(apiReturn.pageResults?.total_results > 0){
                    print(tv[0].name)
                    print(tv[0].genreIds)
                }
            }
        }

Get the list of translations that exist for a TV series. These translations cascade down to the episode level.

  TVMDB.translations(apikey, tvShowID: 1396){
            apiReturn in
            let translations = apiReturn.MBDBReturn as! [TranslationsMDB]
            for translation in translations{
                print(translation.iso_639_1)
                print(translation.english_name)
                print(translation.name)
            }
        }

Get the videos that have been added to a TV series (trailers, opening credits, etc...)

    TVMDB.videos(apikey, tvShowID: 60735, language: "en"){
            apiReturn in
            let videos = apiReturn.MBDBReturn as! [VideosMDB]
            for i in videos {
                print(i.site)
            }
        }

Get the latest TV show id.

   TVMDB.latest(apikey){
            apiReturn in
            if( apiReturn.error == nil){
                let tv = apiReturn.MBDBReturn as! TVDetailedMDB
                print(tv.name)
                print(tv.last_air_date)
                print(tv.seasons)
                print(tv.episode_run_time)
                print(tv.createdBy)
            }
        }

Get the list of TV shows that are currently on the air.
This query looks for any TV show that has an episode with an air date in the next 7 days.

 TVMDB.ontheair(apikey, page: 1, language: "en"){
            apiReturn in
            let tv = apiReturn.MBDBReturn as! [TVMDB]
            print(tv[0].name)
            print(tv[0].popularity)
            print(tv[0].first_air_date)
            print(tv[0].overview)
            print(apiReturn.pageResults?.total_pages)
        }

Get the list of TV shows that air today. Without a specified timezone, this query defaults to EST (Eastern Time UTC-05:00).

           TVMDB.airingtoday(apikey, page: 2, language: "en", timezone: "Asia/Baku"){
            apiReturn in
            let tv = apiReturn.MBDBReturn as! [TVMDB]
            print(tv[0].name)
            print(tv[0].popularity)
            print(tv[0].first_air_date)
            print(tv[0].overview)
            print(apiReturn.pageResults?.total_pages)
        }

Get the list of top rated TV shows. By default, this list will only include TV shows that have 2 or more votes. This list refreshes every day.

                TVMDB.toprated(apikey, page: 1, language: "en"){
                    apiReturn in
                    let tv = apiReturn.MBDBReturn as! [TVMDB]
                    print(tv[0].name)
                    print(tv[0].popularity)
                    print(tv[0].first_air_date)
                    print(tv[0].overview)
                }

Get the list of popular TV shows. This list refreshes every day.

        TVMDB.popular(apikey, page: 1, language: "en"){
            apiReturn in
            let tv = apiReturn.MBDBReturn as! [TVMDB]
            print(tv[0].name)
            print(tv[0].popularity)
            print(tv[0].first_air_date)
            print(tv[0].overview)
        }
Clone this wiki locally