Sending Data

As seen in the overview, the first step to integrate Matchable is to send data to the platform by using the API.

Any piece of data (called “action”) shared with Matchable is structured the following way:

  • - a unique player’s identifier (generated by your game client)
  • - the version of the game client
  • - a type of action
  • - a date
  • - parameters (containing any additional information needed by Matchable)

Now according to the document provided by Matchable, let’s say you need to send the following action each time a player starts your game :

user_id description example
user_id unique player’s identifier b6d384c8b8e0b5c13c5bd217db3c8980
date the current_timestamp 1505393718
version your client version 1.0.7
type type of action session_start
parameters list of parameters needed by matchable ressources { gold:20 , life:5 }

To facilitate this integration, Matchable provides a few examples in different languages.

  • Sending data with curl

    Here’s an example of request with curl:

    
                curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: api_key <your_api_key>' -d '[
                    {
                        "date": 1505393718,
                        "version": "1.0.7",
                        "type": "session_start",
                        "parameters": {
                                "resources": {
                                        "gold": 20,
                                        "life": 5
                                }
                        }
                    }
                ]' 'http://api.matchable.io/v1.0/users/b6d384c8b8e0b5c13c5bd217db3c8980/actions'
                

    Here’s an example of callback you will get:

    
                {
                  "error": "",
                  "result": "1 saved actions"
                }
                

    To see examples of requests or any other detail regarding the current API, please refer to the online documentation.

    To make sure that any API call is correctly configured, Matchable also provides a debugger that gives real time feedback to the developer. Simply ask Matchable for your dashboard credentials to access this debugger.

  • Sending data with Unity

    To facilitate this integration, Matchable provides a SDK for the Unity framework:
    https://github.com/Matchable/matchable-unity-sdk

    Make sure you have properly configured your Settings (Open Matchable / Edit Settings menu and enter your App Key and Player Id)

    Here’s an example of request with the Unity SDK:

    
                public IEnumerator DemoSendAction()
                {
                    _test = "Matchable.SendAction()";
                    _log = "Waiting for response...";
                    Hashtable resources = new Hashtable();
                    resources.Add("gold", 20);
                    resources.Add("life", 5);
                    Hashtable parameters = new Hashtable();
                    parameters.Add("resources", resources);
                    // Call any MatchableAction asynchronously as a Coroutine
                    yield return StartCoroutine(Matchable.SendAction("sample_action_type", parameters, (response) =>
                    {
                    // Handle the API response the way you want
                    _log = response.ToJsonString();
                    }));
                }
                

    If you need any details about this demo code, you can refer to the following page on github.