Rotten Tomatoes API for Python

Overview

rottentomatoes.py

rottentomatoes offers an easy-to-use Python wrapper to interact with the Rotten Tomatoes API. Before you try and use the API, make sure you sign up to get an API Key.

Installation

If you have pip installed, then run the following command:

pip install rottentomatoes

You can also run easy_install:

easy_install rottentomatoes

Or, if you want to help develop the package, just git clone the Github repository:

git clone https://github.com/zachwill/rottentomatoes.git

Usage

Without saving your API key as a RT_KEY environment variable:

from rottentomatoes import RT

RT('my_api_key').search('some movie here')

With your API key saved:

from rottentomatoes import RT

RT().search('some movie here')

NOTE: Documentation from this point forward will assume you have saved your Rotten Tomatoes Developer API Key as a RT_KEY environment variable:

$ RT_KEY='my_api_key'
$ echo $RT_KEY

Methods

search

Rotten Tomatoes movie search. Returns a list of dictionaries. Possible keyword arguments include: page and page_limit.

>>> rt = RT()
>>> rt.search('the lion king')
[{'movie': 'here'}, {'movie': 'here'}, ...]

>>> rt.search('fight club', page_limit=2)
[{'movie': 1}, {'movie': 2}]

>>> rt.search('disney', page=2)
[{'movie': 'from second page'}, {'movie': 'from second page'}, ...]

lists

Displays the lists available in the Rotten Tomatoes API.

>>> rt = RT()
>>> rt.lists()
{'links': {'movies': 'http://link-to-movies',
           'dvds': 'http://link-to-dvds'}}

>>> rt.lists('dvds')
{'links': {'new_releases': 'http://link-to-new-releases'}}

>>> rt.lists(directory='dvds')
{'links': {'new_releases': 'http://link-to-new-releases'}}

>>> rt.lists('dvds', 'new_releases')
{'your data': 'is right here'}

>>> rt.lists(directory='dvds', sub='new_releases')
{'your data': 'is right here'}

>>> rt.lists('movies')
{'links': {'box_office': 'http://link-to-box-office-movies',
           'in_theaters': 'http://link-to-movies-in-theaters',
           'opening': 'http://link-to-opening-movies',
           'upcoming': 'http://link-to-upcoming-movies'}

>>> rt.lists('movies', 'box_office')
{'your data': 'is right here'}

>>> rt.lists('movies', 'box_office', page_limit=5)
{'only five': 'box office movies'}

>>> rt.lists('movies', 'opening')
{'your data': 'is right here'}

info

Return info for a movie given its id. Arguments for specific_info include cast and reviews.

>>> rt = RT()
>>> fight_club = '13153'
>>> rt.info(fight_club)
{'your data': 'is right here'}

>>> rt.info(fight_club, 'cast')
{'cast info': 'is right here'}

>>> rt.info(fight_club, 'reviews')
{'reviews': 'are right here'}

new

Short method to return just opened theatrical movies or newly released dvds. Returns a list of dictionaries.

>>> rt = RT()
>>> rt.new('movies')
[{'movie': 'here'}, {'movie': 'here'}, ...]

>>> rt.new('dvds')
[{'dvd': 'here'}, {'dvd': 'here'}, ...]

movies

Short method for returning specific movie lists. Possible sub arguments include: box_office, in_theaters, opening, and upcoming.

>>> rt = RT()
>>> rt.movies('in_theaters', page_limit=5)
{'top five': 'movies in theaters'}

>>> rt.movies('opening', page_limit=5)
{'top five': 'movies opening'}

>>> rt.movies('upcoming', page=2)
{'page 2': 'of upcoming movies'}
```python

* `dvds` -- Short method for returning specific dvd lists. Currently, only one `sub` argument is possible: `new_releases`.
```python
>>> RT().dvds(page_limit=5)
{'only 5': 'newly released dvds'}

feeling_lucky

Similar to Google's I'm Feeling Lucky button. Returns first instance of search term.

>>> RT().feeling_lucky('memento')
{'first result': 'for memento'}

Tests

In order to run the tests for rottentomatoes.py, make sure you have the mock library installed.

Also, all code complies with the PEP 8 Style Guide.

License

Author: Zach Williams

All code released under the Unlicense (a.k.a. Public Domain).

Comments
  • support gzip-encoded responses from the RT api

    support gzip-encoded responses from the RT api

    The Rotten Tomatoes API Forums are full of people complaining about errors while parsing the json result. It looks like there is an error where some of their servers are responding with a gzipped json string.

    urlopen() does not automatically decompress this, so json.loads() gets confused and errors out.

    The changes I've made will first attempt to decompress the string using zlib, and then will deserialize the json from there.

    opened by devrelm 1
  • Support gzip-encoded responses from the RT API

    Support gzip-encoded responses from the RT API

    The Rotten Tomatoes API Forums are full of people complaining about errors while parsing the json result. It looks like there is an error where some of their servers are responding with a gzipped json string.

    urlopen() does not automatically decompress this, so json.loads() gets confused and errors out.

    The changes I've made will first attempt to decompress the string using zlib, and then will deserialize the json from there.

    opened by devrelm 1
  • Preventing API keys from being exposed on Heroku apps

    Preventing API keys from being exposed on Heroku apps

    Ran into a problem where Django was throwing 403 errors from the RT API because Heroku was downloading its own copy of rottentomatoes from pypi — without the filled out rottentomatoes_api_key.py file. One way of solving this is using the RT(key) format, but this introduces a vulnerability by publicly exposing the user's API key in any public git repository.

    My changes still allow for a api_key.py file, but if one is not found it instead uses an RT_KEY environment variable.

    os.environ.get was used to prevent crashing if the library is installed in a temporary directory without RT_KEY with a later check to see if a key was provided.

    opened by alilja 0
  • updates?

    updates?

    Hey Zach~

    no idea if these updates fit your style, but I thought I would at least let you know I'm using your code and making changes ;) (thanks by the way!)

    Mostly I was just going to update to use requests, but I ended up making a lot more changes. I plan on adding some code to cover getting more info from items at some point as well in line with what I do in our netflix wrapper.

    opened by chrisdrackett 0
  • Compatibility fixes for Python 3.5

    Compatibility fixes for Python 3.5

    Hi! I ran into a couple of problems trying to use rottentomatoes with Python 3.5. Everything seems to work now (the tests seem to be passing on both 2.7 and 3.5).

    opened by myedibleenso 1
  • `pip install rottentomatoes` not working in python 3.4

    `pip install rottentomatoes` not working in python 3.4

    I tried this using 2.7 and everything appeared to be working fine, however in python 3.4 I get this error.

    Downloading/unpacking rottentomatoes
      Downloading rottentomatoes-2.1.tar.gz
      Running setup.py (path:/Users/me/.virutalenvs/myapp/build/rottentomatoes/setup.py) egg_info for package rottentomatoes
        Traceback (most recent call last):
          File "<string>", line 17, in <module>
          File "/Users/me/.virutalenvs/myapp/build/rottentomatoes/setup.py", line 8, in <module>
            import rottentomatoes
          File "/Users/me/.virutalenvs/myapp/build/rottentomatoes/rottentomatoes/__init__.py", line 3, in <module>
            from rottentomatoes import RT
        ImportError: cannot import name 'RT'
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 17, in <module>
    
      File "/Users/me/.virutalenvs/myapp/build/rottentomatoes/setup.py", line 8, in <module>
    
        import rottentomatoes
    
      File "/Users/me/.virutalenvs/myapp/build/rottentomatoes/rottentomatoes/__init__.py", line 3, in <module>
    
        from rottentomatoes import RT
    
    ImportError: cannot import name 'RT'
    
    ----------------------------------------
    Cleaning up...
    Command python setup.py egg_info failed with error code 1 in /Users/me/.virutalenvs/myapp/build/rottentomatoes
    Storing debug log for failure in /Users/me/.pip/pip.log
    

    any ideas? Thanks for your work on this project.

    opened by djds23 3
  • added mock to requirements

    added mock to requirements

    Hi Zach,

    This is my first pull request. Lately I have been interested in contributing to projects, so I'm looking to get a start. I added a requirements file to include the mock library, so one may install with pip install -r requirements.txt

    Let me know if it's cool if I contribute a little bit to this project, or let me know if you have any ideas for improvement.

    Thanks,

    • Jim
    opened by jkrooskos 0
Owner
Zach Williams
🏀📊
Zach Williams
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API.

alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API. It allows rapid trading algo development easily, with support for both REST and streaming data interfaces

Alpaca 1.5k Jan 9, 2023
WhatsApp Api Python - This documentation aims to exemplify the use of Moorse Whatsapp API in Python

WhatsApp API Python ChatBot Este repositório contém uma aplicação que se utiliza

Moorse.io 3 Jan 8, 2022
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

null 20 Jun 18, 2022
Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

null 16 Mar 29, 2022
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

wyscoutapi wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3). Usage Install with pip install wyscoutapi. To connect to the Wys

