This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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