flutter_google_places icon indicating copy to clipboard operation
flutter_google_places copied to clipboard

Google Places Pricing Per Session or Per Request

Open benneynens opened this issue 5 years ago • 8 comments

I typed a place name 14 characters in length, and within console.cloud.google.com the # of requests increased by 14.

Does this mean that the sessionToken is not working correctly? I'm just playing around using the test project main.dart file.

Any idea if the result of the above is 14 x requests (at $2.83/1000) or 14 x sessions (at $17/1000)

My understanding was that if implemented correctly, you can type unlimited characters in an autocomplete field for one place, and just be charged for a single session (at $17/1000). Ie. 1 session per place, not per character. Not sure if I'm right on that though.

benneynens avatar May 05 '20 02:05 benneynens

i have same problem

domizilver avatar May 07 '20 15:05 domizilver

It seems like API is called with every single character you type in. If this is the case it's going to be very expensive :( Can someone from Google team please clarify this issue.

shubhambansal avatar Jun 04 '20 23:06 shubhambansal

@benneynens As a temporary solution, I am using 'offset' field of PlacesAutocomplete class.

shubhambansal avatar Jun 04 '20 23:06 shubhambansal

Thanks for that. I've put a hold on my flutter app and am doing it as a web app instead.

On Fri, Jun 5, 2020 at 9:24 AM Shubham Bansal [email protected] wrote:

@benneynens https://github.com/benneynens As a temporary solution, I am using 'offset' field of PlacesAutocomplete class.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fluttercommunity/flutter_google_places/issues/113#issuecomment-639168095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJNWE4FTYCIA6TFVUARVMS3RVAUJDANCNFSM4MZGNQ6A .

benneynens avatar Jun 06 '20 02:06 benneynens

I believe that this library can do this by default but according to Place API docs, we're supposed to handle this: https://developers.google.com/places/web-service/autocomplete

Google recommends the following:

  • Use session tokens for all autocomplete sessions.
  • Generate a fresh token for each session. Using a version 4 UUID is recommended.
  • Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Google Cloud Console project.
  • Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.

Have you guys tried settings the sessionToken? I haven't tested this myself but the the attribute is there.

image

charleshan avatar Jul 14 '20 17:07 charleshan

Use session tokens

https://www.youtube.com/watch?v=mzqgVWli6k0

MuzavaziTawa avatar Oct 15 '20 06:10 MuzavaziTawa

I am having the same issue, any update on this?

bcbcbcbcbcl avatar Jun 15 '22 15:06 bcbcbcbcbcl

@benneynens What you saw is the number of request, not the number of session. If you read the doc carefully, you see:

An Autocomplete session includes some Autocomplete requests (to retrieve suggestions on a place as the user types), and at most one Places Details request (to retrieve details about the place selected by the user).

If I understand correctly, as long as we include a session token, no matter how many requests we make in a session, we will only be charged once.

As for the duration of a session, there is no definitive answer, here's what Google says:

The Autocomplete without Place Details – Per Session SKU is charged for an Autocomplete session that does not include a Place Details request (within a few minutes of the beginning of the session).

LogicNg avatar Jul 01 '22 08:07 LogicNg