Amazon GameSparks is currently in preview. Changes might be made to this service and to this documentation. We don't recommend using this service for production workloads.
Amazon GameSparks Extension API Reference
Amazon GameSparks is a fully managed AWS service that you can use to quickly stand up a game backend. GameSparks extensions provide services that you can use as building blocks instead of having to integrate them yourself. You leverage the services you need using JavaScript, which you develop as cloud code messages. These messages can be either requests that return a response, or as events.
GameSparks offers the following extensions:
Infrastructure
Access to other AWS services
Game features
Action example
The following example demonstrates using GameSparks.Core Actions and GameSparks.PlayerState Actions to retrieve and modify player data.
let log = GameSparks().Logging(); log.Debug("Inside Counter event handler"); let player = GameSparks().CurrentPlayer(); let data = player.GetData(["counter"]); log.Debug("Current: " + data.counter); if(data.counter === undefined) { data.counter = 0; } data.counter++; player.SetData(data); log.Debug("New: " + data.counter);
After you've deployed a cloud code message like this, your game client can then use it to communicate with GameSparks.
Extension capabilities
Each extension in this reference includes one or more of the following elements:
Actions provide APIs that can be called from custom cloud code (as shown in the earlier examples).
Data types define the shape of the data that is passed in and out of actions and extension requests.
Errors can be returned to the game client as the result of a request or event.
Requests can be sent by the game client, and result in a response from the game backend.
Sections can be included in a game configuration to control the behavior of the extension.
Learn more
For more information about:
-
Developing your game, see the Developer Guide.
-
Using actions, data types, events, requests, and errors, see Using messages.
-
Game configurations and sections, see Managing games.