emrecncelik / yemeksepeti_api

Yemeksepeti unofficial API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yemeksepeti API

This repository contains code for Yemeksepeti unofficial API. The project aims to help provide educators/researchers with the tools they need to gather data and demonstrate analysis methodologies with real-world datasets. The API interactions has been reverse enginereed from the mobile client. You can search provinces, areas, restaurants and get reviews for restaurants using this code.

Quickstart

pip install git+https://github.com/e4c6/yemeksepeti_api.git

At this point, you're ready to use the script.

import yemeksepeti_api
import random

All you need to do is import the api, but we import random for demonstration purposes.

api = YemeksepetiApi()
catalogs = api.get_catalogs()
random_city = random.choice(catalogs)

print(random_city['CatalogName'])
>> TR_VAN

Catalogs are provinces, they store various information regarding the province. We need the catalog name to search areas belonging to the province. Their ids correspond to the license plate numbers. However we use their names to find which areas belong to them.

van_areas = api.get_catalog_areas("TR_VAN")
random_area = random.choice(van_areas)

print(random_area['Name'])
>> Edremit (Eminpaşa Mah. - Havalimanı) 
print(random_area['Id'])
>> 717c73d8-5748-4a2b-a467-3af94d9e3ddc

Each area has it's unique id and it's city id. We need the unique id to search for restaurants belonging to an area.

edremit_restaurants = api.search_restaurants(catalog="TR_VAN", 
                                            area_id="717c73d8-5748-4a2b-a467-3af94d9e3ddc")

random_restaurant = random.choice(edremit_restaurants)
print(random_restaurant['DisplayName'])
>> Akdeniz Tantuni, Çarşı
print(random_restaurant['MainCuisineName'])
>> Kebap & Türk Mutfağı
print(random_restaurant['CategoryName'])
>> bea5c4cf-d779-48bb-9c12-25ce1da5dc46

Restaurants too have their unique ids under the "CategoryName" key. We need this id if we'd like to see their reviews.

akdeniz_tantuni_reviews = api.get_restaurant_reviews(catalog="TR_VAN", 
                                                    area_id="717c73d8-5748-4a2b-a467-3af94d9e3ddc",
                                                    category_name="bea5c4cf-d779-48bb-9c12-25ce1da5dc46")
random_review = random.choice(akdeniz_tantuni_reviews)
print(random_review['Comment'])
>> Abi asiri hizliydi ya vanin en hizli restorani olabilir.
print(random_review['CommentDate'])
>> 2020-03-26 19:05:26.717000
print(random_review['Flavour'], random_review['Serving'], random_review['Speed'])
>> 7 9 10

Reviews include their scores, date and comment text and various other information.

Data Dump

  • 3,536,968 records
  • Raw 1.6GB
  • New line delimited JSON dump
    • Link 1: Compressed with zstd (191.5MB)

Parsed Sample:

Comment CommentDate Flavour RestaurantDisplayName Serving Speed Status CommentType AreaName AvgRestaurantScore CatalogName
Gayet güzeldi, memnunuyetle sipariş verebilirsiniz. 2020-03-15T16:49:07.570Z 9 Değer Kebap, Kurtuluş Mah. 9 10 Onaylandı UserComment Uşak (Ünalan Mah.) 9,0 TR_USAK

Raw Sample:

{"Comment":"Gayet güzeldi, memnunuyetle sipariş verebilirsiniz.","CommentDate":"2020-03-15T16:49:07.570Z","Flavour":"9","RestaurantDisplayName":"Değer Kebap, Kurtuluş Mah.","Serving":"9","Speed":"10","Status":"Onaylandı","CommentType":"UserComment","AreaName":"Uşak (Ünalan Mah.)","AvgRestaurantScore":"9,0","CatalogName":"TR_USAK"}

About

Yemeksepeti unofficial API.

License:GNU General Public License v3.0


Languages

Language:Python 100.0%