Skip to content
George Kye edited this page Oct 26, 2016 · 14 revisions

Get the basic movie information for a specific movie id.

    MovieMDB.movie(apikey, movieID: 7984, language: "en"){
      apiReturn, movie in
      if let movie = movie{
        print(movie.title)
        print(movie.revenue)
        print(movie.genres[0].name)
        print(movie.production_companies?[0].name)
      }
    }

Get the alternative titles for a specific movie id.

    MovieMDB.alternativeTitles(apikey, movieID: 12, country: nil){
      apiReturn, altTitles in
      if let altTitles = altTitles{
        print(altTitles.titles[0])
        print(altTitles.id)
      }
    }

Get the cast and crew information for a specific movie id.

       MovieMDB.credits(apikey, movieID: 871){
      apiReturn, credits in
      if let credits = credits{
        for crew in credits.crew{
          print(crew.job)
          print(crew.name)
          print(crew.department)
        }
        for cast in credits.cast{
          print(cast.character)
          print(cast.name)
          print(cast.order)
        }
      }
    }

Get the images (posters and backdrops) for a specific movie id.

    MovieMDB.images(apikey, movieID: 871, language: "en"){
      data, imgs in
      if let images = imgs{
        print(images.posters[0].file_path)
        //Backdrop & stills might return `nil`
        // print(images.stills[0].file_path)
        //print(images.backdrops[0].file_path)
      }
    }

Get the plot keywords for a specific movie id.

    MovieMDB.keywords(apikey, movieID: 871){
      apiReturn, keywords in
      if let keywords = keywords{
      print(keywords[0].id)
      print(keywords[0].name)
      }
    }

Get the release dates, certifications and related information by country for a specific movie id.

         MovieMDB.release_dates(apikey, movieID: 293660){
      apiReturn, dates in
      if let releaseDates = dates{
        for releaseDate in releaseDates{
          print(releaseDate.iso_3166_1)
          print(releaseDate.release_dates[0].certification)
          print(releaseDate.release_dates[0].iso_639_1!) //possible nil value
          print(releaseDate.release_dates[0].note!) //possible nil value
          print(releaseDate.release_dates[0].release_date)
          print(releaseDate.release_dates[0].type)
        }
      }
    }

Get the videos (trailers, teasers, clips, etc...) for a specific movie id.

         MovieMDB.videos(apikey, movieID: 607, language: "en"){
      apiReturn, videos in
      if let videos = videos{
        for i in videos {
          //    print(i.site)
          print(i.key)
          print(i.name)
        }
      }
    }

Get the lists that the movie belongs to.

          MovieMDB.list(apikey, movieID: 1396, page: 1, language: "en"){
      apiReturn, lists in
      if let lists  = lists{
        for list in lists{
          print(list.name!)
          print(list.description)
          print(list.item_count)
        }
      }
    }

Get the similar movies for a specific movie id.

        MovieMDB.similar(apikey, movieID: 334, page: 1, language: "en"){
      data, relatedMovies in
      if let movie = relatedMovies{
        print(movie[0].title)
        print(movie[0].original_title)
        print(movie[0].release_date)
        print(movie[0].overview)
      }
    }

Get the translations for a specific movie id.

     MovieMDB.release_dates(apikey, movieID: 293660){
            apiReturn in
            let releaseDates = apiReturn.releatedDates!
            for releaseDate in releaseDates{
                print(releaseDate.iso_3166_1)
                print(releaseDate.release_dates[0].certification)
                print(releaseDate.release_dates[0].iso_639_1) //possible nil value
                print(releaseDate.release_dates[0].note) //possible nil value
                print(releaseDate.release_dates[0].release_date)
                print(releaseDate.release_dates[0].type)
            }
        }

Get the reviews for a particular movie id.

        MovieMDB.reviews(apikey, movieID: 49026, page: 1, language: "en"){
            data in
            print(data.reviews?[0].content)
        }

Get the latest movie id.

      MovieMDB.latest(apikey){
            latestMovies in
            let movie = latestMovies.moviesDetailed!
            print(movie.title)
            print(movie.original_title)
            print(movie.release_date)
            print(movie.overview)
            print(movie.budget)
        }

Get the list of movies playing that have been, or are being released this week. This list refreshes every day.

         MovieMDB.nowplaying(apikey, language: "en", page: 1){
            nowPlaying in
            let movie = nowPlaying.movie!
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }

Get the list of popular movies on The Movie Database. This list refreshes every day.

    MovieMDB.popular(apikey, language: "en", page: 1){
            popularMovies in
            let movie = popularMovies.movie!
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }

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

  MovieMDB.toprated(apikey, language: "en"){
            topRatedMovies in
            let movie = topRatedMovies.movie!
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }

Get the list of upcoming movies by release date. This list refreshes every day.

       MovieMDB.upcoming(apikey, language: "en"){
            upcomingMovies in
            let movie = upcomingMovies.movie!
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }
        

Append to response (Retrieve multiple movie object with one request). Object must be manually initialized using the JSON returned.

    var videos: [VideosMDB]?
    var reviews: [MovieReviewsMDB]?
    MovieMDB.movieAppendTo(apikey, movieID: 49026, append_to: ["videos", "reviews"]){
      data in
      if let json = data.json{
        videos = VideosMDB.initialize(json: json["videos"]["results"])
        reviews = MovieReviewsMDB.initialize(json: json["reviews"]["results"])
      }
    }
Clone this wiki locally