Summary:
This article explains how to export all Cloud Save player data (player IDs and associated userAccountInfo key-value pairs) when the dataset is very large (e.g., hundreds of thousands of records). It describes the need for a service account with appropriate permissions, how to use the paginated Cloud Save Admin API to retrieve all player IDs and items, and how to approach automating this process
Title:
Exporting All Cloud Save Player Data via Paginated Admin API
Symptoms:
- You need to do a complete extraction of all players' data.
Challenges:
The Cloud Save Admin API returns player data in a paginated manner, limiting each request to a maximum of 100 players. When the number of players is very large, attempting to manually retrieve all data becomes impractical. As the support team does not have direct access to export all project player data on behalf of customers, the export must be performed programmatically by the project owner or an authorized service.
Resolution:
1. Create or use a service account:
- Ensure you have a service account with the "Cloud Save Viewer" role to access Cloud Save Admin APIs for your project and environment.
2. Retrieve all player IDs using the Admin API:
- Call the “Get Cloud Save players” Admin API endpoint.
- Use the pagination parameters (e.g., page size up to 100 and continuation/next page tokens) to iterate through all pages until no further pages remain.
- Collect all returned player IDs in your script or application.
3. Fetch player data for each player ID:
- For every player ID, call the Admin API endpoints to:
- Get Player Items (general items)
- Get Public Items (publicly accessible data)
- Get Private Items (private data, if required and permitted)
- Get Protected Items (hidden data not available to player devices)
- Extract the required key-value pairs, such as userAccountInfo, from the returned data.
4. Automate the process with a script:
- Implement an automated script (for example, in Python, Node.js, or another language) that:
- Iterates through all pages of player IDs.
- For each player ID, fetches the relevant items and fields.
- Handle retries and timeouts to make the process resilient to network interruptions.
5. Generate the CSV export:
- Define the CSV columns (e.g., playerId, and each required userAccountInfo key).
- As your script processes each player, append a row to the CSV.
- Continue until all pages and all player IDs have been processed.
6. Operational considerations:
- Because the process is paginated and script-driven, you can start and stop at convenient times and track progress (e.g., last processed page or player ID).
- This approach avoids relying on a single long-running “download all” operation that could be more prone to timeouts or failures over HTTP.
- Player IDs are retrieved alphabetically, and so players joining the game whilst you are performing this process may be missed in a single pass.
By following these steps, you can programmatically retrieve all player IDs and associated userAccountInfo data, and produce a complete CSV export for large player datasets.