# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# Dependencies json, requests, pprint, and your config file for api_key
import json
import requests
from pprint import pprint
from config import api_key

# +
# Set the url and query information for the country of US
url = "https://newsapi.org/v2/top-headlines?"
country = "us"

# Build query URL with the country query.
query_url = url + "country=" + country + "&apiKey=" + api_key
query_url

# +
# Get news data using requests
news_response = requests.get(query_url)
news_json = news_response.json()

# Test your api call using by printing your api data.
print(f"The news API responded with: {news_json}.")

# +
# Create variable called articles_list 
    # Set it to a list of all article dictionaries from news_json
articles_list = [article for article in news_json['articles']]

# Use pprint to print the articles_list
pprint(articles_list)
# -



StarcoderdataJupyterScriptsDedupFiltered