Yelp / yelp-fusion

Yelp Fusion API
https://yelp.com/developers
MIT License
403 stars 394 forks source link

Yelp API is giving me same result even after changing the offset #123

Closed oswal04 closed 7 years ago

oswal04 commented 7 years ago

Hi,

Can someone please help me with yelp api. I am new to this and trying to get data from yelp api and I am using request module from python. I am getting same data from yelp api even after changing the offset.

But when I use Yelp api console, I get different data by changing offset. I am not able to understand exactly what is happening.

Below is the code.

Any help is appreciated. Thanks!!

import rauth import json import requests

consumer_key='' consumersecret='' token='' token_secret=''

session = rauth.OAuth1Session(
consumer_key = consumer_key ,consumer_secret = consumer_secret ,access_token = token ,access_token_secret = token_secret)

fn.new_folder('Restaurants') baseurl ='https://api.yelp.com/v2/search' for x in range(1,100,20): params={'term':'Restaurant','location':'Boston, MA', 'offest':20,'sort':x-1}

request = session.get(baseurl,params=params)
jsn = request.json()
mittonk commented 7 years ago

@oswal04 :

  1. That code belongs to the older V2 API (https://www.yelp.com/developers/documentation/v2/ ), not Fusion (https://www.yelp.com/developers/documentation/v3/ ). If you're just getting started, I'd suggest switching to Fusion now.

  2. Your for loop is changing the sort parameter. I think you want to be varying the offset parameter instead.