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.23.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newspy-2.2.23-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: newspy-2.2.23.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.5 Linux/6.17.0-1013-azure

File hashes

Hashes for newspy-2.2.23.tar.gz
Algorithm Hash digest
SHA256 6db00b7b9b29415101f30053ed011597061d254dc3e1f13ec926a11291ff5739
MD5 e3dc98bdfa42a77aa7cc4d73f0818261
BLAKE2b-256 34555e76250cc85f27ea8c18f27ea58942d8ae2d9d0ac5694a8cb96950b9067c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: newspy-2.2.23-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.5 Linux/6.17.0-1013-azure

File hashes

Hashes for newspy-2.2.23-py3-none-any.whl
Algorithm Hash digest
SHA256 ee8d745f6bfb43492e16f1f2d67a1d594be97c80938e9c0e68938c3baa3b2e39
MD5 4280764fd690265a1573e7da0e319cf9
BLAKE2b-256 13017fa4ec7cd5b20c46254d1f47243d3ed1b00735360b3c8350e9b57081f8a2

See more details on using hashes here.

Supported by

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