<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Prepare the connection
Apply a Google Places Web Service API key on Google Developers Console
Save the key as an json file in the same folder of the python script
import the modules we need and set up a credential connection to Google Places API
(If you didn't install 'googleplaces' module before, go to terminal and type pip install https
Step1:  Get data from API
Every account can excuete 1,000 API calls within 24 hours. The response limit of every search is 20. So again we have to narrow down the search criteria to get more data. Let's begin with the geometry of Boston Downtown Crossing.
For the parameters you can set up in the following query, go to Documentation
Step2:  Then we check if we get any results from API and print some information to the screen.
Step3:  The response from API above contains many information
Step4:  Scrape the data nad save them to json files
Let's start to collect the data and save them to files for further usage. We list all the criterias we want to search for, go through them one by one, append to a list and save the list as a json file.
<ASSISTANT_TASK:>
Python Code:
import json  #for reading oauth info and save the results
import io 
from googleplaces import GooglePlaces, types, lang
from pprint import pprint
with io.open('google_places_key.json') as cred:
    creds = json.load(cred)
    google_places = GooglePlaces(**creds)
Explanation: Prepare the connection
Apply a Google Places Web Service API key on Google Developers Console
Save the key as an json file in the same folder of the python script
import the modules we need and set up a credential connection to Google Places API
(If you didn't install 'googleplaces' module before, go to terminal and type pip install https://github.com/slimkrazy/python-google-places/zipball/master to install the module)
End of explanation
    query_result = google_places.nearby_search(
        lat_lng = {'lat': 42.3555885, 'lng': -71.0646816}, rankby = 'distance', types = [types.TYPE_FOOD])
Explanation: Get data from API
Every account can excuete 1,000 API calls within 24 hours. The response limit of every search is 20. So again we have to narrow down the search criteria to get more data. Let's begin with the geometry of Boston Downtown Crossing.
For the parameters you can set up in the following query, go to Documentation
End of explanation
    if query_result.raw_response:
        print 'status: ' + query_result.raw_response['status']
        print 'next_page_token: ' + query_result.raw_response['next_page_token']
        print 'number of results: ' + str(len(query_result.raw_response['results']))
Explanation: Then we check if we get any results from API and print some information to the screen.
End of explanation
    for place in query_result.places:
        pprint(vars(place))  #only get geo_location, icon, id, name, place_id, rating, types, vicinty 
        # The following method has to make a further API call.
        place.get_details()  #get more details including phone_number, opening_hours, photos, reviews ... etc
        pprint(vars(place))
        break    #Here I break when we finish the first place since 20 reesults are too long.
Explanation: The response from API above contains many information:
1. A 'next_page_token': Use this token at your next search assigned to parameter 'pagetoken' and you'll get the following 20 results of your previous serach.
2. Your 'results' of places: These are the data we want. But only few basic informatino here, so we have to get more details in the follwing steps.
Look into details of the data
We use vars(object) to extend all the information in the object:
To see all the response values and their definitinos in places, go to Google Places Search Results
End of explanation
    result = []
    #Put your lantitude and longtitude pairs in the list and run the search in turns
    lat_lng_list = [{'lat': 2.356357, 'lng': -71.0623345},  #Park Street Station
                    {'lat': 42.356357, 'lng': -71.0623345},  #China Town Station
                    {'lat': 42.3555885, 'lng': -71.0646816}] #Downtown Crossing Station
    for pair in lat_lng_list:
        query_result = google_places.nearby_search(
        lat_lng = pair, rankby = 'distance', types = [types.TYPE_FOOD])
        for place in query_result.places:
            place.get_details()
            tmp = vars(place)
            results.append(tmp)
            
    with open('my_boston_restaurants_google_places.json', 'wb') as f:
        results_json = json.dumps(results, indent=4, skipkeys=True, sort_keys=True)
        f.write(results_json)
Explanation: Scrape the data nad save them to json files
Let's start to collect the data and save them to files for further usage. We list all the criterias we want to search for, go through them one by one, append to a list and save the list as a json file.
End of explanation
<END_TASK>