Data Service REST API
Read First! This Data Service REST API page assumes you've already read the REST APIs Overview page.
Introduction
The GameSparks platform allows you to manage the data you store on the platform using the Game Data Service via a REST interface. You can use this REST API to control your game's data directly and without having to do this via the GamesSparks platform.
All the communication is based on a JSON payload.
This topic lists the REST API calls used by the Data Type Explorer:
Warning! A limit is imposed of 1000 calls per second (per API Key) to the Game Data Service.
Authentication
The Data Service REST API uses the GameSparks JSON web token authentication type. For further details, see the GameSparks JSON WEB Token section on the REST APIs Overview page.
REST Endpoint
All of these APIs are accessed from the cluster-manage endpoint, similar to the existing REST API for NoSQL access. Prefix is always:
restv2/game/{apiKey}/data
GET datatypes
Lists the datatypes that currently exist in the Data Service
Example
GET restv2/game/{apiKey}/data/datatypes
GET itemId
Retrieve an item from the data service by ID
Example
GET restv2/game/{apiKey}/data//{type}/{itemId}
DELETE itemId
Delete an item from the data service by ID
Example
DELETE restv2/game/{apiKey}/data/{type}/{itemId}
DELETE type
Delete all items from a data type
Example
DELETE restv2/game/{apiKey}/data/{type}
PUT item
Create or update an item in the data service by ID
Example
PUT restv2/game/{apiKey}/data/{type}/{itemId}
POST query
Query for items in the data service.
The query body is the JSON document for query:
- The body should be in the format that you can see in the JSON tab in the Data Explorer.
- Supported statements are:
- condition: (AND,OR,NOT)
- field: (short code)
- operator: (<,>,=,<>,IN,STARTSWITH)
- value: (String or Number)
Examples
POST restv2/game/{apiKey}/data/{type}/query
Example 1 – Query Body
{"query":{"condition":"AND","rules":[{"field":"CITY","operator":"EQ","value":"York"},{"field":"RANK","operator":"GT","value":20}]},"sort":"RANK","asc":true}
Example 2 – Query Body
{"query":{"condition":"OR","rules":[{"field":"RANK","operator":"GT","value":20},{"field":"SCORE","operator":"GT","value":120}]},"sort":"SCORE","asc":true}