py-mediastack
An unofficial python helper package to interact with the mediastack API.
Drawbacks
- No historical Data (I don't have a paid account to test it)
- No News Sources search (I don't have time to implement it)
Feel free to contribute. Make sure that you use the pre-commit hooks.
What can it do ?
It can give you live news updated.
Installation
pip3 install py-mediastack
Usage
Get the api key from here
from mediastack import MediaStack
client = MediaStack("<your-api-key>")
resp = client.get_live_news()
print(resp.pagination)
print(resp.data[0])
Pagination(limit=25, offset=0, count=25, total=10000)
Article(author='Redazione', title='Via agli incontri di quartiere:
primo appuntamento con i residenti di San Lorenzo',
description='Hanno preso il via ieri sera, dalla sala Biasin dove l’Amministrazione ha convocato i residenti del quartiere San Lorenzo, gli ‘Incontri di quartiere’ con cui la Giunta si confronta con i cittadini. Presenti, oltre al Sindaco Gian Francesco Menani, il vicesindaco Camilla Nizzoli e gli assessori Corrado Ruini e Massimo Malagoli, che hanno ascoltato le […]',
url='https://www.bologna2000.com/2021/09/07/via-agli-incontri-di-quartiere-primo-appuntamento-con-i-residenti-di-san-lorenzo/',
image=None,
category='general',
language='it',
country='it',
published_at='2021-09-07T08:32:52+00:00',
source='bologna2000')
The parameters for MediaStack.get_live_news are as follow:
-
sources:Optional[list[str]]-> Use this parameter to include or exclude one or multiple news sources. Example: To include CNN, but exclude BBC:sources=["cnn", "-bbc"] -
categories:Optional[list[str]]Use this parameter to include or exclude one or multiple news categories. Example: To include business, but exclude sports:categories=["business", "-sports"]. -
countries:Optional[list[str]]-> Use this parameter to include or exclude one or multiple countries. Example: To include Australia, but exclude the US:countries=["au", "-us"]. -
languages:Optional[list[str]]-> Use this parameter to include or exclude one or multiple languages. Example: To include English, but exclude German:languages=["en", "-de"]. -
keywords:Optional[str]-> Use this parameter to search for sentences, you can also exclude words that you do not want to appear in your search results. Example: To search for "New movies 2021" but exclude "Matrix":keywords='new movies 2021 -matrix' -
date:Optional[str]-> Use this parameter to specify a date or date range. Example:date=2020-01-01for news on Jan 1st anddate='2020-12-24,2020-12-31'for news between Dec 24th and 31st. -
sort:Optional[str]-> Use this parameter to specify a sorting order. Available values:published_desc(default),published_asc,popularity -
limit:Optional[int]-> Use this parameter to specify a pagination limit (number of results per page) for your API request. Default limit value is 25, maximum allowed limit value is 100. -
offset:Optional[int]-> Use this parameter to specify a pagination offset value for your API request. Example: An offset value of 100 combined with a limit value of 10 would show results 100-110. Default value is 0, starting with the first available result.
The get_live_news methods returns a LiveNewsResponse data class.
It contains the pagination details and the data.
The LiveNewsResponse.pagination is of type Pagination and has the following
attributes.
Pagination.limit-> your pagination limit value.Pagination.offset-> your pagination offset value.Pagination.count-> the results count on the current page.Pagination.total-> the total count of results available.
The LiveNewsResponse.data is a list[Article] and each Article has the following
attributes.
Article.author-> the name of the author of the given news article.Article.title-> the title text of the given news article.Article.description-> the description text of the given news article.Article.url- > the URL leading to the given news article.Article.image-> an image URL associated with the given news article.Article.category-> the category associated with the given news article.Article.language-> the language the given news article is in.Article.country-> the country code associated with the given news article.Article.published_at-> the exact time stamp the given news article was published.Article.source-> the source from which the article was taken
Supported News Categories
- general - Uncategorized News
- business - Business News
- entertainment - Entertainment News
- health - Health News
- science - Science News
- sports - Sports News
- technology - Technology News
Supported Countries
Click Here to see the list of all the supported countries.
Supported Languages
- ar - Arabic
- de - German
- en - English
- es - Spanish
- fr - French
- he - Hebrew
- it - Italian
- nl - Dutch
- no - Norwegian
- pt - Portuguese
- ru - Russian
- se - Swedish
- zh - Chinese
Most of the docs are directly taken from the mediastacks api docs
Metadata
Release files for py-mediastack 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| py-mediastack-0.1.1.tar.gz | 7.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_mediastack-0.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / py-mediastack-0.1.1.tar.gz
| Download URL | py-mediastack-0.1.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
936d8ce97ca8e0714e975464473fc8fb306dfdea0516708a667b3c746886304f
|
|
BLAKE2b-256 checksum How to use checksums |
bac997110ef204579e06451d7e27e323f5e6ed23d15a93d5a1e20dbbc32b1b62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Release files / py_mediastack-0.1.1-py2.py3-none-any.whl
| Download URL | py_mediastack-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c380dd01633340b5da527469ae7c822aaf08f28cb6bf5c714f8273d188f79190
|
|
BLAKE2b-256 checksum How to use checksums |
1b538c4e5b9cab31c813153f4c5ec38a7773d9f268eb0b3faf57522d5c91fe0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Security for py-mediastack 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.