- Python 3.10+
- Poetry 1.4.0+ (for dependency management)
- yarn (for the semantic-release versioning)
- API Key from the New API Organisation: https://newsapi.org/
- News API. Requires API Key from: https://newsapi.org/
- RSS feeds
python -m venv .venv
# Activate virtual environment
.venv/bin/activate # Linux or MacOS
.venv/Script/activate # Windows
# Install
pip install newspy
from newspy import rss
rss_sources = rss.get_sources()
print(rss_sources)
rss_articles = rss.get_articles()
print(rss_articles)
You can get one here: https://newsapi.org/
import newspy.client as newspy
newsorg_api_key = "YOUR_NEWSORG_KEY"
newspy.configure(newsorg_api_key=newsorg_api_key)
from newspy import newsorg
newsorg_sources = newsorg.get_sources()
print(newsorg_sources)
from newspy import newsorg
from newspy.newsorg.models import NewsorgEndpoint
newsorg_articles = newsorg.get_articles(
endpoint=NewsorgEndpoint.TOP_HEADLINES,
search_text="bitcoin",
)
print(newsorg_articles)
The newspy client makes it convenient to get articles from both the RSS feeds and Newsorg APIs.
import newspy.client as newspy
newsorg_api_key = "YOUR_NEWSORG_KEY"
newspy.configure(newsorg_api_key=newsorg_api_key)
import newspy.client as newspy
news_sources = newspy.get_sources()
print(news_sources)
import newspy.client as newspy
news_articles = newspy.get_articles()
print(news_articles)
See the examples directory for more examples.
Want to contribute? Read our contribution guideline.