Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Created on Cognitive Class Labs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<a href=\"https://cognitiveclass.ai\"><img src = \"https://ibm.box.com/shared/static/9gegpsmnsoo25ikkbl4qzlvlyjbgxs5x.png\" width = 400> </a>\n",
"\n",
"<h1 align=center><font size = 5>Learning FourSquare API with Python</font></h1>"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## Introduction\n",
"\n",
"In this lab, you will learn in details how to make calls to the Foursquare API for different purposes. You will learn how to construct a URL to send a request to the API to search for a specific type of venues, to explore a particular venue, to explore a Foursquare user, to explore a geographical location, and to get trending venues around a location. Also, you will learn how to use the visualization library, Folium, to visualize the results."
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## Table of Contents\n",
"\n",
"1. <a href=\"#item1\">Foursquare API Search Function</a>\n",
"2. <a href=\"#item2\">Explore a Given Venue</a> \n",
"3. <a href=\"#item3\">Explore a User</a> \n",
"4. <a href=\"#item4\">Foursquare API Explore Function</a> \n",
"5. <a href=\"#item5\">Get Trending Venues</a> "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Import necessary Libraries"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Folium installed\n",
"Libraries imported.\n"
]
}
],
"source": [
"import requests # library to handle requests\n",
"import pandas as pd # library for data analsysis\n",
"import numpy as np # library to handle data in a vectorized manner\n",
"import random # library for random number generation\n",
"\n",
"#!conda install -c conda-forge geopy --yes \n",
"from geopy.geocoders import Nominatim # module to convert an address into latitude and longitude values\n",
"\n",
"# libraries for displaying images\n",
"from IPython.display import Image \n",
"from IPython.core.display import HTML \n",
" \n",
"# tranforming json file into a pandas dataframe library\n",
"from pandas.io.json import json_normalize\n",
"\n",
"#!conda install -c conda-forge folium=0.5.0 --yes\n",
"import folium # plotting library\n",
"\n",
"print('Folium installed')\n",
"print('Libraries imported.')"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Define Foursquare Credentials and Version"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"##### Make sure that you have created a Foursquare developer account and have your credentials handy"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Your credentials:\n",
"CLIENT_ID: your-client-ID\n",
"CLIENT_SECRET:your-client-secret\n"
]
}
],
"source": [
"CLIENT_ID = 'your-client-ID' # your Foursquare ID\n",
"CLIENT_SECRET = 'your-client-secret' # your Foursquare Secret\n",
"VERSION = '20180604'\n",
"LIMIT = 30\n",
"print('Your credentials:')\n",
"print('CLIENT_ID: ' + CLIENT_ID)\n",
"print('CLIENT_SECRET:' + CLIENT_SECRET)"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Let's again assume that you are staying at the Conrad hotel. So let's start by converting the Contrad Hotel's address to its latitude and longitude coordinates."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In order to define an instance of the geocoder, we need to define a user_agent. We will name our agent <em>foursquare_agent</em>, as shown below."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"40.7149555 -74.0153365\n"
]
}
],
"source": [
"address = '102 North End Ave, New York, NY'\n",
"\n",
"geolocator = Nominatim(user_agent=\"foursquare_agent\")\n",
"location = geolocator.geocode(address)\n",
"latitude = location.latitude\n",
"longitude = location.longitude\n",
"print(latitude, longitude)"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<a id=\"item1\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## 1. Search for a specific venue category\n",
"> `https://api.foursquare.com/v2/venues/`**search**`?client_id=`**CLIENT_ID**`&client_secret=`**CLIENT_SECRET**`&ll=`**LATITUDE**`,`**LONGITUDE**`&v=`**VERSION**`&query=`**QUERY**`&radius=`**RADIUS**`&limit=`**LIMIT**"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Now, let's assume that it is lunch time, and you are craving Italian food. So, let's define a query to search for Italian food that is within 500 metres from the Conrad Hotel. "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Italian .... OK!\n"
]
}
],
"source": [
"search_query = 'Italian'\n",
"radius = 500\n",
"print(search_query + ' .... OK!')"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Define the corresponding URL"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"'https://api.foursquare.com/v2/venues/search?client_id=your-client-ID&client_secret=your-client-secret&ll=40.7149555,-74.0153365&v=20180604&query=Italian&radius=500&limit=30'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url = 'https://api.foursquare.com/v2/venues/search?client_id={}&client_secret={}&ll={},{}&v={}&query={}&radius={}&limit={}'.format(CLIENT_ID, CLIENT_SECRET, latitude, longitude, VERSION, search_query, radius, LIMIT)\n",
"url"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Send the GET Request and examine the results"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"{'meta': {'code': 200, 'requestId': '5c74bc25f594df76b9d58ba4'},\n",
" 'response': {'venues': [{'id': '4fa862b3e4b0ebff2f749f06',\n",
" 'name': \"Harry's Italian Pizza Bar\",\n",
" 'location': {'address': '225 Murray St',\n",
" 'lat': 40.71521779064671,\n",
" 'lng': -74.01473940209351,\n",
" 'labeledLatLngs': [{'label': 'display',\n",
" 'lat': 40.71521779064671,\n",
" 'lng': -74.01473940209351}],\n",
" 'distance': 58,\n",
" 'postalCode': '10282',\n",
" 'cc': 'US',\n",
" 'city': 'New York',\n",
" 'state': 'NY',\n",
" 'country': 'United States',\n",
" 'formattedAddress': ['225 Murray St',\n",
" 'New York, NY 10282',\n",
" 'United States']},\n",
" 'categories': [{'id': '4bf58dd8d48988d1ca941735',\n",
" 'name': 'Pizza Place',\n",
" 'pluralName': 'Pizza Places',\n",
" 'shortName': 'Pizza',\n",
" 'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/pizza_',\n",
" 'suffix': '.png'},\n",
" 'primary': True}],\n",
" 'delivery': {'id': '294544',\n",
" 'url': 'https://www.seamless.com/menu/harrys-italian-pizza-bar-225-murray-st-new-york/294544?affiliate=1131&utm_source=foursquare-affiliate-network&utm_medium=affiliate&utm_campaign=1131&utm_content=294544',\n",
" 'provider': {'name': 'seamless',\n",
" 'icon': {'prefix': 'https://fastly.4sqi.net/img/general/cap/',\n",
" 'sizes': [40, 50],\n",
" 'name': '/delivery_provider_seamless_20180129.png'}}},\n",
" 'referralId': 'v-1551154213',\n",
" 'hasPerk': False},\n",
" {'id': '4f3232e219836c91c7bfde94',\n",
" 'name': 'Conca Cucina Italian Restaurant',\n",
" 'location': {'address': '63 W Broadway',\n",
" 'lat': 40.71446,\n",
" 'lng': -74.010086,\n",
" 'labeledLatLngs': [{'label': 'display',\n",
" 'lat': 40.71446,\n",
" 'lng': -74.010086}],\n",
" 'distance': 446,\n",
" 'postalCode': '10007',\n",
" 'cc': 'US',\n",
" 'city': 'New York',\n",
" 'state': 'NY',\n",
" 'country': 'United States',\n",
" 'formattedAddress': ['63 W Broadway',\n",
" 'New York, NY 10007',\n",
" 'United States']},\n",
" 'categories': [{'id': '4d4b7105d754a06374d81259',\n",
" 'name': 'Food',\n",
" 'pluralName': 'Food',\n",
" 'shortName': 'Food',\n",
" 'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/default_',\n",
" 'suffix': '.png'},\n",
" 'primary': True}],\n",
" 'referralId': 'v-1551154213',\n",
" 'hasPerk': False},\n",
" {'id': '3fd66200f964a520f4e41ee3',\n",
" 'name': 'Ecco',\n",
" 'location': {'address': '124 Chambers St',\n",
" 'crossStreet': 'btwn Church St & W Broadway',\n",
" 'lat': 40.71533713859952,\n",
" 'lng': -74.00884766217825,\n",
" 'labeledLatLngs': [{'label': 'display',\n",
" 'lat': 40.71533713859952,\n",
" 'lng': -74.00884766217825}],\n",
" 'distance': 549,\n",
" 'postalCode': '10007',\n",
" 'cc': 'US',\n",
" 'city': 'New York',\n",
" 'state': 'NY',\n",
" 'country': 'United States',\n",
" 'formattedAddress': ['124 Chambers St (btwn Church St & W Broadway)',\n",
" 'New York, NY 10007',\n",
" 'United States']},\n",
" 'categories': [{'id': '4bf58dd8d48988d110941735',\n",
" 'name': 'Italian Restaurant',\n",
" 'pluralName': 'Italian Restaurants',\n",
" 'shortName': 'Italian',\n",
" 'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/italian_',\n",
" 'suffix': '.png'},\n",
" 'primary': True}],\n",
" 'referralId': 'v-1551154213',\n",
" 'hasPerk': False}]}}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results = requests.get(url).json()\n",
"results"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Get relevant part of JSON and transform it into a *pandas* dataframe"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>categories</th>\n",
" <th>delivery.id</th>\n",
" <th>delivery.provider.icon.name</th>\n",
" <th>delivery.provider.icon.prefix</th>\n",
" <th>delivery.provider.icon.sizes</th>\n",
" <th>delivery.provider.name</th>\n",
" <th>delivery.url</th>\n",
" <th>hasPerk</th>\n",
" <th>id</th>\n",
" <th>location.address</th>\n",
" <th>...</th>\n",
" <th>location.crossStreet</th>\n",
" <th>location.distance</th>\n",
" <th>location.formattedAddress</th>\n",
" <th>location.labeledLatLngs</th>\n",
" <th>location.lat</th>\n",
" <th>location.lng</th>\n",
" <th>location.postalCode</th>\n",
" <th>location.state</th>\n",
" <th>name</th>\n",
" <th>referralId</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[{'id': '4bf58dd8d48988d1ca941735', 'name': 'P...</td>\n",
" <td>294544</td>\n",
" <td>/delivery_provider_seamless_20180129.png</td>\n",
" <td>https://fastly.4sqi.net/img/general/cap/</td>\n",
" <td>[40, 50]</td>\n",
" <td>seamless</td>\n",
" <td>https://www.seamless.com/menu/harrys-italian-p...</td>\n",
" <td>False</td>\n",
" <td>4fa862b3e4b0ebff2f749f06</td>\n",
" <td>225 Murray St</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>58</td>\n",
" <td>[225 Murray St, New York, NY 10282, United Sta...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71521779064671...</td>\n",
" <td>40.715218</td>\n",
" <td>-74.014739</td>\n",
" <td>10282</td>\n",
" <td>NY</td>\n",
" <td>Harry's Italian Pizza Bar</td>\n",
" <td>v-1551154213</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[{'id': '4d4b7105d754a06374d81259', 'name': 'F...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>4f3232e219836c91c7bfde94</td>\n",
" <td>63 W Broadway</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>446</td>\n",
" <td>[63 W Broadway, New York, NY 10007, United Sta...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71446, 'lng': ...</td>\n",
" <td>40.714460</td>\n",
" <td>-74.010086</td>\n",
" <td>10007</td>\n",
" <td>NY</td>\n",
" <td>Conca Cucina Italian Restaurant</td>\n",
" <td>v-1551154213</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[{'id': '4bf58dd8d48988d110941735', 'name': 'I...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>3fd66200f964a520f4e41ee3</td>\n",
" <td>124 Chambers St</td>\n",
" <td>...</td>\n",
" <td>btwn Church St &amp; W Broadway</td>\n",
" <td>549</td>\n",
" <td>[124 Chambers St (btwn Church St &amp; W Broadway)...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71533713859952...</td>\n",
" <td>40.715337</td>\n",
" <td>-74.008848</td>\n",
" <td>10007</td>\n",
" <td>NY</td>\n",
" <td>Ecco</td>\n",
" <td>v-1551154213</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>3 rows × 23 columns</p>\n",
"</div>"
],
"text/plain": [
" categories delivery.id \\\n",
"0 [{'id': '4bf58dd8d48988d1ca941735', 'name': 'P... 294544 \n",
"1 [{'id': '4d4b7105d754a06374d81259', 'name': 'F... NaN \n",
"2 [{'id': '4bf58dd8d48988d110941735', 'name': 'I... NaN \n",
"\n",
" delivery.provider.icon.name \\\n",
"0 /delivery_provider_seamless_20180129.png \n",
"1 NaN \n",
"2 NaN \n",
"\n",
" delivery.provider.icon.prefix delivery.provider.icon.sizes \\\n",
"0 https://fastly.4sqi.net/img/general/cap/ [40, 50] \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"\n",
" delivery.provider.name delivery.url \\\n",
"0 seamless https://www.seamless.com/menu/harrys-italian-p... \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"\n",
" hasPerk id location.address ... \\\n",
"0 False 4fa862b3e4b0ebff2f749f06 225 Murray St ... \n",
"1 False 4f3232e219836c91c7bfde94 63 W Broadway ... \n",
"2 False 3fd66200f964a520f4e41ee3 124 Chambers St ... \n",
"\n",
" location.crossStreet location.distance \\\n",
"0 NaN 58 \n",
"1 NaN 446 \n",
"2 btwn Church St & W Broadway 549 \n",
"\n",
" location.formattedAddress \\\n",
"0 [225 Murray St, New York, NY 10282, United Sta... \n",
"1 [63 W Broadway, New York, NY 10007, United Sta... \n",
"2 [124 Chambers St (btwn Church St & W Broadway)... \n",
"\n",
" location.labeledLatLngs location.lat \\\n",
"0 [{'label': 'display', 'lat': 40.71521779064671... 40.715218 \n",
"1 [{'label': 'display', 'lat': 40.71446, 'lng': ... 40.714460 \n",
"2 [{'label': 'display', 'lat': 40.71533713859952... 40.715337 \n",
"\n",
" location.lng location.postalCode location.state \\\n",
"0 -74.014739 10282 NY \n",
"1 -74.010086 10007 NY \n",
"2 -74.008848 10007 NY \n",
"\n",
" name referralId \n",
"0 Harry's Italian Pizza Bar v-1551154213 \n",
"1 Conca Cucina Italian Restaurant v-1551154213 \n",
"2 Ecco v-1551154213 \n",
"\n",
"[3 rows x 23 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# assign relevant part of JSON to venues\n",
"venues = results['response']['venues']\n",
"\n",
"# tranform venues into a dataframe\n",
"dataframe = json_normalize(venues)\n",
"dataframe.head()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Define information of interest and filter dataframe"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>categories</th>\n",
" <th>address</th>\n",
" <th>cc</th>\n",
" <th>city</th>\n",
" <th>country</th>\n",
" <th>crossStreet</th>\n",
" <th>distance</th>\n",
" <th>formattedAddress</th>\n",
" <th>labeledLatLngs</th>\n",
" <th>lat</th>\n",
" <th>lng</th>\n",
" <th>postalCode</th>\n",
" <th>state</th>\n",
" <th>id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Harry's Italian Pizza Bar</td>\n",
" <td>Pizza Place</td>\n",
" <td>225 Murray St</td>\n",
" <td>US</td>\n",
" <td>New York</td>\n",
" <td>United States</td>\n",
" <td>NaN</td>\n",
" <td>58</td>\n",
" <td>[225 Murray St, New York, NY 10282, United Sta...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71521779064671...</td>\n",
" <td>40.715218</td>\n",
" <td>-74.014739</td>\n",
" <td>10282</td>\n",
" <td>NY</td>\n",
" <td>4fa862b3e4b0ebff2f749f06</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Conca Cucina Italian Restaurant</td>\n",
" <td>Food</td>\n",
" <td>63 W Broadway</td>\n",
" <td>US</td>\n",
" <td>New York</td>\n",
" <td>United States</td>\n",
" <td>NaN</td>\n",
" <td>446</td>\n",
" <td>[63 W Broadway, New York, NY 10007, United Sta...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71446, 'lng': ...</td>\n",
" <td>40.714460</td>\n",
" <td>-74.010086</td>\n",
" <td>10007</td>\n",
" <td>NY</td>\n",
" <td>4f3232e219836c91c7bfde94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Ecco</td>\n",
" <td>Italian Restaurant</td>\n",
" <td>124 Chambers St</td>\n",
" <td>US</td>\n",
" <td>New York</td>\n",
" <td>United States</td>\n",
" <td>btwn Church St &amp; W Broadway</td>\n",
" <td>549</td>\n",
" <td>[124 Chambers St (btwn Church St &amp; W Broadway)...</td>\n",
" <td>[{'label': 'display', 'lat': 40.71533713859952...</td>\n",
" <td>40.715337</td>\n",
" <td>-74.008848</td>\n",
" <td>10007</td>\n",
" <td>NY</td>\n",
" <td>3fd66200f964a520f4e41ee3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name categories address cc \\\n",
"0 Harry's Italian Pizza Bar Pizza Place 225 Murray St US \n",
"1 Conca Cucina Italian Restaurant Food 63 W Broadway US \n",
"2 Ecco Italian Restaurant 124 Chambers St US \n",
"\n",
" city country crossStreet distance \\\n",
"0 New York United States NaN 58 \n",
"1 New York United States NaN 446 \n",
"2 New York United States btwn Church St & W Broadway 549 \n",
"\n",
" formattedAddress \\\n",
"0 [225 Murray St, New York, NY 10282, United Sta... \n",
"1 [63 W Broadway, New York, NY 10007, United Sta... \n",
"2 [124 Chambers St (btwn Church St & W Broadway)... \n",
"\n",
" labeledLatLngs lat lng \\\n",
"0 [{'label': 'display', 'lat': 40.71521779064671... 40.715218 -74.014739 \n",
"1 [{'label': 'display', 'lat': 40.71446, 'lng': ... 40.714460 -74.010086 \n",
"2 [{'label': 'display', 'lat': 40.71533713859952... 40.715337 -74.008848 \n",
"\n",
" postalCode state id \n",
"0 10282 NY 4fa862b3e4b0ebff2f749f06 \n",
"1 10007 NY 4f3232e219836c91c7bfde94 \n",
"2 10007 NY 3fd66200f964a520f4e41ee3 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# keep only columns that include venue name, and anything that is associated with location\n",
"filtered_columns = ['name', 'categories'] + [col for col in dataframe.columns if col.startswith('location.')] + ['id']\n",
"dataframe_filtered = dataframe.loc[:, filtered_columns]\n",
"#print(\"dataframe_filtered step 1:\", dataframe_filtered.head())\n",
"# function that extracts the category of the venue\n",
"def get_category_type(row):\n",
" try:\n",
" categories_list = row['categories']\n",
" except:\n",
" categories_list = row['venue.categories']\n",
" \n",
" if len(categories_list) == 0:\n",
" return None\n",
" else:\n",
" return categories_list[0]['name']\n",
"\n",
"# filter the category for each row\n",
"dataframe_filtered['categories'] = dataframe_filtered.apply(get_category_type, axis=1)\n",
"\n",
"# clean column names by keeping only last term\n",
"dataframe_filtered.columns = [column.split('.')[-1] for column in dataframe_filtered.columns]\n",
"\n",
"dataframe_filtered"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Let's visualize the Italian restaurants that are nearby"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"0 Harry's Italian Pizza Bar\n",
"1 Conca Cucina Italian Restaurant\n",
"2 Ecco\n",
"Name: name, dtype: object"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataframe_filtered.name"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgPHNjcmlwdD5MX1BSRUZFUl9DQU5WQVMgPSBmYWxzZTsgTF9OT19UT1VDSCA9IGZhbHN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MGY4ZTRmOTNiNDZjOTI2YTY0OTQwY2E1IiA+PC9kaXY+CiAgICAgICAgCjwvYm9keT4KPHNjcmlwdD4gICAgCiAgICAKCiAgICAgICAgICAgIAogICAgICAgICAgICAgICAgdmFyIGJvdW5kcyA9IG51bGw7CiAgICAgICAgICAgIAoKICAgICAgICAgICAgdmFyIG1hcF81YWMyODFlMTBmOGU0ZjkzYjQ2YzkyNmE2NDk0MGNhNSA9IEwubWFwKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ21hcF81YWMyODFlMTBmOGU0ZjkzYjQ2YzkyNmE2NDk0MGNhNScsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7Y2VudGVyOiBbNDAuNzE0OTU1NSwtNzQuMDE1MzM2NV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6b29tOiAxMywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heEJvdW5kczogYm91bmRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGF5ZXJzOiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmxkQ29weUp1bXA6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JzOiBMLkNSUy5FUFNHMzg1NwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgCiAgICAgICAgCiAgICAKICAgICAgICAgICAgdmFyIHRpbGVfbGF5ZXJfNDY0NTRjMzUzNjM5NDk0NmI1Yjg4MzExZmE0YTI0Y2UgPSBMLnRpbGVMYXllcigKICAgICAgICAgICAgICAgICdodHRwczovL3tzfS50aWxlLm9wZW5zdHJlZXRtYXAub3JnL3t6fS97eH0ve3l9LnBuZycsCiAgICAgICAgICAgICAgICB7CiAgImF0dHJpYnV0aW9uIjogbnVsbCwKICAiZGV0ZWN0UmV0aW5hIjogZmFsc2UsCiAgIm1heFpvb20iOiAxOCwKICAib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ChodG1sXzhlZTdlM2E4ZThiMzQyYmFhNzk0MDk2YmM4NjhiMmU5KTsKICAgICAgICAgICAgCgogICAgICAgICAgICBjaXJjbGVfbWFya2VyXzYzNDk2YjVkMjQyODRmMDFhNDRkOTVjZWQwODA5MzhjLmJpbmRQb3B1cChwb3B1cF84OWRjMTRiZDViZTA0ODAyOWI2NjU4YmU4NmEzZTI4Zik7CgogICAgICAgICAgICAKICAgICAgICAKPC9zY3JpcHQ+\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7f9a46a93da0>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"venues_map = folium.Map(location=[latitude, longitude], zoom_start=13) # generate map centred around the Conrad Hotel\n",
"\n",
"# add a red circle marker to represent the Conrad Hotel\n",
"folium.features.CircleMarker(\n",
" [latitude, longitude],\n",
" radius=10,\n",
" color='red',\n",
" popup='Conrad Hotel',\n",
" fill = True,\n",
" fill_color = 'red',\n",
" fill_opacity = 0.6\n",
").add_to(venues_map)\n",
"\n",
"# add the Italian restaurants as blue circle markers\n",
"for lat, lng, label in zip(dataframe_filtered.lat, dataframe_filtered.lng, dataframe_filtered.categories):\n",
" folium.features.CircleMarker(\n",
" [lat, lng],\n",
" radius=5,\n",
" color='blue',\n",
" popup=label,\n",
" fill = True,\n",
" fill_color='blue',\n",
" fill_opacity=0.6\n",
" ).add_to(venues_map)\n",
"\n",
"# display map\n",
"venues_map"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<a id=\"item2\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## 2. Explore a Given Venue\n",
"> `https://api.foursquare.com/v2/venues/`**VENUE_ID**`?client_id=`**CLIENT_ID**`&client_secret=`**CLIENT_SECRET**`&v=`**VERSION**"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### A. Let's explore the closest Italian restaurant -- _Harry's Italian Pizza Bar_"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"'https://api.foursquare.com/v2/venues/4fa862b3e4b0ebff2f749f06?client_id=your-client-ID&client_secret=your-client-secret&v=20180604'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"venue_id = '4fa862b3e4b0ebff2f749f06' # ID of Harry's Italian Pizza Bar\n",
"url = 'https://api.foursquare.com/v2/venues/{}?client_id={}&client_secret={}&v={}'.format(venue_id, CLIENT_ID, CLIENT_SECRET, VERSION)\n",
"url"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Send GET request for result"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dict_keys(['id', 'name', 'contact', 'location', 'canonicalUrl', 'categories', 'verified', 'stats', 'url', 'price', 'hasMenu', 'likes', 'dislike', 'ok', 'rating', 'ratingColor', 'ratingSignals', 'delivery', 'menu', 'allowMenuUrlEdit', 'beenHere', 'specials', 'photos', 'reasons', 'hereNow', 'createdAt', 'tips', 'shortUrl', 'timeZone', 'listed', 'hours', 'popular', 'pageUpdates', 'inbox', 'attributes', 'bestPhoto', 'colors'])\n"
]
},
{
"data": {
"text/plain": [
"{'id': '4fa862b3e4b0ebff2f749f06',\n",
" 'name': \"Harry's Italian Pizza Bar\",\n",
" 'contact': {'phone': '2126081007', 'formattedPhone': '(212) 608-1007'},\n",
" 'location': {'address': '225 Murray St',\n",
" 'lat': 40.71521779064671,\n",
" 'lng': -74.01473940209351,\n",
" 'labeledLatLngs': [{'label': 'display',\n",
" 'lat': 40.71521779064671,\n",
" 'lng': -74.01473940209351}],\n",
" 'postalCode': '10282',\n",
" 'cc': 'US',\n",
" 'city': 'New York',\n",
" 'state': 'NY',\n",
" 'country': 'United States',\n",
" 'formattedAddress': ['225 Murray St',\n",
" 'New York, NY 10282',\n",
" 'United States']},\n",
" 'canonicalUrl': 'https://foursquare.com/v/harrys-italian-pizza-bar/4fa862b3e4b0ebff2f749f06',\n",
" 'categories': [{'id': '4bf58dd8d48988d1ca941735',\n",
" 'name': 'Pizza Place',\n",
" 'pluralName': 'Pizza Places',\n",
" 'shortName': 'Pizza',\n",
" 'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/pizza_',\n",
" 'suffix': '.png'},\n",
" 'primary': True},\n",
" {'id': '4bf58dd8d48988d110941735',\n",
" 'name': 'Italian Restaurant',\n",
" 'pluralName': 'Italian Restaurants',\n",
" 'shortName': 'Italian',\n",
" 'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/food/italian_',\n",
" 'suffix': '.png'}}],\n",
" 'verified': False,\n",
" 'stats': {'tipCount': 55},\n",
" 'url': 'http://harrysitalian.com',\n",
" 'price': {'tier': 2, 'message': 'Moderate', 'currency': '$'},\n",
" 'hasMenu': True,\n",
" 'likes': {'count': 119,\n",
" 'groups': [{'type': 'others', 'count': 119, 'items': []}],\n",
" 'summary': '119 Likes'},\n",
" 'dislike': False,\n",
" 'ok': False,\n",
" 'rating': 7.1,\n",
" 'ratingColor': 'C5DE35',\n",
" 'ratingSignals': 209,\n",
" 'delivery': {'id': '294544',\n",
" 'url': 'https://www.seamless.com/menu/harrys-italian-pizza-bar-225-murray-st-new-york/294544?affiliate=1131&utm_source=foursquare-affiliate-network&utm_medium=affiliate&utm_campaign=1131&utm_content=294544',\n",
" 'provider': {'name': 'seamless',\n",
" 'icon': {'prefix': 'https://fastly.4sqi.net/img/general/cap/',\n",
" 'sizes': [40, 50],\n",
" 'name': '/delivery_provider_seamless_20180129.png'}}},\n",
" 'menu': {'type': 'Menu',\n",
" 'label': 'Menu',\n",
" 'anchor': 'View Menu',\n",
" 'url': 'https://foursquare.com/v/harrys-italian-pizza-bar/4fa862b3e4b0ebff2f749f06/menu',\n",
" 'mobileUrl': 'https://foursquare.com/v/4fa862b3e4b0ebff2f749f06/device_menu'},\n",
" 'allowMenuUrlEdit': True,\n",
" 'beenHere': {'count': 0,\n",
" 'unconfirmedCount': 0,\n",
" 'marked': False,\n",
" 'lastCheckinExpiredAt': 0},\n",
" 'specials': {'count': 0, 'items': []},\n",
" 'photos': {'count': 146,\n",
" 'groups': [{'type': 'checkin',\n",
" 'name': \"Friends' check-in photos\",\n",
" 'count': 0,\n",
" 'items': []},\n",
" {'type': 'venue',\n",
" 'name': 'Venue photos',\n",
" 'count': 146,\n",
" 'items': [{'id': '4fad980de4b091b4626c3633',\n",
" 'createdAt': 1336776717,\n",
" 'source': {'name': 'Foursquare for Android',\n",
" 'url': 'https://foursquare.com/download/#/android'},\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/ya1iQFI7pLjuIJp1PGDKlrZS3OJdHCF7tpILMmjv_2w.jpg',\n",
" 'width': 480,\n",
" 'height': 640,\n",
" 'user': {'id': '13676709',\n",
" 'firstName': 'Leony',\n",
" 'lastName': 'Naciri',\n",
" 'gender': 'none',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/T0ANFNGNMCHUDEUE.jpg'}},\n",
" 'visibility': 'public'},\n",
" {'id': '513a2e50e4b08ac082454376',\n",
" 'createdAt': 1362767440,\n",
" 'source': {'name': 'Foursquare for iOS',\n",
" 'url': 'https://foursquare.com/download/#/iphone'},\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/6195366_2CTGLooEIZ-oVxZlMGjQFunPJuwJql1jtFnIf69-8Tw.jpg',\n",
" 'width': 717,\n",
" 'height': 959,\n",
" 'user': {'id': '6195366',\n",
" 'firstName': 'Michelle',\n",
" 'lastName': 'Thornton',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/2RJUIIDMSRLF1UOE.jpg'}},\n",
" 'visibility': 'public'}]}],\n",
" 'summary': '0 photos'},\n",
" 'reasons': {'count': 1,\n",
" 'items': [{'summary': 'Lots of people like this place',\n",
" 'type': 'general',\n",
" 'reasonName': 'rawLikesReason'}]},\n",
" 'hereNow': {'count': 0, 'summary': 'Nobody here', 'groups': []},\n",
" 'createdAt': 1336435379,\n",
" 'tips': {'count': 55,\n",
" 'groups': [{'type': 'others',\n",
" 'name': 'All tips',\n",
" 'count': 55,\n",
" 'items': [{'id': '53d27909498e0523841340b6',\n",
" 'createdAt': 1406302473,\n",
" 'text': \"Harry's Italian Pizza bar is known for it's amazing pizza, but did you know that the brunches here are amazing too? Try the Nutella French toast and we know you'll be sold.\",\n",
" 'type': 'user',\n",
" 'canonicalUrl': 'https://foursquare.com/item/53d27909498e0523841340b6',\n",
" 'lang': 'en',\n",
" 'likes': {'count': 4,\n",
" 'groups': [{'type': 'others',\n",
" 'count': 4,\n",
" 'items': [{'id': '369426',\n",
" 'firstName': 'P.',\n",
" 'lastName': 'M.',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/JPQYUWJKUT0H2OO4.jpg'}},\n",
" {'id': '87587879',\n",
" 'firstName': 'Diane',\n",
" 'lastName': 'Danneels',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/87587879-ESLRSZLQ2CBE2P4W.jpg'}},\n",
" {'id': '87591341',\n",
" 'firstName': 'Tim',\n",
" 'lastName': 'Sheehan',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/-Z4YK4VKE0JSVXIY1.jpg'}},\n",
" {'id': '87473404',\n",
" 'firstName': 'TenantKing.com',\n",
" 'gender': 'none',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/87473404-HI5DTBTK0HX401CA.png'},\n",
" 'type': 'page'}]}],\n",
" 'summary': '4 likes'},\n",
" 'logView': True,\n",
" 'agreeCount': 4,\n",
" 'disagreeCount': 0,\n",
" 'todo': {'count': 0},\n",
" 'user': {'id': '87473404',\n",
" 'firstName': 'TenantKing.com',\n",
" 'gender': 'none',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/87473404-HI5DTBTK0HX401CA.png'},\n",
" 'type': 'page'}},\n",
" {'id': '53962e98498ecd43845cc813',\n",
" 'createdAt': 1402351256,\n",
" 'text': \"I'm not sure if this place is one of the famous pizzerias in NYC but I loved their pizza.\",\n",
" 'type': 'user',\n",
" 'canonicalUrl': 'https://foursquare.com/item/53962e98498ecd43845cc813',\n",
" 'photo': {'id': '53962e9c498e53dbbf59b28e',\n",
" 'createdAt': 1402351260,\n",
" 'source': {'name': 'Foursquare for iOS',\n",
" 'url': 'https://foursquare.com/download/#/iphone'},\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/7012699_DCcCtW8oRbhNv62E68gxtLnWn7IgRhapBr8vdnIQjYk.jpg',\n",
" 'width': 720,\n",
" 'height': 720,\n",
" 'visibility': 'public'},\n",
" 'photourl': 'https://fastly.4sqi.net/img/general/original/7012699_DCcCtW8oRbhNv62E68gxtLnWn7IgRhapBr8vdnIQjYk.jpg',\n",
" 'lang': 'en',\n",
" 'likes': {'count': 2,\n",
" 'groups': [{'type': 'others',\n",
" 'count': 2,\n",
" 'items': [{'id': '7012699',\n",
" 'firstName': 'Hani',\n",
" 'lastName': 'Alawadi',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/2ZMJFSP2Z4R5NBVX.jpg'}},\n",
" {'id': '61939758',\n",
" 'firstName': 'Leena',\n",
" 'lastName': 'Ragheb',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/61939758_pBzZmOnI_mALXdaYa4C4EqqytWYHr5jq5XUZi3ImFD8uORx0A5-KLcSxtzsxwgtMRPn1Ur7-v.jpg'}}]}],\n",
" 'summary': '2 likes'},\n",
" 'logView': True,\n",
" 'agreeCount': 2,\n",
" 'disagreeCount': 0,\n",
" 'todo': {'count': 0},\n",
" 'user': {'id': '7012699',\n",
" 'firstName': 'Hani',\n",
" 'lastName': 'Alawadi',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/2ZMJFSP2Z4R5NBVX.jpg'}},\n",
" 'authorInteractionType': 'liked'}]}]},\n",
" 'shortUrl': 'http://4sq.com/JNblHV',\n",
" 'timeZone': 'America/New_York',\n",
" 'listed': {'count': 50,\n",
" 'groups': [{'type': 'others',\n",
" 'name': 'Lists from other people',\n",
" 'count': 50,\n",
" 'items': [{'id': '4fa32fd0e4b04193744746b1',\n",
" 'name': 'Manhattan Haunts',\n",
" 'description': '',\n",
" 'type': 'others',\n",
" 'user': {'id': '24592223',\n",
" 'firstName': 'Becca',\n",
" 'lastName': 'McArthur',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/24592223-RAW2UYM0GIB1U40K.jpg'}},\n",
" 'editable': False,\n",
" 'public': True,\n",
" 'collaborative': False,\n",
" 'url': '/becca_mcarthur/list/manhattan-haunts',\n",
" 'canonicalUrl': 'https://foursquare.com/becca_mcarthur/list/manhattan-haunts',\n",
" 'createdAt': 1336094672,\n",
" 'updatedAt': 1380845377,\n",
" 'photo': {'id': '4e8cc9461081e3b3544e12e5',\n",
" 'createdAt': 1317849414,\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/0NLVU2HC1JF4DXIMKWUFW3QBUT31DC11EFNYYHMJG3NDWAPS.jpg',\n",
" 'width': 492,\n",
" 'height': 330,\n",
" 'user': {'id': '742542',\n",
" 'firstName': 'Time Out New York',\n",
" 'gender': 'none',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/XXHKCBSQHBORZNSR.jpg'},\n",
" 'type': 'page'},\n",
" 'visibility': 'public'},\n",
" 'followers': {'count': 22},\n",
" 'listItems': {'count': 187,\n",
" 'items': [{'id': 'v4fa862b3e4b0ebff2f749f06',\n",
" 'createdAt': 1342934485}]}},\n",
" {'id': '4fae817be4b085f6b2a74d19',\n",
" 'name': 'USA NYC MAN FiDi',\n",
" 'description': 'Where to go for decent eats in the restaurant wasteland of Downtown NYC aka FiDi, along with Tribeca & Battery Park City.',\n",
" 'type': 'others',\n",
" 'user': {'id': '12113441',\n",
" 'firstName': 'Kino',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/12113441-K5HTHFLU2MUCM0CM.jpg'}},\n",
" 'editable': False,\n",
" 'public': True,\n",
" 'collaborative': False,\n",
" 'url': '/kinosfault/list/usa-nyc-man-fidi',\n",
" 'canonicalUrl': 'https://foursquare.com/kinosfault/list/usa-nyc-man-fidi',\n",
" 'createdAt': 1336836475,\n",
" 'updatedAt': 1536019882,\n",
" 'photo': {'id': '55984992498e13ba75e353bb',\n",
" 'createdAt': 1436043666,\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/12113441_iOa6Uh-Xi8bhj2-gpzkkw8MKiAIs7RmOcz_RM7m8ink.jpg',\n",
" 'width': 540,\n",
" 'height': 960,\n",
" 'user': {'id': '12113441',\n",
" 'firstName': 'Kino',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/12113441-K5HTHFLU2MUCM0CM.jpg'}},\n",
" 'visibility': 'public'},\n",
" 'followers': {'count': 20},\n",
" 'listItems': {'count': 272,\n",
" 'items': [{'id': 'v4fa862b3e4b0ebff2f749f06',\n",
" 'createdAt': 1373909433}]}},\n",
" {'id': '4fddeff0e4b0e078037ac0d3',\n",
" 'name': 'NYC Resturants',\n",
" 'description': '',\n",
" 'type': 'others',\n",
" 'user': {'id': '21563126',\n",
" 'firstName': 'Richard',\n",
" 'lastName': 'Revilla',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/21563126_v05J1KPw_SVj6Ehq9g8B9jeAGjFUMsU5QGl-NZ8inUQ7pKQm5bKplW37EmR7jS2A7GYPBBAtl.jpg'}},\n",
" 'editable': False,\n",
" 'public': True,\n",
" 'collaborative': True,\n",
" 'url': '/rickr7/list/nyc-resturants',\n",
" 'canonicalUrl': 'https://foursquare.com/rickr7/list/nyc-resturants',\n",
" 'createdAt': 1339944944,\n",
" 'updatedAt': 1550795902,\n",
" 'photo': {'id': '5072dd13e4b09145cdf782d1',\n",
" 'createdAt': 1349704979,\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/208205_fGh2OuAZ9qJ4agbAA5wMVNOSIm9kNUlRtNwj1N-adqg.jpg',\n",
" 'width': 800,\n",
" 'height': 800,\n",
" 'user': {'id': '208205',\n",
" 'firstName': 'Thalia',\n",
" 'lastName': 'K',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/SNOOLCAW2AG04ZKD.jpg'}},\n",
" 'visibility': 'public'},\n",
" 'followers': {'count': 12},\n",
" 'listItems': {'count': 194,\n",
" 'items': [{'id': 't54ed3b13498e857fd7dbb6fc',\n",
" 'createdAt': 1514680908}]}},\n",
" {'id': '5266c68a498e7c667807fe09',\n",
" 'name': 'Foodie Love in NY - 02',\n",
" 'description': '',\n",
" 'type': 'others',\n",
" 'user': {'id': '547977',\n",
" 'firstName': 'WiLL',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/-Q5NYGDMFDMOITQRR.jpg'}},\n",
" 'editable': False,\n",
" 'public': True,\n",
" 'collaborative': False,\n",
" 'url': '/sweetiewill/list/foodie-love-in-ny--02',\n",
" 'canonicalUrl': 'https://foursquare.com/sweetiewill/list/foodie-love-in-ny--02',\n",
" 'createdAt': 1382467210,\n",
" 'updatedAt': 1391995585,\n",
" 'followers': {'count': 7},\n",
" 'listItems': {'count': 200,\n",
" 'items': [{'id': 'v4fa862b3e4b0ebff2f749f06',\n",
" 'createdAt': 1386809936}]}}]}]},\n",
" 'hours': {'status': 'Closed until 11:30 AM tomorrow',\n",
" 'richStatus': {'entities': [], 'text': 'Closed until 11:30 AM tomorrow'},\n",
" 'isOpen': False,\n",
" 'isLocalHoliday': False,\n",
" 'dayData': [],\n",
" 'timeframes': [{'days': 'Mon–Wed, Sun',\n",
" 'includesToday': True,\n",
" 'open': [{'renderedTime': '11:30 AM–11:00 PM'}],\n",
" 'segments': []},\n",
" {'days': 'Thu–Sat',\n",
" 'open': [{'renderedTime': '11:30 AM–Midnight'}],\n",
" 'segments': []}]},\n",
" 'popular': {'isOpen': False,\n",
" 'isLocalHoliday': False,\n",
" 'timeframes': [{'days': 'Today',\n",
" 'includesToday': True,\n",
" 'open': [{'renderedTime': 'Noon–2:00 PM'},\n",
" {'renderedTime': '6:00 PM–8:00 PM'}],\n",
" 'segments': []},\n",
" {'days': 'Tue–Thu',\n",
" 'open': [{'renderedTime': 'Noon–2:00 PM'},\n",
" {'renderedTime': '5:00 PM–10:00 PM'}],\n",
" 'segments': []},\n",
" {'days': 'Fri',\n",
" 'open': [{'renderedTime': 'Noon–3:00 PM'},\n",
" {'renderedTime': '5:00 PM–11:00 PM'}],\n",
" 'segments': []},\n",
" {'days': 'Sat',\n",
" 'open': [{'renderedTime': 'Noon–11:00 PM'}],\n",
" 'segments': []},\n",
" {'days': 'Sun',\n",
" 'open': [{'renderedTime': 'Noon–3:00 PM'},\n",
" {'renderedTime': '5:00 PM–8:00 PM'}],\n",
" 'segments': []}]},\n",
" 'pageUpdates': {'count': 0, 'items': []},\n",
" 'inbox': {'count': 0, 'items': []},\n",
" 'attributes': {'groups': [{'type': 'price',\n",
" 'name': 'Price',\n",
" 'summary': '$$',\n",
" 'count': 1,\n",
" 'items': [{'displayName': 'Price', 'displayValue': '$$', 'priceTier': 2}]},\n",
" {'type': 'payments',\n",
" 'name': 'Credit Cards',\n",
" 'summary': 'Credit Cards',\n",
" 'count': 7,\n",
" 'items': [{'displayName': 'Credit Cards',\n",
" 'displayValue': 'Yes (incl. American Express)'}]},\n",
" {'type': 'outdoorSeating',\n",
" 'name': 'Outdoor Seating',\n",
" 'summary': 'Outdoor Seating',\n",
" 'count': 1,\n",
" 'items': [{'displayName': 'Outdoor Seating', 'displayValue': 'Yes'}]},\n",
" {'type': 'serves',\n",
" 'name': 'Menus',\n",
" 'summary': 'Happy Hour, Brunch & more',\n",
" 'count': 8,\n",
" 'items': [{'displayName': 'Brunch', 'displayValue': 'Brunch'},\n",
" {'displayName': 'Lunch', 'displayValue': 'Lunch'},\n",
" {'displayName': 'Dinner', 'displayValue': 'Dinner'},\n",
" {'displayName': 'Happy Hour', 'displayValue': 'Happy Hour'}]},\n",
" {'type': 'drinks',\n",
" 'name': 'Drinks',\n",
" 'summary': 'Beer, Wine & Cocktails',\n",
" 'count': 5,\n",
" 'items': [{'displayName': 'Beer', 'displayValue': 'Beer'},\n",
" {'displayName': 'Wine', 'displayValue': 'Wine'},\n",
" {'displayName': 'Cocktails', 'displayValue': 'Cocktails'}]},\n",
" {'type': 'diningOptions',\n",
" 'name': 'Dining Options',\n",
" 'summary': 'Delivery',\n",
" 'count': 5,\n",
" 'items': [{'displayName': 'Delivery', 'displayValue': 'Delivery'}]}]},\n",
" 'bestPhoto': {'id': '4fad980de4b091b4626c3633',\n",
" 'createdAt': 1336776717,\n",
" 'source': {'name': 'Foursquare for Android',\n",
" 'url': 'https://foursquare.com/download/#/android'},\n",
" 'prefix': 'https://fastly.4sqi.net/img/general/',\n",
" 'suffix': '/ya1iQFI7pLjuIJp1PGDKlrZS3OJdHCF7tpILMmjv_2w.jpg',\n",
" 'width': 480,\n",
" 'height': 640,\n",
" 'visibility': 'public'},\n",
" 'colors': {'highlightColor': {'photoId': '4fad980de4b091b4626c3633',\n",
" 'value': -13619152},\n",
" 'highlightTextColor': {'photoId': '4fad980de4b091b4626c3633', 'value': -1},\n",
" 'algoVersion': 3}}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"result = requests.get(url).json()\n",
"print(result['response']['venue'].keys())\n",
"result['response']['venue']"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### B. Get the venue's overall rating"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7.1\n"
]
}
],
"source": [
"try:\n",
" print(result['response']['venue']['rating'])\n",
"except:\n",
" print('This venue has not been rated yet.')"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"That is not a very good rating. Let's check the rating of the second closest Italian restaurant."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This venue has not been rated yet.\n"
]
}
],
"source": [
"venue_id = '4f3232e219836c91c7bfde94' # ID of Conca Cucina Italian Restaurant\n",
"url = 'https://api.foursquare.com/v2/venues/{}?client_id={}&client_secret={}&v={}'.format(venue_id, CLIENT_ID, CLIENT_SECRET, VERSION)\n",
"\n",
"result = requests.get(url).json()\n",
"try:\n",
" print(result['response']['venue']['rating'])\n",
"except:\n",
" print('This venue has not been rated yet.')"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Since this restaurant has no ratings, let's check the third restaurant."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7.9\n"
]
}
],
"source": [
"venue_id = '3fd66200f964a520f4e41ee3' # ID of Ecco\n",
"url = 'https://api.foursquare.com/v2/venues/{}?client_id={}&client_secret={}&v={}'.format(venue_id, CLIENT_ID, CLIENT_SECRET, VERSION)\n",
"\n",
"result = requests.get(url).json()\n",
"try:\n",
" print(result['response']['venue']['rating'])\n",
"except:\n",
" print('This venue has not been rated yet.')"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Since this restaurant has a slightly better rating, let's explore it further."
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### C. Get the number of tips"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"16"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"result['response']['venue']['tips']['count']"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### D. Get the venue's tips\n",
"> `https://api.foursquare.com/v2/venues/`**VENUE_ID**`/tips?client_id=`**CLIENT_ID**`&client_secret=`**CLIENT_SECRET**`&v=`**VERSION**`&limit=`**LIMIT**"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Create URL and send GET request. Make sure to set limit to get all tips"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'meta': {'code': 200, 'requestId': '5c74c2c8db04f505a38385fb'},\n",
" 'response': {'tips': {'count': 16,\n",
" 'items': [{'id': '5ab1cb46c9a517174651d3fe',\n",
" 'createdAt': 1521601350,\n",
" 'text': 'A+ Italian food! Trust me on this: my mom’s side of the family is 100% Italian. I was born and bred to know good pasta when I see it, and Ecco is one of my all-time NYC favorites',\n",
" 'type': 'user',\n",
" 'canonicalUrl': 'https://foursquare.com/item/5ab1cb46c9a517174651d3fe',\n",
" 'lang': 'en',\n",
" 'likes': {'count': 0, 'groups': []},\n",
" 'logView': True,\n",
" 'agreeCount': 2,\n",
" 'disagreeCount': 0,\n",
" 'todo': {'count': 0},\n",
" 'user': {'id': '484542633',\n",
" 'firstName': 'Nick',\n",
" 'lastName': 'El-Tawil',\n",
" 'gender': 'male',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/484542633_mK2Yum7T_7Tn9fWpndidJsmw2Hof_6T5vJBKCHPLMK5OL-U5ZiJGj51iwBstcpDLYa3Zvhvis.jpg'}},\n",
" 'authorInteractionType': 'liked'},\n",
" {'id': '5247cb68498eeac13eb4c3e1',\n",
" 'createdAt': 1380436840,\n",
" 'text': 'Service was truly excellent- attentive, quick, & friendly. Food was equally amazing- particularly calamari and pollo alla scarpiello. The sauces were incredibly flavorful. Great wine list too! A+++',\n",
" 'type': 'user',\n",
" 'canonicalUrl': 'https://foursquare.com/item/5247cb68498eeac13eb4c3e1',\n",
" 'lang': 'en',\n",
" 'likes': {'count': 0, 'groups': []},\n",
" 'logView': True,\n",
" 'agreeCount': 0,\n",
" 'disagreeCount': 0,\n",
" 'todo': {'count': 0},\n",
" 'user': {'id': '25279241',\n",
" 'firstName': 'Nicole',\n",
" 'lastName': 'F',\n",
" 'gender': 'female',\n",
" 'photo': {'prefix': 'https://fastly.4sqi.net/img/user/',\n",
" 'suffix': '/SDJDCS2XH2USIRK0.jpg'}}}]}}}"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## Ecco Tips\n",
"limit = 15 # set limit to be greater than or equal to the total number of tips\n",
"url = 'https://api.foursquare.com/v2/venues/{}/tips?client_id={}&client_secret={}&v={}&limit={}'.format(venue_id, CLIENT_ID, CLIENT_SECRET, VERSION, limit)\n",
"\n",
"results = requests.get(url).json()\n",
"results"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Get tips and list of associated features"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['id', 'createdAt', 'text', 'type', 'canonicalUrl', 'lang', 'likes', 'logView', 'agreeCount', 'disagreeCount', 'todo', 'user', 'authorInteractionType'])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tips = results['response']['tips']['items']\n",
"\n",
"tip = results['response']['tips']['items'][0]\n",
"tip.keys()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Format column width and display all tips"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>text</th>\n",
" <th>agreeCount</th>\n",
" <th>disagreeCount</th>\n",
" <th>id</th>\n",
" <th>user.firstName</th>\n",
" <th>user.lastName</th>\n",
" <th>user.gender</th>\n",
" <th>user.id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>A+ Italian food! Trust me on this: my mom’s side of the family is 100% Italian. I was born and bred to know good pasta when I see it, and Ecco is one of my all-time NYC favorites</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>5ab1cb46c9a517174651d3fe</td>\n",
" <td>Nick</td>\n",
" <td>El-Tawil</td>\n",
" <td>male</td>\n",
" <td>484542633</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Service was truly excellent- attentive, quick, &amp; friendly. Food was equally amazing- particularly calamari and pollo alla scarpiello. The sauces were incredibly flavorful. Great wine list too! A+++</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>5247cb68498eeac13eb4c3e1</td>\n",
" <td>Nicole</td>\n",
" <td>F</td>\n",
" <td>female</td>\n",
" <td>25279241</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" text \\\n",
"0 A+ Italian food! Trust me on this: my mom’s side of the family is 100% Italian. I was born and bred to know good pasta when I see it, and Ecco is one of my all-time NYC favorites \n",
"1 Service was truly excellent- attentive, quick, & friendly. Food was equally amazing- particularly calamari and pollo alla scarpiello. The sauces were incredibly flavorful. Great wine list too! A+++ \n",
"\n",
" agreeCount disagreeCount id user.firstName \\\n",
"0 2 0 5ab1cb46c9a517174651d3fe Nick \n",
"1 0 0 5247cb68498eeac13eb4c3e1 Nicole \n",
"\n",
" user.lastName user.gender user.id \n",
"0 El-Tawil male 484542633 \n",
"1 F female 25279241 "
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.set_option('display.max_colwidth', -1)\n",
"\n",
"tips_df = json_normalize(tips) # json normalize tips\n",
"\n",
"# columns to keep\n",
"filtered_columns = ['text', 'agreeCount', 'disagreeCount', 'id', 'user.firstName', 'user.lastName', 'user.gender', 'user.id']\n",
"tips_filtered = tips_df.loc[:, filtered_columns]\n",
"\n",
"# display tips\n",
"tips_filtered"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Now remember that because we are using a personal developer account, then we can access only 2 of the restaurant's tips, instead of all 15 tips."
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<a id=\"item3\"></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"## 3. Search a Foursquare User\n",
"> `https://api.foursquare.com/v2/users/`**USER_ID**`?client_id=`**CLIENT_ID**`&client_secret=`**CLIENT_SECRET**`&v=`**VERSION**"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Define URL, send GET request and display features associated with user"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['id', 'firstName', 'lastName', 'gender', 'canonicalUrl', 'photo', 'friends', 'tips', 'homeCity', 'bio', 'contact', 'photos', 'type', 'mayorships', 'checkins', 'lists', 'lenses'])"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"user_id = '484542633' # user ID with most agree counts and complete profile\n",
"\n",
"url = 'https://api.foursquare.com/v2/users/{}?client_id={}&client_secret={}&v={}'.format(user_id, CLIENT_ID, CLIENT_SECRET, VERSION) # define URL\n",
"\n",
"# send GET request\n",
"results = requests.get(url).json()\n",
"user_data = results['response']['user']\n",
"\n",
"# display features associated with user\n",
"user_data.keys()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"First Name: Nick\n",
"Last Name: El-Tawil\n",
"Home City: New York, NY\n"
]
}
],
"source": [
"print('First Name: ' + user_data['firstName'])\n",
"print('Last Name: ' + user_data['lastName'])\n",
"print('Home City: ' + user_data['homeCity'])"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### How many tips has this user submitted?"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'count': 241}"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"user_data['tips']"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"Wow! So it turns out that Nick is a very active Foursquare user, with more than 250 tips."
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Get User's tips"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"button": false,
"collapsed": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>text</th>\n",
" <th>agreeCount</th>\n",
" <th>disagreeCount</th>\n",
" <th>id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>The best! I’m especially fond of the salmon burger, but I’ve had half of the menu and never been disappointed. There’s a reason this place is well known even outside of the Village!</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5aec594b1f7440002c138612</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>I used to down a pint of chocolate like it was nothing back when I was bulking. Highly recommended!</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5accc9f66fa81f196724807b</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>They serve coffee!!!!!!</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5accc98c0313204c9d7ec157</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>I’m a fan. In fact, I’m such a big fan, I want Taim to hire me to be their spokesman. Kind of like the Arabic Jared Fogle - but without the kid stuff.</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5accbf033abcaf09a24612a0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>The linguine with clams is on point 👌</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5accbe3a911fc423730f3ed3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Great for a quick, cheap lunch! Shorter lines than Chipotle too👌</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5acbecb86fa81f1967e019b0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Quick, cheap lunch that tastes good! Way shorter line than Chipotle, too.</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5acbec70a0215b732e264fe8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>You’re not a real New Yorker until you’ve shame-ordered Insomnia Cookies for delivery at 3am</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5acbbd4eb1538e45373b07f5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Good for you yet still tasty! Clean green protein is my go-to after I hit the gym 💪</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>5acbbcda01235808d5d6dc75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Coffee game on point</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5acbbb1501235808d5d6525e</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>This is the dive bar to end all other dive bars. Go here if you like cheap drinks! 🥃</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5ab576abea1e444f2abb051e</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Burger game strong 💪</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5ab575fb6bdee65f759da8c1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Great burgers &amp; fries! Also, this place is exactly what it’s like when you go to a bar in the Southwest. Source: I’m from Arizona.</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>5ab5575d73fe2516ad8f363b</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>That guy looks familiar...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5ab5299635f98312029a53b7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Açaí bowl + peanut butter + whey protein = 💪💪💪</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>5ab42db53c858d64af2688a4</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" text \\\n",
"0 The best! I’m especially fond of the salmon burger, but I’ve had half of the menu and never been disappointed. There’s a reason this place is well known even outside of the Village! \n",
"1 I used to down a pint of chocolate like it was nothing back when I was bulking. Highly recommended! \n",
"2 They serve coffee!!!!!! \n",
"3 I’m a fan. In fact, I’m such a big fan, I want Taim to hire me to be their spokesman. Kind of like the Arabic Jared Fogle - but without the kid stuff. \n",
"4 The linguine with clams is on point 👌 \n",
"5 Great for a quick, cheap lunch! Shorter lines than Chipotle too👌 \n",
"6 Quick, cheap lunch that tastes good! Way shorter line than Chipotle, too. \n",
"7 You’re not a real New Yorker until you’ve shame-ordered Insomnia Cookies for delivery at 3am \n",
"8 Good for you yet still tasty! Clean green protein is my go-to after I hit the gym 💪 \n",
"9 Coffee game on point \n",
"10 This is the dive bar to end all other dive bars. Go here if you like cheap drinks! 🥃 \n",
"11 Burger game strong 💪 \n",
"12 Great burgers & fries! Also, this place is exactly what it’s like when you go to a bar in the Southwest. Source: I’m from Arizona. \n",
"13 That guy looks familiar... \n",
"14 Açaí bowl + peanut butter + whey protein = 💪💪💪 \n",
"\n",
" agreeCount disagreeCount id \n",
"0 1 0 5aec594b1f7440002c138612 \n",
"1 1 0 5accc9f66fa81f196724807b \n",
"2 1 0 5accc98c0313204c9d7ec157 \n",
"3 1 0 5accbf033abcaf09a24612a0 \n",
"4 1 0 5accbe3a911fc423730f3ed3 \n",
"5 1 0 5acbecb86fa81f1967e019b0 \n",
"6 1 0 5acbec70a0215b732e264fe8 \n",
"7 1 0 5acbbd4eb1538e45373b07f5 \n",
"8 2 0 5acbbcda01235808d5d6dc75 \n",
"9 1 0 5acbbb1501235808d5d6525e \n",
"10 1 0 5ab576abea1e444f2abb051e \n",
"11 1 0 5ab575fb6bdee65f759da8c1 \n",
"12 2 0 5ab5575d73fe2516ad8f363b \n",
"13 1 0 5ab5299635f98312029a53b7 \n",
"14 1 0 5ab42db53c858d64af2688a4 "
]
},
"execution_count": 24,