Skip to content
Juan Roldán edited this page Jul 16, 2019 · 26 revisions

MovieQuotes wiki

Usage

To start using the gem, you should get an API Key (free). Please send an email to [email protected]

Setup the API Key within an initializer:

# movie_quotes_initializer.rb

MovieQuotes.configure do |config|
  config.api_key = "abcd1234"
end

Then create a new filter instance like so:

filter = MovieQuotes.new

and then set filters, for instance, to fetch well known movie quotes from actors like Al Pacino:

filter.by_actor("al pacino")

or quotes from charachters like morpheus:

filter.by_character("morpheus")

or chain filters to get quotes from movies like Die Hard and actors like Bruce Willis:

filter.by_movie("die hard").by_actor("bruce willis")

Once applied all the filters you need, make the API call to get the quotes:

filter.results

API Methods

All methods are chainable, they can be applied one after another to conform the desired request.

To retrieve well known quotes from movies, API methods available so far are:

Quotes filtered by actors:

filter.by_actor("bruce willis")
# or use the slug
filter.by_actor("bruce-willis")

Quotes filtered by categories (genre):

filter.by_category("action")

# "OR" behavior when multiple categories are applied
filter.by_category(["action", "crime", "drama"])

Quotes filtered by characters:

filter.by_character("morpheus")

Quotes filtered by content or pieces of quotes:

filter.by_content("no spoon")

Quotes filtered by movies:

filter.by_movie("the matrix")

Since results are paginated by 20 items each page, quotes can also be filtered by page:

filter.by_page(1)
# or
filter.by_page("1")

Quotes filtered by years:

filter.by_year(1999)

# "OR" behavior when multiple years are applied
filter.by_year([1999, 2005])

# "OR" behavior when multiple years are applied
filter.by_year(["1999", "2005"])

Quotes filtered by rating (from 1(worst) to 10(best)):

filter.by_rating(10)
# or
filter.by_rating("10")

Quotes fetched randomly:

# A single quote is picked randomly and returned to client.
filter.by_random

# or 
# A single quote is picked randomly and returned to client.
filter.by_random(1)
filter.by_random("1")

# or
# Four quotes are picked randomly and returned to client.
filter.by_random(4)
filter.by_random("4")

Quotes fetched by multiple scopes at once:

filter.by_multiple("take")

Response

The response format is JSON by default. Results are provided as an array of objects with the following structure:

Filtering well known quotes by movies like Die Hard and actors like Bruce Willis:

movie_quotes die hard
filter = MovieQuotes.new
filter.by_movie("die hard").by_actor("bruce willis")
filter.results
=> [
  {
    "content": "Yippie-ki-yay, motherfucker!",
    "rating": 5,
    "year": 1988,
    "categories": [
      "Thriller",
      "Crime",
      "Action"
    ],
    "image_large_url": "https://i.ytimg.com/vi/YfpDSNNgYhI/hqdefault.jpg",
    "image_thumb_url": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRlniyMNhCV4h8UF9zn6Lka4s-OTU_j7Br43Kp5OR7eGljOAIpDXKystfQ",
    "movie": {
      "title": "Die Hard",
      "slug": "die-hard"
    },
    "character": {
      "name": "John Mc Clane",
      "slug": "john-mc-clane"
    },
    "actor": {
      "name": "Bruce Willis",
      "slug": "bruce-willis"
    }
  }
]

Filtering well known quotes by actors like Al Pacino:

