asyncnewsapi
An asyncio Python library to perform request against News API. It provides direct access to the endpoints defined in the documentation.
Two classes are implemented, returning async iterators for the request results. Session will return an iterator through the results of a single request. Alternatively, Stream will return an infinite iterator, performing successive requests and continuing to iterate through the results. A minimal implementation can be as simple as:
import asyncio
from asyncnewsapi import Session
async def main():
async with Session() as api:
async for article in api.top_headlines(language='en'):
print(article['title'])
if __name__ == '__main__':
asyncio.run(main())
The API key should be provided as an environment variable named NEWSAPI_KEY:
export NEWSAPI_KEY="..."
Go to the NewsAPI website to create a free API key.
This library is loosely based on / inspired by newsapi-python, a requests based library by Matt Lisivick.
Installation
Use pip to install this package, either directly from pypi:
pip install asyncnewsapi
or after cloning from github:
pip install .
Tests
Unit tests have been implemented using pytest. To run them, additional dependencies need be installed:
pip install ".[test]"
The tests can then be run using:
python -m pytest -v tests/
from the root of the repo (running it explicitly on the tests/ directory avoids interference with the venv folders).
Metadata
Release files for asyncnewsapi 0.2.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 | Actions |
|---|---|---|---|---|
| asyncnewsapi-0.2.1.tar.gz | 12.8 kB | Without provenance | Details for asyncnewsapi-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncnewsapi-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for asyncnewsapi-0.2.1-py3-none-any.whl |
Total release size: 25.8 kB
Release files / asyncnewsapi-0.2.1.tar.gz
| Download URL | asyncnewsapi-0.2.1.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9986573b7fb062dab7e27a4e0a07d610e60218fcc337ab217a0bb7104c18039c
|
|
BLAKE2b-256 checksum How to use checksums |
efeed32348fb48b16a746b6d9f50c06665a5cc00ee877f72b4a1be5db93d7ed9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
|
Release files / asyncnewsapi-0.2.1-py3-none-any.whl
| Download URL | asyncnewsapi-0.2.1-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54abb36ddd9548b011e0ae8ec885002be469c9f0c8bc38ca771f2d74e1f97366
|
|
BLAKE2b-256 checksum How to use checksums |
42d60ce0c053427d0d0f2bfc107cabb0ce7a19d9343f23dabed701be54d1ba99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
|
Security for asyncnewsapi 0.2.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.