REST API tutorial
Access Cloud Save data from any development environment with the REST API.
Read time 1 minuteLast updated 2 days ago
You can access data in Cloud Save using the REST API. REST APIs provide more flexibility and allow you to automate your workflows by using your favorite language and game development engine or from a game server. The Cloud Save service provides the following REST APIs:
- Cloud Save Player API for player actions (e.g. saving/loading data)
- Cloud Save Admin API for admin actions (e.g. configuring queries/indexes)
Authentication
You can authenticate requests to the Cloud Save REST API using a Multiplay Hosting token_token) or a stateless token. Use the received token as a bearer token for HTTP authentication in the request header.Authenticate using a Multiplay Hosting token
You can retrieve a Multiplay Hosting token by running the following request on the game server:The request would return a response in the format below:curl -X GET http://localhost:8086/v4/token
{"token":"<BEARER_TOKEN>", "error":""}
Authenticate using a stateless token
To use a stateless token, you need to create a service account and call the Token Exchange API to obtain a stateless token with a limited lifespan.Calling the REST API
You can call a module endpoint using any HTTP library that is native to the codebase. Use the retrieved authentication token as a bearer token for HTTP authentication in the request header. An example CURL request to save data to a player could look like this:curl -X POST-H 'Authorization: Bearer <BEARER_TOKEN>' \-H 'Accept: application/json' \-H 'Content-Type: application/json' \-d '{"key":"someKey","value":"someValue"}' \'https://cloud-save.services.api.unity.com/v1/data/projects/<PROJECT_ID>/players/<PLAYER_ID>/items'