A Python client to interact with News API from NewApi.org
Project description
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
Create a secrets.json file in the base directory of the project with the following structure:
{
"NEWS_API_KEY": "YOUR_NEWS_API_KEY"
}
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.
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
Built Distribution
Hashes for newsapi-python-client-0.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ab4baa4db75cbc65fb5f658ab1061691f427467fab28022a7157ae49236b8ce |
|
MD5 | f1089dda4a9534f53e1744d240fa0dce |
|
BLAKE2b-256 | 526c86b12dbc11d49e0b39a8d32a2d925ef5f798c11b21c75b878c7605b3efd3 |
Hashes for newsapi_python_client-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d459ae9845a2d0d931729c6663eae96145ac7d3e7cd8798911c916f666a451 |
|
MD5 | c7fba3c1c9c4f6da50ccb04b4060bcd0 |
|
BLAKE2b-256 | 6d211d2d915274c8a9c37b882785ead361cfa12c8069cc93e52b18bbaf65e72c |