NoSQL Explorer REST API

Read First! This NoSQL Explorer REST API page assumes you've already read the REST APIs Overview page.

The GameSparks platform allows you to manage the data you store in the MongoDB and Redis databases via a REST interface. You can use this REST API to control your game's data stored in these databases directly and without having to do this via the GamesSparks platform.

All the communication is based on a JSON payload.

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.

Discovering the Endpoint

In the system architecture diagram on the REST APIs Overview page, you can see that there are multiple servers that handle the NoSQL REST requests, one for each cluster. This means that before you can query the system for NoSQL information, you must first find out what server you need to talk to.

Example Request

GET https://config2.gamesparks.net/restv2/game/m306293Zcipm/endpoints

Example Response

{
"liveNosql":"https://m306293Zcipm.live.cluster.gamesparks.net",
"previewNosql":"https://m306293Zcipm.preview.cluster.gamesparks.net",
"liveElasticSearch":"https://gsp-aeu002-es.gamesparks.net",
"previewElasticSearch":"https://gsp-aeu000-es.gamesparks.net"
}

You'll use either the previewNosql or the liveNosql base URLs, depending on the stage you want to query: Preview or Live respectively.

From now on, we'll refer to the endpoint you choose to query as {stageBaseUrl}.

Examples Operations

You can find an exhaustive list of the operations that you can perform using the NoSQL Explorer REST API together with an explanation of their parameters here.

This section provides a few examples.

Find All Collections

GET {stageBaseUrl}/restv2/game/{gameApiKey}/mongo/collections

Returns all the available collections and the operations you are allowed to perform on each of them.

Example response

[
  {
    "actions": [ "FIND", "COUNT", "INSERT", "UPDATE", "REMOVE", "INDEX", "AGGREGATE", "STATS"],
    "name": "challengeInstance",
    "optionGroup": "System"
  },
  {
    "actions": [ "FIND", "COUNT", "INSERT", "UPDATE", "REMOVE", "INDEX", "AGGREGATE", "STATS"],
    "name": "externalAuthentication",
    "optionGroup": "System"
  },
  {
    "actions": [ "FIND", "COUNT", "INSERT", "UPDATE", "REMOVE", "INDEX", "AGGREGATE", "STATS" ],
    "name": "player",
    "optionGroup": "System"
  },
  {
    "actions": [ "FIND", "COUNT", "INDEX", "AGGREGATE", "STATS" ],
    "name": "score-leaderboard",
    "optionGroup": "Leaderboards"
  },
  {
    "actions": [ "FIND", "COUNT", "INSERT", "UPDATE", "REMOVE", "INDEX", "AGGREGATE", "DROP", "STATS"],
    "name": "score-runningTotal",
    "optionGroup": "Running Totals"
  }
]

Find Data in a Collection

POST {stageBaseUrl}/restv2/game/{gameApiKey}/mongo/collection/player/find

Returns the players that match the parameters you pass.

Here are the optional parameters:

Example Request

{
    "query":{"displayName":"testUser"},
    "fields":{"userName":1,"currency1":1},
    "skip":0,
    "sort":{"userName":1},
    "limit":100
}

Example Response

[
  {
    "_id": {
      "$oid": "58b826d0b5973404c700a925"
    },
    "userName": "gamedude",
    "currency1": {
      "$numberLong": "1"
    }
  }
]

Create a Meta Collection

You can only create meta collections or runtime collections. The following request will create a meta collection called 'tracks':

POST {stageBaseUrl}/restv2/game/{gameApiKey}/mongo/collection/tracks/meta

Response

{message: "OK"}
Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here