Invalid locations count as API hits
Closed this issue · 1 comments
bradasteiner commented
Hi, I noticed that if a location does not exist in street view, it still counts as an API hit on the google API console. However I noticed that the following code will not count misses:
import google_streetview.api
rand_lat = "{:.6f}".format(random.uniform(-90, 90))
rand_lon = "{:.6f}".format(random.uniform(-180, 180))
rand_heading = "{:.4f}".format(random.uniform(0, 360))
# Define parameters for street view api
params = [{
'size': '640x640', # max 640x640 pixels
'location': rand_lat + ',' + rand_lon,
'heading': rand_heading,
'pitch': '0',
'key': ''
}]
# Create a results object
results = google_streetview.api.results(params)
results.download_links('images')
Would it be possible to incorporate this approach instead?
hugovk commented
You're right, it does count hits even if there's no image available.
Sure, if you'd like to try using the google_streetview
library, or seeing what the library itself does, PRs are welcome.
Alternatively, have a look at PR #5 (stuck in review), which uses a metadata endpoint to reduce the number of hits. I expect the library uses the same approach.