movie_quotes
filter = MovieQuotes.new
filter.by_actor("al pacino")
# "slug" can also be used to make searches more accurate
# filter.by_actor("al-pacino")
filter.results
=> [
  {
    "content":"Keep your friends close, but your enemies closer.",
    "rating": 5,
    "year":1974,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/DfHJDLoGInM/hqdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHyFYb7t8Qoniyea8IlFDvte0hvB8wzPBQWenC8hV_oMUudfiWlAzDEXgW",
    "movie":{
      "title":"The Godfather Part Ii",
      "slug":"the-godfather-part-ii"
    },
    "character":{
      "name":"Michael Corleone",
      "slug":"michael-corleone"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  },
  {
    "content":"Say 'hello' to my little friend!",
    "rating": 5,
    "year":1983,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/a_z4IuxAqpE/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRiQEnHHPSvib02Te1fLCBaEyzMlkpK1Fomc7wFwu0lt6FZxv-gUavr6XeA",
    "movie":{
      "title":"Scarface",
      "slug":"scarface"
    },
    "character":{
      "name":"Tony Montana",
      "slug":"tony-montana"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  },
  {
    "content":"Attica! Attica!",
    "rating": 2,
    "year":1975,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/3Bw1a_O2m48/hqdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_KsKyBtUFczLtAAQ3FbI3r6GeZcJNRQwyzIhADEBCU641nS5mKSvb7Uc7",
    "movie":{
      "title":"Dog Day Afternoon",
      "slug":"dog-day-afternoon"
    },
    "character":{
      "name":"Sonny Wortzik",
      "slug":"sonny-wortzik"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  },
  {
    "content":"I know it was you, Fredo. You broke my heart. You broke my heart.",
    "rating": 4,
    "year":1974,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/DjUOBVAbGhQ/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTmMdvXj_n5yv35xvfK1HniKaYEK6b0QE9HUxMjKmrRc2qp0GOy22OcZq8",
    "movie":{
      "title":"The Godfather: Part Ii",
      "slug":"the-godfather-part-ii-1b8f0ac8-2fee-4b93-9db7-41b101fbd6bc"
    },
    "character":{
      "name":"Michael Corleone",
      "slug":"michael-corleone"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  },
  {
    "content":"Keep your friends close, but your enemies closer.",
    "rating": 5,
    "year":1974,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/DfHJDLoGInM/hqdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHyFYb7t8Qoniyea8IlFDvte0hvB8wzPBQWenC8hV_oMUudfiWlAzDEXgW",
    "movie":{
      "title":"The Godfather: Part Ii",
      "slug":"the-godfather-part-ii-1b8f0ac8-2fee-4b93-9db7-41b101fbd6bc"
    },
    "character":{
      "name":"Michael Corleone",
      "slug":"michael-corleone"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  },
  {
    "content":"Hoo-ah!",
    "rating": 3,
    "year":1992,
    "categories":[
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/7oXtISrMwVc/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRRZNSQQDNYBTI5-0m_dayn1FWFu3_zlJd4_kNKkq48yiQ62vlWUH9Nl8G7",
    "movie":{
      "title":"Scent Of A Woman",
      "slug":"scent-of-a-woman"
    },
    "character":{
      "name":"Lt. Col. Frank Slade",
      "slug":"lt-col-frank-slade"
    },
    "actor":{
      "name":"Al Pacino",
      "slug":"al-pacino"
    }
  }
]

Filtering well known quotes by movie categories like crime and drama and years 1976 and 1991:

movie_quotes
filter = MovieQuotes.new
filter.by_category(["crime", "drama"]).by_year([1976, 1991])
filter.results
=> [
  {
    "content":"You talkin' to me?",
    "rating": 5,
    "year":1976,
    "categories":[
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/-QWL-FwX4t4/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQsrFYpPUa_qLZqvjL53JrBsWSLlfYBaC5qiXdNhDSTZZysA2U_IaK03HG3",
    "movie":{
      "title":"Taxi Driver",
      "slug":"taxi-driver"
    },
    "character":{
      "name":"Travis Bickle",
      "slug":"travis-bickle"
    },
    "actor":{
      "name":"Robert De Niro",
      "slug":"robert-de-niro"
    }
  },
  {
    "content":"A census taker once tried to test me. I ate his liver with some fava beans and a nice Chianti.",
    "rating": 5,
    "year":1991,
    "categories":[
      "Thriller",
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/M1b2v_Lls3A/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQO6iO860KO8e6Qmuv_ogCKdHXdo5CgWpPioU6CF9g5FSoqbQNoXPccQJo",
    "movie":{
      "title":"The Silence Of The Lambs",
      "slug":"the-silence-of-the-lambs"
    },
    "character":{
      "name":"Dr. Hannibal Lecter",
      "slug":"dr-hannibal-lecter"
    },
    "actor":{
      "name":"Anthony Hopkins",
      "slug":"anthony-hopkins"
    }
  },
  {
    "content":"I do wish we could chat longer, but I'm having an old friend for dinner.",
    "rating": 5,
    "year":1991,
    "categories":[
      "Thriller",
      "Crime",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/sbJ89LFheTs/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRnGtsUwpoCc-5nw_zznRS2615ZafAiESSebcMbC9NoT83Mh5XvnEI0ohg",
    "movie":{
      "title":"The Silence Of The Lambs",
      "slug":"the-silence-of-the-lambs"
    },
    "character":{
      "name":"Dr. Hannibal Lecter",
      "slug":"dr-hannibal-lecter"
    },
    "actor":{
      "name":"Anthony Hopkins",
      "slug":"anthony-hopkins"
    }
  },
  {
    "content":"I'm as mad as hell, and I'm not going to take this anymore!",
    "rating": 5,
    "year":1976,
    "categories":[
      "Biography",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/ZwMVMbmQBug/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTsFCb5V4pS0taLWJwiZTDhZXD_qzzVgtmALirHoHLbicudOGFuZew-ujhH",
    "movie":{
      "title":"Network",
      "slug":"network"
    },
    "character":{
      "name":"Howard Beale",
      "slug":"howard-beale"
    },
    "actor":{
      "name":"Peter Finch",
      "slug":"peter-finch"
    }
  },
  {
    "content":"Yo, Adrian!",
    "rating": 5,
    "year":1976,
    "categories":[
      "Sport",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/WgScBiXkO9Y/hqdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQF_Rd6Z3208kVy83_1LvvJsXUme4XMVQkejNadWsF4DzbIbgcyL-Z0rP4",
    "movie":{
      "title":"Rocky",
      "slug":"rocky"
    },
    "character":{
      "name":"Rocky Balboa",
      "slug":"rocky-balboa"
    },
    "actor":{
      "name":"Sylvester Stallone",
      "slug":"sylvester-stallone"
    }
  },
  {
    "content":"Follow the money.",
    "rating": 2,
    "year":1976,
    "categories":[
      "History",
      "Mystery",
      "Drama"
    ],
    "image_large_url":"https://i.ytimg.com/vi/vETxuL7Ij3Q/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRc2vS39RMwLOy9tAZ7N7wih6sQ23vGcu0Q-OE2zTKworLmbANxDIG6sxo",
    "movie":{
      "title":"All The President's Men",
      "slug":"all-the-president-s-men"
    },
    "character":{
      "name":"Deep Throat",
      "slug":"deep-throat"
    },
    "actor":{
      "name":"Hal Holbrook",
      "slug":"hal-holbrook"
    }
  },
  {
    "content":"Why don't you go outside and jerk yourself a soda?",
    "rating": 1,
    "year":1991,
    "categories":[
      "Family",
      "Comedy",
      "Crime"
    ],
    "image_large_url":"https://s-media-cache-ak0.pinimg.com/236x/80/3c/85/803c85322a9d28826ed645e8fb9d63d3.jpg",
    "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS4Fuuxe4sCVr4kgW4AioE69z39i60EYh6Pf7AQuANWZ98mFOlM7ITy7w",
    "movie":{
      "title":"Bugsy",
      "slug":"bugsy"
    },
    "character":{
      "name":"Virginia Hill",
      "slug":"virginia-hill"
    },
    "actor":{
      "name":"Annette Bening",
      "slug":"annette-bening"
    }
  },
  {
    "content":"Does your dog bite?",
    "rating": 3,
    "year":1976,
    "categories":[
      "Comedy",
      "Crime"
    ],
    "image_large_url":"https://cinemafanatic.files.wordpress.com/2010/08/pinkpantherstrikesagain.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQFNBT4DfEJJKSfDUouaQhWWJjuoi1KmuKYFOQNFz413z5-rEwsY1acAuI",
    "movie":{
      "title":"The Pink Panther Strikes Again",
      "slug":"the-pink-panther-strikes-again"
    },
    "character":{
      "name":"Chief Insp. Jacques Clouseau",
      "slug":"chief-insp-jacques-clouseau"
    },
    "actor":{
      "name":"Peter Sellers",
      "slug":"peter-sellers"
    }
  }
]

Filtering well known quotes by characters like Harry Callahan:

movie_quotes
filter = MovieQuotes.new
filter.by_character("harry callahan")
filter.results
=> [
  {
    "content":"Go ahead, make my day.",
    "rating": 5,
    "year":1983,
    "categories":[
      "Thriller",
      "Action"
    ],
    "image_large_url":"https://i.ytimg.com/vi/n_SU-cJFRjs/hqdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQn33w-E743mL3L-ar6uI9vzE9Nu8wRE_d8UkQsDcT5vCpjWUH5TfP6szOA",
    "movie":{
      "title":"Sudden Impact",
      "slug":"sudden-impact"
    },
    "character":{
      "name":"Harry Callahan",
      "slug":"harry-callahan"
    },
    "actor":{
      "name":"Clint Eastwood",
      "slug":"clint-eastwood"
    }
  },
  {
    "content":"You've got to ask yourself one question: 'Do I feel lucky?' Well, do ya, punk?",
    "rating": 5,
    "year":1971,
    "categories":[
      "Thriller",
      "Crime",
      "Action"
    ],
    "image_large_url":"https://i.ytimg.com/vi/8Xjr2hnOHiM/maxresdefault.jpg",
    "image_thumb_url":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTgtJip8s8q3PZ2O9mxmpVwMBsndKmFKAVJ--Oca1b6WlznU8BpTUD-Xg4",
    "movie":{
      "title":"Dirty Harry",
      "slug":"dirty-harry"
    },
    "character":{
      "name":"Harry Callahan",
      "slug":"harry-callahan"
    },
    "actor":{
      "name":"Clint Eastwood",
      "slug":"clint-eastwood"
    }
  }
]

Filtering quotes which contain the word take on their content OR movie title OR actor name OR character name OR categories:

movie_quotes
filter = MovieQuotes.new
filter.by_multiple("take")
filter.results
=> [
   {  
      "content":"They may take our lives, but they'll never take our freedom!",
      "year":1995,
      "categories":[  
         "Biography",
         "Drama",
         "Action"
      ],
      "image_large_url":"https://i.ytimg.com/vi/BcZ-DaRkj5g/maxresdefault.jpg",
      "image_thumb_url":"https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRa7cBYH2OadLo8-D6ugY_jAYxaSmFY5lXSbuTuiKsflonMVXj7Ms4VGU8",
      "rating":10,
      "movie":{  
         "title":"Braveheart",
         "slug":"braveheart"
      },
      "character":{  
         "name":"William Wallace",
         "slug":"william-wallace"
      },
      "actor":{  
         "name":"Mel Gibson",
         "slug":"mel-gibson"
      }
   },
   {  
      "content":"A census taker once tried to test me. I ate his liver with some fava beans and a nice Chianti.",
      "year":1991,
      "categories":[  
         "Thriller",
         "Crime",
         "Drama"
      ],
      "image_large_url":"https://i.ytimg.com/vi/M1b2v_Lls3A/maxresdefault.jpg",
      "image_thumb_url":"https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQO6iO860KO8e6Qmuv_ogCKdHXdo5CgWpPioU6CF9g5FSoqbQNoXPccQJo",
      "rating":10,
      "movie":{  
         "title":"The Silence Of The Lambs",
         "slug":"the-silence-of-the-lambs"
      },
      "character":{  
         "name":"Dr. Hannibal Lecter",
         "slug":"dr-hannibal-lecter"
      },
      "actor":{  
         "name":"Anthony Hopkins",
         "slug":"anthony-hopkins"
      }
   },
   {  
      "content":"Leave the gun. Take the cannolis.",
      "year":1972,
      "categories":[  
         "Crime",
         "Drama"
      ],
      "image_large_url":"https://i.ytimg.com/vi/35fLKn2Tq3o/hqdefault.jpg",
      "image_thumb_url":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRaL2_UrrtdUlEX4TmLww_azWQpX4qfLDB2YYpv552S2GAqjiulzSgcnAEe",
      "rating":8,
      "movie":{  
         "title":"The Godfather",
         "slug":"the-godfather"
      },
      "character":{  
         "name":"Pete Clemenza",
         "slug":"pete-clemenza"
      },
      "actor":{  
         "name":"Richard S. Castellano",
         "slug":"richard-s-castellano"
      }
   },
   {  
      "content":"If you let my daughter go now, that'll be the end of it. I will not look for you, I will not pursue you. But if you don't, I will look for you, I will find you, and I will kill you.",
      "year":2008,
      "categories":[  
         "Thriller",
         "Crime",
         "Action"
      ],
      "image_large_url":"https://cdn.meme.am/instances/36649014.jpg",
      "image_thumb_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSrBlvDKjs3w_xKtiXSbdY6wSr3MUK37nGtYM5jSgxyhCI75_J-LhO3FQ",
      "rating":10,
      "movie":{  
         "title":"Taken",
         "slug":"taken"
      },
      "character":{  
         "name":"Bryan Mills",
         "slug":"bryan-mills"
      },
      "actor":{  
         "name":"Liam Neeson",
         "slug":"liam-neeson"
      }
   }
]

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running bundle and rake.

Copyright

Copyright © 2019 Juan Roldan. See LICENSE.txt for further details.

Clone this wiki locally