News-API-gh / News-API-python

Our officially supported Python client library for accessing News API.
MIT License
35 stars 9 forks source link

Python's API param issue #6

Open richielo opened 6 years ago

richielo commented 6 years ago

Hi, I am playing with this API using the pageSize and page params to retrieve top headlines on Hong Kong news with a developer account. It doesn't seem to be working. It always returns me 20 news article

Here's my Url: https://newsapi.org/v2/top-headlines?country=hk&pageSize=100&page=2&apiKey=[apiKey]

Am I doing anything wrong here?

Thank you very much for your help in advance

Hadjerkhd commented 5 years ago

Were you able to solve this problem, please ? Because I'm having the same problem here. Even if the results shows this 'totalResults': 6502, , I only get 20 articles.

richielo commented 5 years ago

@Hadjer13 It's been like half a year since I posted this issue. If I remember correctly, I gave up on making this to work. Sorry about that, wish I have a better answer to this

stevenlis commented 4 years ago

I tried with:

import requests

url = 'http://newsapi.org/v2/top-headlines'

params = {}
params['country'] = 'hk'
params['pageSize'] = '100'
params['page'] = '2'
params['apiKey'] = 'API_KEY'

r = requests.get(url, params=params)
print(r.json())

got

{'status': 'error',
 'code': 'maximumResultsReached',
 'message': 'You have requested too many results. Developer accounts are limited to a max of 100 results. You are trying to request results 100 to 200. Please upgrade to a paid plan if you need more results.'}