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.3.tar.gz
(5.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gnewsio-0.1.3.tar.gz.
File metadata
- Download URL: gnewsio-0.1.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
997b93d623c4c15143fe3393bd76be8a7b94171e3c7481d6e32e66ac87ae3d67
|
|
| MD5 |
ed7091138dc892231db048d042957e88
|
|
| BLAKE2b-256 |
064d1a183688cdc096f78dd7e78ec286116bb8023981cca6ac68344d9ec0345c
|
File details
Details for the file gnewsio-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gnewsio-0.1.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db0dc2167c40fb71bcb5f159abd023f6dacf03f4a101cb4bd594c6fd47c91376
|
|
| MD5 |
9b9532633e769a3a73ae62e1dc3fe37c
|
|
| BLAKE2b-256 |
cdbe879b9294167bc84a67f6b351891eb850ae007eec85800123f47430070e3d
|