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.22.tar.gz (10.1 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.22-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: newspy-2.2.22.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Linux/6.17.0-1008-azure

File hashes

Hashes for newspy-2.2.22.tar.gz
Algorithm Hash digest
SHA256 05fd7f791161defa7f8257b146293a483fcf41ca255c7316344ea18ec3aef4a8
MD5 3cfe0c41c4b99e8dec89a226061405a5
BLAKE2b-256 da6a783d3422f136eaa83cc995abcc69247cf1d0f59d52b2d6865d54e6e365f8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for newspy-2.2.22-py3-none-any.whl
Algorithm Hash digest
SHA256 3f22bc86924def9ca3ce33ca1df6ba97731ca1fa1439de2a88f3a23fce8efcac
MD5 2d09fa00dbb00e9535c8d45afa46cb2d
BLAKE2b-256 55be9c53fbbf1402d7837921cfd4b32d5f0492904f99b56cb8fd44a45fe48671

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