Produk atau fitur ini memiliki status Lama. Untuk informasi selengkapnya tentang status Lama, lihat Produk dan fitur lama. Untuk bermigrasi ke Places API for iOS(New), lihat Panduan migrasi.
Place Autocomplete (Lama) menggunakan token sesi untuk mengelompokkan fase kueri dan pemilihan penelusuran pelengkapan otomatis pengguna ke dalam sesi terpisah untuk tujuan penagihan. Sesi dimulai saat pengguna mulai mengetik kueri, dan berakhir saat mereka memilih tempat dan panggilan ke Place Details (Lama) dilakukan. Setiap sesi dapat
memiliki beberapa kueri pelengkapan otomatis, yang diikuti dengan satu pilihan tempat. Kunci API
yang digunakan untuk setiap permintaan dalam sesi harus berasal dari project konsol Google Cloud yang sama. Setelah sesi selesai, token tidak lagi
valid; aplikasi Anda harus membuat token baru untuk setiap sesi. Jika parameter sessiontoken dihilangkan, atau jika Anda menggunakan kembali token sesi, sesi tersebut dikenai biaya seolah-olah tidak ada token sesi yang diberikan (setiap permintaan ditagih secara terpisah).
Sebaiknya ikuti panduan berikut:
Gunakan token sesi untuk semua sesi pelengkapan otomatis.
Pastikan kunci API yang digunakan untuk semua permintaan Place Autocomplete (Lama) dan Place Details (Lama)
dalam sesi berasal dari project konsol Google Cloud yang sama.
Pastikan untuk meneruskan token sesi yang unik untuk setiap sesi baru. Jika menggunakan token yang sama untuk lebih dari satu sesi, setiap permintaan akan ditagih satu per satu.
Anda dapat memilih untuk menghapus token sesi pelengkapan otomatis dari permintaan. Jika
token sesi dihilangkan, setiap permintaan ditagih secara terpisah, yang memicu
SKU
Autocomplete - Per Request. Jika Anda menggunakan kembali token sesi, sesi tersebut dianggap tidak valid dan permintaan akan dikenai biaya seolah-olah tidak ada token sesi yang diberikan.
Contoh
Saat pengguna mengetik kueri, permintaan pelengkapan otomatis dipanggil setiap beberapa
ketukan tombol (bukan per karakter), dan daftar kemungkinan hasil akan ditampilkan.
Saat pengguna membuat pilihan dari daftar hasil, pilihan tersebut dihitung sebagai
permintaan, dan semua permintaan yang dibuat selama penelusuran dipaketkan dan
dihitung sebagai satu permintaan. Jika pengguna memilih tempat, kueri penelusuran tersedia tanpa biaya, dan hanya permintaan data Tempat yang dikenai biaya. Jika pengguna tidak membuat
pilihan dalam beberapa menit sejak awal sesi, hanya
kueri penelusuran yang akan ditagih.
Mari kita periksa alur peristiwa ini dari perspektif aplikasi.
Pengguna mulai mengetik kueri untuk menelusuri "Paris, Prancis".
Setelah mendeteksi input pengguna, aplikasi akan membuat token sesi
baru, "Token A".
Saat pengguna mengetik, API akan membuat permintaan pelengkapan otomatis setiap beberapa
karakter, menampilkan daftar baru potensi hasil untuk setiap karakter:
"P"
"Par"
"Paris,"
"Paris, Fr"
Saat pengguna membuat pilihan:
Semua permintaan yang dihasilkan dari kueri dikelompokkan dan ditambahkan ke sesi yang diwakili oleh "Token A", sebagai satu permintaan.
Pilihan pengguna dihitung sebagai permintaan Place Detail, dan ditambahkan ke sesi yang diwakili oleh "Token A".
Sesi selesai, dan aplikasi menghapus "Token A".
Untuk informasi selengkapnya tentang cara penagihan permintaan Place Autocomplete (Lama), lihat
Penggunaan dan Penagihan.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Session Tokens\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/session-tokens \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/session-tokens \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/places-autocomplete#session_tokens \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/places/web-service/session-tokens \"View this page for the Web Service platform docs.\")\n\nPlace Autocomplete (Legacy) uses session tokens to group the query and selection\nphases of a user autocomplete search into a discrete session for billing\npurposes. The session begins when the user starts typing a query, and concludes\nwhen they select a place and a call to Place Details (Legacy) is made. Each session can\nhave multiple autocomplete queries, followed by one place selection. The API\nkey(s) used for each request within a session must belong to the same\nGoogle Cloud console project. Once a session has concluded, the token is no longer\nvalid; your app must generate a fresh token for each session. If the\n`sessiontoken` parameter is omitted, or if you reuse a session\ntoken, the session is charged as if no session token was provided (each request\nis billed separately).\n\nWe recommend the following guidelines:\n\n- Use session tokens for all autocomplete sessions.\n- [Generate a fresh token](#create-session-tokens) for each session.\n- Ensure that the API key(s) used for all Place Autocomplete (Legacy) and Place Details (Legacy) requests within a session belong to the same Google Cloud console project.\n- 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.\n\nYou can optionally omit the autocomplete session token from a request. If\nthe session token is omitted, each request is billed separately, triggering the\n\n[Autocomplete - Per Request](/maps/billing-and-pricing/sku-details#autocomplete-request-new-ess-sku)\n\n\nSKU. If you reuse a session token, the session is considered invalid and the\nrequests are charged as if no session token was provided.\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.\nWhen the user makes a selection from the result list, the selection counts as\na request, and all of the requests made during the search are bundled and\ncounted as a single request. If the user selects a place, the search query is\navailable at no charge, and only the Place data request is charged. If the user does not make a\nselection 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 Place Autocomplete (Legacy) requests are billed, see\n\n[Usage and Billing](/maps/documentation/places/ios-sdk/usage-and-billing).\n\nCreate session tokens\n---------------------\n\n\nTo create a session token, call\n[`GMSAutocompleteSessionToken.init()`](/maps/documentation/places/ios-sdk/reference/interface_g_m_s_autocomplete_session_token)."]]