Hi all
I have this python code the retrieve an image of a specific address via API. Can someone help me to find out why i get an empty response? Thank you so much!
import requests
Set up API endpoint and parameters
endpoint = “https://graph.mapillary.com/images”
params = {
“access_token”: “Client Secret”,
“query”: “{ "
’ search(n:1, query:”{ADDRESS}") { ’
" edges { "
" node { "
" id "
" thumb_url "
" } "
" } "
" } "
“}”,
}
Replace {ADDRESS} with the address you want to search for
address = “1600 Pennsylvania Ave NW, Washington, DC 20500”
params[“query”] = params[“query”].replace(“{ADDRESS}”, address)
Make a request to the Mapillary API
response = requests.get(endpoint, params=params)
Retrieve the URL of the image
if response.status_code == 200 and len(response.json()[“data”][“search”][“edges”]) > 0:
image_url = response.json()[“data”][“search”][“edges”][0][“node”][“thumb_url”]
print(image_url)
else:
print(“Unable to retrieve image”)