Skip to main content

NewsAPI Python Client

Description

This project provides a Python client for accessing the NewsAPI. It aims to make it easier for developers to integrate news searching capabilities into their applications. Whether you are building a news aggregation service, a stock trading platform that needs financial news, or a social media app that needs to show relevant news to users, this library is for you.

Features

  • Simple and intuitive Python interface to the NewsAPI.
  • Uses the requests library for making HTTP requests.
  • Object-oriented models for request and response data.
  • Supports all parameters of the NewsAPI, including advanced search queries and filtering.
  • Built with flexibility and extensibility in mind, allowing developers to customize it according to their needs.

Installation

pip install newsapi-python-client

Usage

from services.news_service import get_finance_news
from models.request_model import RequestModel

request_model = RequestModel(
    q='finance',
    searchIn='title,content',
    sources='source1,source2',
    domains='domain1.com,domain2.com',
    excludeDomains='excludedomain1.com,excludedomain2.com',
    from_param='2023-05-01T00:00:00',
    to='2023-05-27T23:59:59',
    language='en',
    sortBy='popularity',
    pageSize=100,
    page=1
)

response_model = get_finance_news(request_model)

for article in response_model.articles:
    print(f"Title: {article.title}")
    print(f"URL: {article.url}")
    print("---")

Note: Remember to replace placeholder values in the RequestModel with actual values.

Requirements

  • Python 3.6 or later
  • requests package

Future Plans

  • Improve error handling and validation.
  • Add more examples and use cases.
  • Create more comprehensive documentation.

Contributing

We welcome contributions from the community. Please refer to the CONTRIBUTING.md file for more details.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Download files

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

Source Distribution

newsapi-python-client-0.2.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

newsapi_python_client-0.2.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file newsapi-python-client-0.2.1.tar.gz.

File metadata

  • Download URL: newsapi-python-client-0.2.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for newsapi-python-client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3700c80c0f633f12fd17ffbc389e8363f3b7084bb814e90a50aa896e046dfa2c
MD5 e054340f3f02fa7ec25426f3575e438a
BLAKE2b-256 722728aca6881f46e28e8bfc074b32c1983054905bad3ba24f0b1d05a9159bc9

See more details on using hashes here.

File details

Details for the file newsapi_python_client-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for newsapi_python_client-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 677e69ccb086cdfb23f112b1287c51b89e1f8d636c07fa9a3d8d85dd397b5746
MD5 abe3a8587058b6cf8c0c005c5c567c19
BLAKE2b-256 ab485a537a89bddcc263e09baf8611c05ebebf27ce49a35bc294e46386c4bf34

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