Skip to main content

AsyncIO Python wrapper to News API

Project description


Build Status Code Coverage License Join the chat at

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'):

if __name__ == '__main__':

The API key should be provided as an environment variable named NEWSAPI_KEY:

export NEWSAPI_KEY="..."

Go to News API website to create a free API key.

This library is loosely based on / inspired by newsapi-python, a requests based library by Matt Lisivick.


Unit tests for the Session class have been implemented using pytest. These can run using:

pytest -v tests/

from the root of the repo (avoids interference with the venv folders).

Project details

Release history Release notifications

This version


Download files

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

Files for asyncnewsapi, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size asyncnewsapi-0.1-py3-none-any.whl (12.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size asyncnewsapi-0.1.tar.gz (11.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page