import json
import requests
import csv
sources = requests.get("http://newskeeper.dev.scoretrends.com/api/v1/source/?format=json&nopaginate=true", headers={'Authorization': 'Token c6864dd6ca421520d84e987f2f6ff70326efb6f8'}).json()
source_list = []
for x in sources:
source_list.append([x['id'], x['name']])
# print source_list
with open('sources.csv', 'w') as myfile:
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
for y in source_list:
wr.writerow(y)