Skip to content

Instantly share code, notes, and snippets.

@quickcode00
Last active September 12, 2021 17:15
Embed
What would you like to do?
def news_api_request(url: str, **kwargs) -> list:
"""
Sends GET request to News API endpoint
Inputs
----------
url: full URL for endpoint
kwargs: please refer to
News API documentations:
https://newsapi.org/docs/endpoints/
(apiKey argument is required)
Return
----------
list containing data for each article in response
"""
params = kwargs
res = requests.get(url, params=params)
articles = res.json().get('articles')
return articles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment