Coder Social home page Coder Social logo

Comments (4)

harryghgim avatar harryghgim commented on August 31, 2024

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.

from newsapi-python.

thankblitz avatar thankblitz commented on August 31, 2024

Is this fixed? I see the same error too. Any updates on this?

from newsapi-python.

mattlisiv avatar mattlisiv commented on August 31, 2024

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.

from newsapi-python.

SYK-08 avatar SYK-08 commented on August 31, 2024

Python Code

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?

from newsapi-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.