SportNews API SDK
An official Python SDK for the SportNews API, providing streamlined access to real-time sports news. This library allows developers to easily integrate sports news feeds into their Python applications.
Installation
pip install sportnews-api
Usage
from sportnews import SportNewsAPI
# Initialize the client with your API key
api = SportNewsAPI('YOUR_API_KEY')
# Retrieve the latest news
articles = api.get_news(language='fr', size=5)
print("Dernières actualités :")
if articles['items']:
for article in articles['items']:
print(f"Titre: {article['title']}")
print(f"Date: {article['published']}")
print(f"Description: {article['description']}")
print(f"Sport: {article['sport']}")
print("---")
else:
print("Aucun article trouvé")
Searching for Articles
# Search for articles about football from the last 7 days
results = api.search_news(
query="Champions League",
sport="football",
language="en",
size=10
)
if results['items']:
for article in results['items']:
print(f"Titre: {article['title']}")
print(f"Date: {article['published']}")
print(f"Description: {article['description']}")
print(f"Sport: {article['sport']}")
print("---")
else:
print("Aucun résultat trouvé")
Key Features
- Retrieve the latest sports news
- Search articles with advanced filters
- Multilingual support (FR, EN, ES, IT, DE)
- Pagination of results
- Robust error handling
- Automatic parameter validation
- Date-based search for temporal filtering
NewsArticle Object
Each news article returned by the API has the following attributes:
title(str): The title of the article.published(datetime): The publication date.description(str): A brief summary of the article.sport(str): The sport associated with the article.language(str): The language of the article.
Error Handling
The SDK raises a SportNewsAPIError for any issues during API requests. Make sure to handle these exceptions in your application:
from sportnews import SportNewsAPI, SportNewsAPIError
try:
news = api.get_latest_news(language='fr')
except SportNewsAPIError as e:
print(f"An error occurred: {e}")
Supported Languages
- French (
fr) - English (
en) - Spanish (
es) - Italian (
it) - German (
de)
License
This project is licensed under the MIT License.
Running Tests
The SDK includes a suite of unit tests to validate its functionality. Run the following command to execute the tests:
python -m unittest discover tests
Support
- Documentation: https://docs.sportnews-api.com
- Support email: support@sportnews-api.com
Developed and maintained by the SportNews API team.
Release files for sportnews-api 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sportnews_api-0.1.8.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sportnews_api-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / sportnews_api-0.1.8.tar.gz
| Download URL | sportnews_api-0.1.8.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d6bfebb0542c90f8ca5bf90e057207ca86c0dcf15146a647f80452c4d7f8ff4
|
|
BLAKE2b-256 checksum How to use checksums |
d2a27645cf57a0865c8318aabdffe5f09a02fd9a57c319b40001eec3f15509e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / sportnews_api-0.1.8-py3-none-any.whl
| Download URL | sportnews_api-0.1.8-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c83a37cf638577d3b3a41ef8ae83944754408ffa7dfea74b31e5193267287790
|
|
BLAKE2b-256 checksum How to use checksums |
0c6c4ae80a652f97bf39fa7a4b822cd63e5a16b1adc5b3b09e09cb02d68857b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|