Skip to main content

The news client written in Python that fetches and curates the world news across the web.

Project description

Newspy

The news client written in Python that fetches and curates the world news across the web.


PyPI - Version GitHub PyPI - Python Version Static Badge Codecov GitHub Workflow Status (with event)


Table of contents

Requirements

  • 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 Sources

Basic usage

Create virtual environment

python -m venv .venv

# Activate virtual environment
.venv/bin/activate # Linux or MacOS
.venv/Script/activate # Windows


# Install
pip install newspy

RSS feeds client

Get available news sources from RSS feeds

from newspy import rss

rss_sources = rss.get_sources()
print(rss_sources)

Get articles from RSS feeds

rss_articles = rss.get_articles()
print(rss_articles)

Newsorg client

Configure your Newsorg API key

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)

Get available news sources from Newsorg

from newspy import newsorg

newsorg_sources = newsorg.get_sources()
print(newsorg_sources)

Get articles from Newsorg

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)

Newspy client

The newspy client makes it convenient to get articles from both the RSS feeds and Newsorg APIs.

Configure your Newsapi API key

import newspy.client as newspy

newsorg_api_key = "YOUR_NEWSORG_KEY"
newspy.configure(newsorg_api_key=newsorg_api_key)

Get available news sources from both RSS feeds and Newsorg

import newspy.client as newspy

news_sources = newspy.get_sources()
print(news_sources)

Get articles from both RSS feeds and Newsorg

import newspy.client as newspy

news_articles = newspy.get_articles()
print(news_articles)

Examples

See the examples directory for more examples.

Contributing

Want to contribute? Read our contribution guideline.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newspy-2.2.9.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

newspy-2.2.9-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file newspy-2.2.9.tar.gz.

File metadata

  • Download URL: newspy-2.2.9.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for newspy-2.2.9.tar.gz
Algorithm Hash digest
SHA256 ea9e9c1fc6999fcaf4debcfff774c07343aca96924b7e7849b80b745b60fa9c7
MD5 4996bcf2e8098354693c72606c5ac31e
BLAKE2b-256 4a6004e130b5e5e99eb4b08ea2c8ad0b35bc4ce4d014835de3c04df5b7e1d25d

See more details on using hashes here.

File details

Details for the file newspy-2.2.9-py3-none-any.whl.

File metadata

  • Download URL: newspy-2.2.9-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for newspy-2.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2d96823d20beb8c27ab163d0416cd1ac8c8f90b4c353f09a8127bc8eb022f835
MD5 1b2d8db0cc9de4dd6f4be41b258dd4f8
BLAKE2b-256 5333b3b36b601e14a11dfce96016b14a93f3c481b9175aaad2aad45f3024cde8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page