question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why fusion returns max 50 businesses?

See original GitHub issue

I created a Python script

app_id = 'MYAPPID'													
app_secret = 'MYAPPSECRET'		
data = {'grant_type': 'client_credentials',											
        'client_id': app_id,														
        'client_secret': app_secret}												
token = requests.post('https://api.yelp.com/oauth2/token', data=data)				
access_token = token.json()['access_token']											
url = 'https://api.yelp.com/v3/businesses/search'									
headers = {'Authorization': 'bearer %s' % access_token}								
# Yelp v3 API: https://nz.yelp.com/developers/documentation/v3                      
params = {'cc': args.country,														
		  'location': args.location,												
		  'categories': args.category,												
		  'limit': args.limit}														
response = requests.get(url=url, params=params, headers=headers)					

results = response.json()['businesses']
for business in results:
     print(business['name'])

print '\nTotal Cinemas retrieved: ' , len(results)

that works fine withinput: --country FR --location Paris --category movietheaters --limit 50 and indeed I can return 50 cinemas in Paris. But if I set 51 as limit Python says:

Traceback (most recent call last):
  File "./VISTA.py", line 52, in <module>
    results = response.json()['businesses']
KeyError: 'businesses'

This is a mystery to me as Postman can return 149 businnesses with the query https://api.yelp.com/v3/businesses/search?cc=FR&location=Paris&categories=movietheaters

149

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
tomelmcommented, May 24, 2017

Postman isn’t returning all 149 without an offset. The total you see is the total number of businesses represented in your specific query, that doesn’t mean it’s returning 149 of them.

For using offset, give it any number. If you have limit=50, that means you’re getting results 1-50, so give it offset=51 and you’ll get 51-100.

1reaction
francesco1119commented, May 24, 2017

Thank you, please specify this on the documentation.

Basically is the same as next_page_token for google-API

Read more comments on GitHub >

github_iconTop Results From Across the Web

US Hails Fusion Breakthrough as Energy Dream Takes Shape
After more than 50 years of false starts, nuclear fusion is finally taking a resolute step closer to becoming the world's newest energy ......
Read more >
Service Limits - Oracle Help Center
Review the following service limits for Oracle Integration Generation 2 resources. A service limit is the quota or allowance set on a resource....
Read more >
Nuclear fusion power inches closer to reality
Venture capitalists are pumping billions into companies, racing to get a fusion power plant up and running by the early 2030s.
Read more >
Feds commit $50 million to for-profit nuclear fusion companies
The Department of Energy officially announced that $50 million will go toward private nuclear fusion companies in public-private partnerships.
Read more >
Ignition! Fusion Energy Comes Closer to Being a Reality, With ...
The ASIC chip, believe it or not, boasts an unbelievable 50 billion ... At the moment, there aren't any publicly traded fusion companies....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found