Skip to main content

A Python client for the GNews API with category, country, and language filtering

Project description

GNews IO Client

A Python client for the gnews.io APIs that supports category, country, and language filtering.

Installation

pip install gnewsio

Usage

from gnews.client_builder import Gnews
from gnews.enums import Category, Country, Language
from datetime import datetime

gnews_client = (Gnews(api_key="YOUR-API-KEY")
                .set_category(Category.NATION)
                .set_country(Country.UNITED_STATES)
                .set_language(Language.ENGLISH)
                .set_from_date(datetime(2024, 10, 11, 0, 0, 0))  # YYYY-MM-DDThh:mm:ssZ
                .set_to_date(datetime(2024, 10, 11, 23, 59, 59))  # YYYY-MM-DDThh:mm:ssZ
                .build())

try:
    # Fetch the top headlines
    response = gnews_client.fetch_top_headlines()
    print(f"Total Articles: {response.total_articles}")
    for article in response.articles:
        print(article)
except Exception as e:
    print(f"Error: {e}")

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

gnewsio-0.1.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

gnewsio-0.1.5-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file gnewsio-0.1.5.tar.gz.

File metadata

  • Download URL: gnewsio-0.1.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for gnewsio-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2e498c4398b414f3d2968fecd4809108270879fdf15972ea5f25ba3d173dbfec
MD5 30347812c96fb433d95065af12f39f9f
BLAKE2b-256 373ed26626c3cb061f84b2f02ba6b977880afe389c0db6aad59d60e9293d9568

See more details on using hashes here.

File details

Details for the file gnewsio-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: gnewsio-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for gnewsio-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e6a9dcb87bb6c542b021b946e7876dbb2d957a3c0fd54c5332ed0a615faa5d7d
MD5 d497ba36f6ece0c7caee31a49c4c2867
BLAKE2b-256 75ce55a4bb69debbb4183a16048181d87c03bd5e44cdb59c758d6954c6911958

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