import json

import requests

# call an API

URL='https://api.data.gov/ed/collegescorecard/v1/schools.json?api_key=hD5u2TNKfysMwBlG0vurLDlLQpVKKTZvb1j60cpx&school.degrees_awarded.predominant=2,3&fields=id,school.name,2013.student.size'

response= requests.get(URL)

jsontxt = response.json()

print(jsontxt,'\n',sep=' ')

# create a new csv file to save the headlines

myfile=open('college_data.csv','w')

myfile.write(str(jsontxt))

myfile.close()