Zomatopy

A Python wrapper for the Zomato API v2.1

Installation

pip install zomatopy

Or download the source code from here, and then just install the package using

python setup.py install

Getting Started

Python Version

This wrapper was written for Python 3 and might not work well with Python 2.

Adding Zomatopy to your application

For use with only user based authentication we can create the following configuration:

import zomatopy

config={
  "user_key":"ZOMATO_API_KEY"
}
    
zomato = zomatopy.initialize_app(config)

Methods

Common

Getting all Category IDs and the category names

category_dictionary = zomato.get_categories()

Getting ID for a particular city

# city_name must be a string without numbers or special characters.

city_ID = zomato.get_city_ID(city_name)

Getting Name for a particular City ID

# city_ID must be an integer.

city_name = zomato.get_city_name(city_ID)

Getting the Zomato Collections in a city

# city_ID must be an integer.
# limit must be an integer.

# Returns all the Zomato Collections in a city
collections_dictionary = zomato.get_collections(city_ID)

# Returns 'limit' number of collections.
collections_dictionary = zomato.get_collections(city_ID, limit=number_of_collections)

Getting the cuisines in a city

# city_ID must be an integer.

cuisine_dictionary = get_cuisines(city_ID)

Getting all establishment types in a city.

# city_ID must be an integer.

establishment_types_dictionary = get_establishment_types(city_ID)

Restaurant

Getting the nearby restaurants

# latitude and longitude must be float or string representation of a float.

restaurant_dictionary = get_nearby_restaurants(latitude, longitude)

Getting the details of a particular restaurant

# restaurant_ID must be an integer.

restaurant_details = get_restaurant(restaurant_ID)

# restaurant_details.name gives the restaurant name.
# restaurant_details.url gives the restaurant Zomato URL.
# restaurant_details.location gives the restaurant location.
# restaurant_details.city gives the restaurant city name.
# restaurant_details.city_ID gives the restaurant city's ID.
# restaurant_details.user_rating gives the restaurant rating.

Searching restaurants based on query, latitude/longitude and/or cuisine IDs

# latitude and longitude must be float or string representation of a float.
# multiple cuisine IDs can be specified by separating with commas. Must be a string.

restaurant_list = restaurant_search(query="Buffet", cuisines="1, 25")

Exceptions

InvalidKey

ValueError: InvalidKey

InvalidCityId

ValueError: InvalidCityId

InvalidCityName

ValueError: InvalidCityName

InvalidRestaurantId

ValueError: InvalidRestaurantId

InvalidLatitudeOrLongitude

ValueError: InvalidLatitudeOrLongitude

LimitNotInteger

ValueError: LimitNotInteger

ApiLimitExceeded

Exception: ApiLimitExceeded