Documentação do Steamworks
Interface ICloudService
Oferece acesso aos arquivos de um usuário Steam na Nuvem Steam. O objetivo principal desta interface é permitir o compartilhamento de progresso no jogo entre plataformas ("cross-save"). A versão Steam do jogo pode usar os recursos de nuvem do Steamworks (seja a API ISteamRemoteStorage ou a nuvem automática). Versões não Steam podem usar esta Web API para acessar os arquivos e enviar versões novas.

O jogo precisará obter permissão do usuário para acessar os respectivos arquivos na Nuvem Steam, o que pode ser feito via OAuth — os detalhes estão aqui. Observe que você provavelmente precisará solicitar as permissões "read_cloud" e "write_cloud".

Consulte também a documentação geral da WebAPI do Steam, especificamente a seção "Interfaces de serviço". Requisições GET podem ser feitas com parâmetros no URL. No entanto, para requisições POST, recomendamos que todos os parâmetros estejam no corpo da requisição. The access-token parameter is directly form-encoded, and then the remaining parameters should be in a JSON structure set via the input-json field.

Respostas a requisições bem formadas e autenticadas geralmente serão 200 OK. However the request may have failed - the detailed Steam error code will be found in the x-eresult header. O valor para "success" é 1. All other values are likely to be errors; see the documentation for steam_api.h for details.

Listagem de arquivos

Requer a permissão OAuth read_cloud.

EnumerateUserFiles


Exemplo:
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

NomeTipoObrigatórioDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32O ID do aplicativo.
extended_detailsboolSe os detalhes dos arquivos, como links de download, devem ser incluídos
countuint32Quantidade máxima de arquivos a listar (padrão: 500).
start_indexuint32Índice do primeiro arquivo da listagem (padrão: 0).

Enumerate the user's Steam Cloud files for your game. Comece com a "start_index" definida como zero, e itere, caso necessário, se o usuário possuir mais de "count" arquivos.

A resposta possui dois campos:
NomeTipoDescrição
filesdetalhes abaixoUma lista de detalhes de arquivos.
total_filesuint32A quantidade total de arquivos do jogo armazenados na Nuvem Steam do usuário.

A lista de arquivos contém os seguintes dados:
NomeTipoDescrição
appiduint32O ID do aplicativo.
ugciduint64ID único do arquivo.
filenamestringO nome do arquivo.
timestampuint64Horário da última atualização do arquivo, no formato de Era Unix.
file_sizeuint64O tamanho do arquivo, em bytes.
urlstringUm URL, que pode ser usado para baixar o arquivo.
steamid_creatoruint64O ID Steam do usuário.
flagsuint64Apenas para uso interno do Steam.
platforms_to_syncstringLista de plataformas para as quais o arquivo é válido. A seção "Envio de arquivos" contém a lista de valores possíveis.
file_shastringCadeia de 40 caracteres hexadecimais que representa o resumo SHA1 do arquivo.

Download de arquivos


To download a file, simple make a GET request to the URL returned by EnumerateUserFiles above.

Modifying Files


Requer a permissão OAuth write_cloud.

Modifying files includes uploading new files, uploading new versions of existing files, and deleting files from Steam Cloud.

A set of file modification actions should be wrapped in a Batch. Batches are used to communicate intent to the Steam Cloud for your set of modifications, and help reduce the likelihood of file conflicts.

A full batch sequence will look like the following:

  • BeginAppUploadBatch call, listing the intended uploads and deletes
  • 0 or more uploads, using the sequence:
    • BeginHTTPUpload
    • HTTP PUT operation to upload the file
    • CommitHTTPUpload
  • 0 or more deletes, using Delete
  • CompleteAppUploadBatch

Chame a função CompleteAppUploadBatch independentemente do sucesso ou falha dos envios e/ou exclusões. 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.

Exemplo:
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"] }

NomeTipoObrigatórioDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32O ID do aplicativo.
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"]

Dados da resposta:
NomeTipoDescrição
batch_iduint64ID of this batch, to be used with the CompleteAppUploadBatch call
app_change_numberuint64Atualmente, não usado pela 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.

Exemplo:
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" }

NomeTipoRequiredDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32O ID do aplicativo.
batch_iduint64The ID number of this batch
batch_eresultuint32Result of the batch (see remarks)

O parâmetro batch_eresult deve ser 1 (sucesso) ou 2 (falha). 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


O envio é feito por meio de uma API de duas partes. Você chamará primeiro BeginHTTPUpload para obter detalhes de onde enviar o arquivo. Quando isso estiver completo, chame CommitHTTPUpload.

Exemplo:
POST https://api.steampowered.com/ICloudService/BeginHTTPUpload/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", "file_size": "7448889", "filename": "%25WinAppDataLocal%25Foobar%2FGamename%2Fcloud%2Fgames%2Fsave.sav", "file_sha": "FDFE308499263F9361B472648E9F49DC0B8799C8", "is_public": "0", "platforms_to_sync": ["all"], "upload_batch_id": "434565457423", }

NomeTipoObrigatórioDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32O ID do aplicativo.
file_sizeuint32O tamanho do arquivo, em bytes.
filenameuint32O nome do arquivo.
file_shauint32Cadeia de 40 caracteres hexadecimais que representa o resumo SHA1 do arquivo.
platforms_to_syncstringLista de plataformas para as quais o arquivo é válido. Possible values: All, Windows, MacOS, linux, Android, iPhoneOS, Switch. Não faz distinção entre maiúsculas e minúsculas.
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. Novas versões de arquivos sobrescreverão a versão existente.

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"]

Dados da resposta:
NomeTipoDescription
ugciduint64unique file id (not needed)
timestampuint32epoch timestamp for this change
url_hoststringO nome de domínio completamente qualificado (FQDN) do host ao qual o arquivo deverá ser enviado.
url_pathstringO caminho da requisição. Observe que, atualmente, este caminho já inclui uma barra (/) no início.
use_httpsboolConterá o valor true se HTTPS deve ser usado para o envio (costuma ser sempre true).
request_headersdetalhes abaixoLista de cabeçalhos HTTP que devem ser inseridos na requisição PUT subsequente.

A lista de "request_headers" contém os seguintes dados:
NomeTipoDescrição
nomestringO nome do cabeçalho.
valuestringO valor do cabeçalho.

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


Exemplo:
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" }
NomeTipoObrigatórioDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32Your App ID
transfer_succeededboolDeve conter o valor true se a requisição PUT foi bem-sucedida.
filenamestringO nome do arquivo.
file_shastringCadeia de 40 caracteres hexadecimais que representa o resumo SHA1 do arquivo.

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


Exemplo:
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" }

NomeTipoObrigatórioDescrição
access_tokenstringToken OAuth de acesso do usuário.
appiduint32O ID do aplicativo.
filenamestringO nome do arquivo a excluir.

A API excluirá o arquivo especificado da Nuvem Steam do usuário. Deleting files is permanent; no prior versions of the file are retained. There's no body data in the response from this API.