Json transformation in python – Code Review Stack Exchange

I’m new to Python and this is the very first program that I wrote. It extracts certain fields from a json data and write it in to a CSV file. This works as intended, but wanted a code review to see if there are any better or efficient ways to do this.

import sys
import json
import csv
import requests

def get_data(data_source, file_mode):

    # construct endpoint and hit the request
    endpoint = ...
    query_string_params = {
    r = requests.get(endpoint, params=query_string_params)

    # get json data from response
    data_json = r.json()

    data_list = data_json('value')

    # create a new dictionary with required fields and a list to put the dictionary in
    x = ('Key1', 'Key2', 'Key3', 'Key4', 'Key5')
    new_data = dict.fromkeys(x)
    new_data_list = ()

    # iterate through the dictionary and extract required fields
    for data in data_list:
        new_data("Key1") = data('field1')('nestedfield1')('nestedfield')
        new_data("Key2") = data('field1')('nestedfield2')
        new_data("Key3") = data('field2')
        new_data("Key4") = data('field3')('nestedfield1')
        new_data("Key5") = data.setdefault('field4', '')

    # open a csv file and write the dictionary values
    data_file = open('prData.csv', file_mode)
    csv_writer = csv.writer(data_file)

    count = 0
    for new_data in new_data_list:
        # first time is called with a mode 'W' and helps create the title row.
        if count == 0 and file_mode == 'w':
            header = new_data.keys()
            count += 1

if __name__ == "__main__":
    # user_input

    get_pull_requests('data_source1', 'w')
    get_pull_requests('data_source2', 'a')
    get_pull_requests('data_source3', 'a')

Thanks in advance!