Steamworks-Dokumentation
ICloudService-Schnittstelle
Bietet Zugriff auf die Steam-Cloud-Dateien eines Steam-Benutzers. Dies ermöglicht hauptsächlich die plattformübergreifende Speicherung Ihres Spiels. Die Steam-Version Ihres Spiels kann die Steamworks-Cloud-Funktionen verwenden (entweder über die ISteamRemoteStorage-API oder die Steam Auto-Cloud). Nicht-Steam-Versionen können diese WebAPI verwenden, um auf die Dateien zuzugreifen und neue Versionen hochzuladen.

Ihr Spiel benötigt die Zugangsberechtigung vom Benutzer, um auf dessen Steam-Cloud-Dateien zugreifen zu können. Dies ist über OAuth möglich. Beachten Sie bitte, dass die Berechtigungen read_cloud und write_cloud erforderlich sind.

Weitere Informationen finden Sie auch in der allgemeinen Steam-Dokumentation WebAPI-Übersicht, insbesondere dem Abschnitt „Service-Schnittstellen“. GET-Anfragen können mit Parametern in der URL durchgeführt werden. Es ist allerdings für POST-Anfragen empfohlen, dass sich alle Parameter im Textkörper der Anfrage befinden. Der Parameter access-token ist direkt Form-kodiert und die übrigen Parameter sollten sich in einer JSON-Struktur befinden, die über das Feld input-json festgelegt werden können.

Antworten auf wohlgeformte und authentifizierte Anfragen sind üblicherweise 200 OK. Jedoch kann die Anfrage fehlschlagen: der detaillierte Steam-Fehlercode befindet sich in der Kopfzeile von x-eresult. Der Wert für „success“ ist 1. Alle übrigen Werte sind wahrscheinlich Fehler; weitere Details finden Sie in der Dokumentation für steam_api.h.

Aufzählung von Dateien

Benötigt OAuth-Zugriff auf read_cloud.

EnumerateUserFiles


Beispiel:
GET https://api.steampowered.com/ICloudService/EnumerateUserFiles/v1/?access_token=<token>&appid=1234&extended_details=1 HTTP/1.1 Host: api.steampowered.com Content-Length: 0

NameTypErforderlich?Beschreibung
access_tokenstringOAuth-Zugriffstoken für den Benutzer
appiduint32Ihre App-ID
extended_detailsboolBeinhaltet Details wie Download-Links für die Dateien
countuint32Die max. Anzahl der aufzuzählenden Dateien (Standardeinstellung: 500)
start_indexuint32Anfangsindexnummer der aufzuzählenden Datei (Standardeinstellung: 0)

Zählt die Steam-Cloud-Dateien des Benutzers für Ihr Spiel auf. Beginnt mit einem „start_index“ von null und wird, wenn nötig, wiederholt, wenn der Benutzer mehr als „count“ Dateien hat.

Die Antwort hat 2 Felder:
NameTypBeschreibung
filessiehe untenEine Liste von Dateidetails
total_filesuint32Die Gesamtzahl der Dateien, die der Benutzer für Ihre Anwendung in der Steam Cloud hat.

Die Dateiliste enthält die folgenden Informationen:
NameTypBeschreibung
appiduint32Dieselbe App-ID
ugciduint64Einzigartige Datei-ID
filenamestringDer Dateiname
timestampuint64Zeitpunkt der letzten Änderung an der Datei in Unixzeit
file_sizeuint64Die Dateigröße in Byte
urlstringEine URL, die zum Herunterladen der Datei verwendet werden kann.
steamid_creatoruint64Die Steam-ID des Benutzers
flagsuint64Nur zur internen Verwendung durch Steam
platforms_to_syncuint32Liste der Plattformen, für die diese Datei gültig ist. Siehe Hochladen von Dateien für die Liste der möglichen Werte.
file_shastringHex-String (40 Zeichen), die den SHA1-Digest der Datei repräsentiert.

Dateien herunterladen


Um eine Datei herunterzuladen, müssen Sie eine GET-Anfrage an die oben von EnumerateFiles zurückgegebene URL stellen.

Dateien bearbeiten


Benötigt OAuth-Zugriff auf write_cloud.