Ben Torvaney 11 Nov 22, 2022
Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Harun Mbaabu Mwenda 46 Sep 1, 2022
A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

TheFarGG 1 Nov 19, 2022
A new coin listing alert bot using Python, Flask, MongoDB, Telegram API and Binance API

Bzzmans New Coin Listing Detection Bot Architecture About Project Work in progress. This bot basically gets new coin listings from Binance using Binan

Eyüp Barlas 21 May 31, 2022
Python API wrapper library for Convex Value API

convex-value-python Python API wrapper library for Convex Value API. Further Links: Convex Value homepage @ConvexValue on Twitter JB on Twitter Authen

Aaron DeVera 2 May 11, 2022
This an API wrapper library for the OpenSea API written in Python 3.

OpenSea NFT API Python 3 wrapper This an API wrapper library for the OpenSea API written in Python 3. The library provides a simplified interface to f

Attila Tóth 159 Dec 26, 2022
YARSAW is an Async Python API Wrapper for the Random Stuff API.

Yet Another Random Stuff API Wrapper - YARSAW YARSAW is an Async Python API Wrapper for the Random Stuff API. This module makes it simpler for you to

Bruce 6 Mar 27, 2022
Python API Client for Twitter API v2

?? Python Client For Twitter API v2 ?? Why Twitter Stream ? Twitter-Stream.py a python API client for Twitter API v2 now supports FilteredStream, Samp

Twitivity 31 Nov 19, 2022
EpikCord.py - This is an API Wrapper for Discord's API for Python

EpikCord.py - This is an API Wrapper for Discord's API for Python! We've decided not to fork discord.py and start completely from scratch for a new, better structuring system!

EpikHost 28 Oct 10, 2022
A simple Python API wrapper for Cloudflare Stream's API.

python-cloudflare-stream A basic Python API wrapper for working with Cloudflare Stream. Arbington.com started off using Cloudflare Stream. We used the

Arbington 3 Sep 8, 2022
Popcorn-time-api - Python API for interacting with the Popcorn Time Servers

Popcorn Time API ?? CONTRIBUTIONS Before doing any contribution read CONTRIBUTIN

Antonio 3 Oct 31, 2022