نشانههای جلسه، مراحل پرس و جو و انتخاب یک جستجوی تکمیل خودکار کاربر را در یک جلسه مجزا برای اهداف صورتحساب گروهبندی میکنند.
یک نشانه جلسه ایجاد کنید
کاربران مسئول تولید نشانه های جلسه منحصر به فرد برای هر جلسه هستند. گوگل استفاده از UUID های نسخه 4 را توصیه می کند.
مثال
همانطور که کاربر یک پرس و جو را تایپ می کند، هر چند ضربه کلید (نه به ازای هر کاراکتر) یک درخواست تکمیل خودکار فراخوانی می شود و لیستی از نتایج ممکن برگردانده می شود. هنگامی که کاربر انتخابی را از لیست نتایج انجام می دهد، انتخاب به عنوان یک درخواست حساب می شود و همه درخواست های انجام شده در طول جستجو به صورت دسته بندی شده و به عنوان یک درخواست شمارش می شوند. اگر کاربر مکانی را انتخاب کند، درخواست جستجو بدون هزینه در دسترس است و فقط درخواست داده مکان هزینه می شود. اگر کاربر ظرف چند دقیقه پس از شروع جلسه انتخابی انجام ندهد، فقط درخواست جستجو شارژ می شود.
بیایید این جریان رویدادها را از منظر یک اپلیکیشن بررسی کنیم.
کاربر شروع به تایپ یک پرس و جو برای جستجوی "پاریس، فرانسه" می کند.
پس از شناسایی ورودی کاربر، برنامه یک نشانه جلسه جدید، "Token A" ایجاد می کند.
همانطور که کاربر تایپ می کند، API هر چند کاراکتر یک درخواست تکمیل خودکار می کند و لیست جدیدی از نتایج بالقوه را برای هر یک نمایش می دهد: "پ" "پار" "پاریس" "پاریس، فر"
هنگامی که کاربر انتخاب می کند:
تمام درخواست های حاصل از پرس و جو گروه بندی می شوند و به عنوان یک درخواست به جلسه ارائه شده توسط "Token A" اضافه می شوند.
انتخاب کاربر به عنوان یک درخواست جزئیات مکان شمارش می شود و به جلسه ای که با "Token A" نشان داده می شود اضافه می شود.
جلسه به پایان می رسد و برنامه "Token A" را کنار می گذارد.
برای اطلاعات بیشتر درباره نحوه صدور صورتحساب درخواستهای تکمیل خودکار، استفاده و صورتحساب را ببینید.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eSession tokens associate autocomplete search queries and selections for billing, ensuring accurate charges based on user interactions.\u003c/p\u003e\n"],["\u003cp\u003eEach new search session requires a unique, user-generated token, ideally a version 4 UUID, to track related requests.\u003c/p\u003e\n"],["\u003cp\u003eAutocomplete requests during a search are grouped and billed as a single request when the user makes a selection, charging only for Place data if a place is chosen.\u003c/p\u003e\n"],["\u003cp\u003eIf no selection is made within a few minutes, only the search query is billed, attributing costs to the initial search activity.\u003c/p\u003e\n"],["\u003cp\u003eSession tokens are project-specific, allowing reuse across different Google Cloud projects but requiring uniqueness within the same project for proper billing.\u003c/p\u003e\n"]]],["Session tokens group user autocomplete searches for billing. Generate unique session tokens (e.g., version 4 UUIDs) per project. As users type, autocomplete requests are made. Upon selection, all requests are bundled into a single, session-token-linked request. If a place is selected, only the Place data request is charged. Otherwise, only the search query is charged. If no selection is made, the session times out, and only the search query is billed. Discard the token after the session.\n"],null,["# Using session tokens\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/using-session-tokens \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/using-session-tokens \"View this page for the iOS platform docs.\") [Web Service](/maps/documentation/places/web-service/using-session-tokens \"View this page for the Web Service platform docs.\")\n\n\u003cbr /\u003e\n\nSession tokens group the query and selection phases of a user autocomplete\nsearch into a discrete session for billing purposes.\n\nCreate a session token\n----------------------\n\nUsers are responsible for generating unique session tokens for each session.\nGoogle recommends using [version 4 UUIDs](https://tools.ietf.org/html/rfc4122).\n| **Note:** Session tokens can overlap across Google Cloud Console projects, but they must be unique per project. For example, an app using Project A and an app using Project B can use the same session token, but multiple apps using Project A cannot use the same session token.\n\nExample\n-------\n\nAs the user types a query, an autocomplete request is called every few\nkeystrokes (not per-character), and a list of possible results is returned. When\nthe user makes a selection from the result list, the selection counts as a\nrequest, and all of the requests made during the search are bundled and counted\nas a single request. If the user selects a place, the search query is available\nat no charge, and only the Place data request is charged. If the user does not\nmake a selection within a few minutes of the beginning of the session, only the\nsearch query is charged.\n\nLet's examine this flow of events from the perspective of an app.\n\n1. A user begins typing a query to search for \"Paris, France\".\n2. Upon detecting user input, the app creates a new session token, \"Token A\".\n3. As the user types, the API makes an autocomplete request every few characters, displaying a new list of potential results for each: \n \"P\" \n \"Par\" \n \"Paris,\" \n \"Paris, Fr\" \n4. When the user makes a selection:\n - All requests resulting from the query are grouped and added to the session represented by \"Token A\", as a single request.\n - The user's selection is counted as a Place Detail request, and added to the session represented by \"Token A\".\n5. The session is concluded, and the app discards \"Token A\".\n\nFor more information about how Autocomplete requests are billed, see [Usage and\nBilling](/maps/documentation/places/android-sdk/usage-and-billing)."]]