Die Bearbeitung von Dateien umfasst das Hochladen neuer Dateien und neuer Versionen bestehender Dateien sowie das Löschen von Dateien aus der Steam Cloud.

Eine Reihe von Änderungen an Dateien sollten in einen Batch gepackt werden. Batches werden zur Übermittlung einer Absicht für Ihren Satz an Änderungen an die Steam Cloud verwendet und helfen die Wahrscheinlichkeit von Dateikonflikten zu reduzieren.

Eine vollständige Batch-Sequenz sieht wie folgt aus:

  • BeginAppUploadBatch-Aufruf, der die vorgesehenen Uploads und Löschungen aufführt.
  • 0 oder mehr uploads unter Verwendung der folgenden Reihenfolge:
    • BeginHTTPUpload
    • HTTP-Operation PUT zum Hochladen der Datei
    • CommitHTTPUpload
  • 0 oder mehr deletes (Löschungen) unter Verwendung von Delete
  • CompleteAppUploadBatch

Hinweis: Sie müssen CompleteAppUploadBatch aufrufen, egal, ob alle Uploads und/oder Löschungen vollständig erfolgreich waren oder nicht. Failing to call CompleteAppUploadBatch will result in a time period of several minutes where new upload attempts for this user and app are blocked with a "too many pending requests" response.

BeginHTTPUpload


The first operation for a set of file modifications is to call BeginAppUploadBatch. This call communicates the set of intended uploads and deletes to the SteamCloud, as well as information about the user's machine which is doing the update.

Example:
POST https://api.steampowered.com/ICloudService/BeginAppUploadBatch/v1/ HTTP/1.1 Host: api.steampowered.com Content-Type: application/x-www-form-urlencoded Content-Length: <body length> access_token=<token>&input_json={ "appid": "1234", "machine_name": "My%20Handheld", "files_to_upload": ["%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave.sav"], "files_to_delete": ["%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave_old.sav"] }

NameTypErforderlich?Beschreibung
access_tokenstringOAuth-Zugriffstoken für den Benutzer
appiduint32Ihre App-ID
machine_namestringA name for the source machine, preferably one the user has applied to the device
files_to_uploadstring listList of all files to be uploaded (new files or updates for existing files) as part of this batch.
files_to_deletestring listList of all files to be deleted from Steam Cloud as part of this batch.

Call this API to begin the upload batch.

Note that for list parameters, such as "files_to_upload", the syntax when used as a GET param is as follows:
&files_to_upload[0]=file1.sav&files_to_upload[1]=file2.sav

In a JSON-encoded field in a POST param, it is as follows:
"files_to_upload": ["file1.sav", "file2.sav"]

The response data:
NameTypBeschreibung
batch_iduint64ID of this batch, to be used with the CompleteAppUploadBatch call
app_change_numberuint64currently unused by this API

Your application must remember the batch_id from this response and submit it to the CompleteAppUploadBatch request once all uploads and deletes have been attempted.

CompleteAppUploadBatch


Once all uploads and deletes have been attempted, successful or not, you must call CompleteAppUploadBatch. This indicates to Steam that all operations for this batch have been attempted and it will then allow any newly-requested batches immediately.

Example:
POST https://api.steampowered.com/ICloudService/CompleteAppUploadBatch/v1/ HTTP/1.1 Host: api.steampowered.com Content-Type: application/x-www-form-urlencoded Content-Length: <body length> access_token=<token>&input_json={ "appid": "1234", "batch_id": "434565457423", "batch_eresult": "1" }

NameTypRequiredDescription
access_tokenstringOAuth access token for the user
appiduint32Der Header-WertYour App ID
batch_iduint64The ID number of this batch
batch_eresultuint32Result of the batch (see remarks)

The batch_eresult parameter should be either 1 (success) or 2 (failure). Technically this is an EResult value (see steam_api.h for the list). Indicating success or failure to Steam is sufficient for this method.

There's no body data in the response from this API.

BeginHTTPUpload


Uploading is done via a two-part API. You'll first call BeginHTTPUpload to get details on where to upload the file, then when that is complete, call CommitHTTPUpload.

