API GET response not sent to Notebook

Using the TomTom API for the first time, and also completely new to coding, so permit me if I don’t present the issue very well.

I’m using this code to get a json result:
url = requests.get(‘https://api.tomtom.com/search/2/search/43.67910515%2C-79.49118414007154.json?limit=10&radius=50&idxSet=Addr&key=APIKEYHERE’)

It ran properly, and got a response 200, but the problem is, I want the actual result to be made available on the jupyter notebook.

Secondly, I used the result from above(maneuvered the result) to create a function call getAround, then called it using this:
York_Spots=getAround(names=York_bor[‘Neighborhood’],latitudes=York_bor[‘Latitude’], longitudes=York_bor[‘Longitude’])

The result should be a map, but all I get is -Response, which I think means it works but can display on the notebook.

This is getting too long, but I hope I passed the message.


Welcome to our community! :slight_smile:

I’m not sure I fully understand your questions. Your query works perfectly inside the Jupyter notebook. To visualize the map you might want to try Folium. Here you can find an example source code:

import requests
import folium

apiKey = 'YOUR_API_KEY'
initial_location = [43.67910515,-79.4911]

def get_tomtom_map(key, location, zoom):
    maps_url = "http://{s}.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.png?key="
    ttmap = folium.Map(
    location = location,
    zoom_start = zoom,
    tiles = str(maps_url + key),
    attr = 'TomTom')
    return ttmap

def get_coords(position):
    return [position['lat'], position['lon']]

ttmap = get_tomtom_map(apiKey, initial_location, 17)

searchResults = requests.get('https://api.tomtom.com/search/2/search/{lat}%2C{lon}.json?limit=10&radius=50&idxSet=Addr&key={key}'.format(key=apiKey, lat=location[0], lon=location[1]))

for result in searchResults.json()['results']:


The end result based on your initial query looks like this:

Hope this helps a little bit :crossed_fingers:


1 Like

Hi, I am trying to extract JSON using the tomtom URL, but I am not getting any results.

Country = CA
Borough = Scarborough
Postal_Code = M1B
API_KEY = tomtom’s API Key for my account

URL = ‘https://api.tomtom.com/search/2/structuredGeocode.json?countryCode={}&municipality={}}&postalCode={}&key={}’.format(Country, Borough, Postal_Code, API_KEY)

results = requests.get(URL).json()

Is there anything I am missing?
Your help is very much appreciated.

Hmm… just fixed quotes etc. and it is working

import requests

Country = 'CA'
Borough = 'Scarborough'
Postal_Code = 'M1B'
API_KEY = 'apikey'

URL = 'https://api.tomtom.com/search/2/structuredGeocode.json?countryCode={}&municipality={}&postalCode={}&key={}'.format(Country, Borough, Postal_Code, API_KEY)

results = requests.get(URL).json()