As per the Google documentation if we use a sessiontoken
in the autocomplete API followed by placeDetails
api then subsequent all the calls will be grouped together and it will be billed as a single request. But while using, it is actually not happening and Google counts all of the requests as individual.
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=s&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=st&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=sta&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=stat&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=stati&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=statio&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=station&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8&location=37.4220309%2C-122.0839848&radius=5000&strictbounds=true
I/flutter (12295): Get URI: https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJr3mngX66j4ARcUF6Ln6aAmk&key=<API_KEY>&sessiontoken=d7f1f97f-621d-45cf-b8fd-38d74c976fd8
I/flutter (12295): Instance of 'PlaceDetails'
In the above scenario, based on the documentation it should have counted as a single request but in the Google console - API usage, it's showing as 9 separate requests.
Is it the right way to use sessiontoken? Am I missing something?
Edit > Added logs for two search groups with placeDetails API. The sessiontoken are being refreshed after every the place details.
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=sta&key=<API_KEY>&sessiontoken=3dd4163e-c5aa-4504-a652-0c7861704efa&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=stat&key=<API_KEY>&sessiontoken=3dd4163e-c5aa-4504-a652-0c7861704efa&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=station&key=<API_KEY>&sessiontoken=3dd4163e-c5aa-4504-a652-0c7861704efa&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/details/json?place_id=<PLACE_DETAILS>&key=<API_KEY>&sessiontoken=3dd4163e-c5aa-4504-a652-0c7861704efa
I/flutter (17558): Instance of 'PlaceDetails'
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=sch&key=<API_KEY>&sessiontoken=a204cfe5-0824-4e2c-8fe6-5382ef542e76&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=scho&key=<API_KEY>&sessiontoken=a204cfe5-0824-4e2c-8fe6-5382ef542e76&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=schoo&key=<API_KEY>&sessiontoken=a204cfe5-0824-4e2c-8fe6-5382ef542e76&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=school&key=<API_KEY>&sessiontoken=a204cfe5-0824-4e2c-8fe6-5382ef542e76&location=22.863185%2C87.3552233&radius=5000&strictbounds=true
I/flutter (17558): Get URI: https://maps.googleapis.com/maps/api/place/details/json?place_id=<PLACE_DETAILS>&key=<API_KEY>&sessiontoken=a204cfe5-0824-4e2c-8fe6-5382ef542e76
I/flutter (17558): Instance of 'PlaceDetails'