Example:
POST https://api.steampowered.com/ICloudService/CommitHTTPUpload/v1/ HTTP/1.1 Host: api.steampowered.com Content-Type: application/x-www-form-urlencoded Content-Length: <body length> access_token=<token>&input_json={ "appid": "1234", "transfer_succeeded": "1", "filename": "%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave.sav", "file_sha": "FDFE308499263F9361B472648E9F49DC0B8799C8" }

NameTypErforderlich?Beschreibung
access_tokenstringOAuth-Zugriffstoken für den Benutzer
appiduint32Ihre App-ID
file_sizeuint32size of the file in bytes
filenamestringDer Dateiname
file_shauint32Hex-String (40 Zeichen), die den SHA1-Digest der Datei repräsentiert.
platforms_to_syncstringList of platforms for which this file is valid. Possible values: All, Windows, MacOS, linux, Android, iPhoneOS, Switch. Case-insensitive.
upload_batch_iduint64The batch_id returned by BeginAppUploadBatch above

Call this API to initiate uploading a new file (or new version of an existing file) to Steam Cloud for the user. New versions of existing files will overwrite the existing version.

Note that for list parameters, such as "platforms_to_sync", the syntax when used as a GET param is as follows:
&platforms_to_sync[0]=macos&platforms_to_sync[1]=windows

In a JSON-encoded field in a POST param, it is as follows:
"platforms_to_sync": ["macos", "windows"]

The response data:
NameTypDescription
access_tokenuint64unique file id (not needed)
timestampuint32epoch timestamp for this change
url_hostboolHost FQDN you will upload the file to
url_pathstringpath for request. Note that currently this includes a leading slash character (/) already.
use_httpsboolset to true if you must use HTTPS to perform the upload (generally always true)
request_headerssee belowlist of HTTP headers you must set on the subsequent PUT request

The "request_headers" list contains this data:
NameTypeDescription
namestringthe header name
valuestringthe header value

To upload the file, make a PUT request to https://<url_host><url_path>, where each of the above specified HTTP headers has the specified value. On success you may receive a 200 OK, 201 Created, or 204 No Content response, depending on the storage provider.

This request may look like:
PUT https://steamcloud-us-west1.storage.googleapis.com/00/00/00/00/1234/012_3_4A77D494_9D267_1464.dat?GoogleAccessId=numbersandletters@developer.gserviceaccount.com&Expires=1595961837&Signature=morestuffhere HTTP/1.1 Host: steamcloud-us-west1.storage.googleapis.com Content-Type: application/octet-stream Content-Length: <body length> Header-from-Steam1: value1 Header-from-Steam2: value2 <file data>

When that completes (whether a success or a failure), call:

CommitHTTPUpload


Example:
POST https://api.steampowered.com/ICloudService/CommitHTTPUpload/v1/ HTTP/1.1 Host: api.steampowered.com Content-Type: application/x-www-form-urlencoded Content-Length: <body length> access_token=<token>&input_json={ "appid": "1234", "transfer_succeeded": "1", "filename": "%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave.sav", "file_sha": "FDFE308499263F9361B472648E9F49DC0B8799C8" }
NameTypeRequiredDescription
access_tokenstringOAuth access token for the user
appiduint32Your App ID
transfer_succeededbooltrue if the PUT request succeeded
filenamestringthe file name
file_shastringHex string (40 digits) representing the SHA1 digest of the file.

The response to this API currently has a single field, "file_committed", which will be true if Steam was able to fully commit the change. If false, then the upload has failed -- a new file was not recorded, and if it was an update to an existing file, the existing file still exists and will be returned by future Enumerate/Download requests.

Delete


Example:
POST https://api.steampowered.com/ICloudService/Delete/v1/ HTTP/1.1 Host: api.steampowered.com Content-Type: application/x-www-form-urlencoded Content-Length: <body length> access_token=<token>&input_json={ "appid": "1234", "filename": "%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave.sav" }

NameTypeRequiredDescription
access_tokenstringOAuth access token for the user
appiduint32Your App ID
filenamestringfilename of the file to delete

This API will delete the specified file from the user's Steam Cloud. Deleting files is permanent; no prior versions of the file are retained. There's no body data in the response from this API.