Closed clone95 closed 3 years ago
Which language are you using? Did you copy and paste from usage under Client libraries > one of languages and run script? Running newsapi.get_sources() and newsapi.get_top_headlines() at the same time won't work and throw error like below:
File "/Users/gwanghyeongim/Documents/py/freeCodeCamp/api_craigdennis/.venv/lib/python3.7/site-packages/newsapi/newsapi_client.py", line 105, in get_top_headlines
raise ValueError("cannot mix country/category param with sources param.")
ValueError: cannot mix country/category param with sources param.
Is this fixed? I see the same error too. Any updates on this?
Per the NewsAPI documentation: Note: you can't mix this param with the country or category params.
.
This library enforces the above rule.
The package is not directly affiliated with the NewsAPI organization, so I would recommend using the example on the README, as I have no ability to update the site's examples.
import config from newsapi import NewsApiClient
newsapi = NewsApiClient(api_key=config.api_key)
top_headlines = newsapi.get_top_headlines(q='Neuralink',sources='the-verge',category='technology',language='en',country='us')
When I run this code it shows the Error: ValueError: cannot mix country/category param with sources param How to fix this?
raise ValueError("cannot mix country/category param with sources param.")