Created
October 8, 2020 13:03
-
-
Save luchiago/7025f68e092ba000a7bfd5a95d6caeb4 to your computer and use it in GitHub Desktop.
Fetch json from an API and saves in a file
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
import json | |
import requests | |
def save_file(file_name, data): | |
with open(file_name, 'w') as file: | |
json_data = json.dumps(data) | |
file.write(json_data) | |
def fetch_json(url, headers={}): | |
response = requests.get(url, headers=headers) | |
return response.json() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment