In order to use the GamiPixel API inside of your games and apps, first of all you need to authenticate the session, preferably at the start of the game or app.
Authentication means the game or application communicates with our servers using your API Key and Secret Key for the GamiPixel to authorise the use of the API in your game or app.
When authentication happens and is successful, it will return an authentication key and you can use this for that session.
How to Authenticate
You can do this by POSTing to the API with your API and Secret Key. If you haven’t generated those inside of your account yet, you can learn about that here.
You should GET this URL
https://gamipixel.com/api/v1/gami-authenticate/
and send the following data as POST$:
api_key=<your_api_key> secret_key=<your_secret_key>
Once it has successfully authenticated, you will receive a JSON response like this:
{"status":"success","authentication_key":"aaee4be6955cef07e50268b4d2117131"}
Status: This is the returned status of the authentication. “success” means the authentication was a success. Anything other than “success” means it was a fail.
Authentication Key: This is the authentication key specifically for that session. You should store this and only query future API requests in that session with the authentication key.
Once you have successfully authenticated the user’s session, you should store the authentication key as a variable and use this for future POST$ to the API for that session. You should also code in to detect if the return response is an error, you will need to re-authenticate and obtain a new authentication key. You can use Keep Alive Requests (below) to ensure the authentication key is kept alive at all times.
Keep the Session Alive
Authentication keys only last for 10 minutes. Every time you request the API from the session with the authentication key, it resets the 10 minute session time. So if you are sending frequent API requests in that session, be sure that the authentication key will be kept alive.
Therefore, you should code into your game or application, if there has been no requests sent at the 9 minute mark from the last request, you should send a Keep Alive Request. Should the user, game or app be idle, this will ensure it keeps their authentication key valid.
You should NOT code a Keep Alive Request any sooner than every 9 minutes, otherwise it can cause your game or app to be rate-limited due to misuse and this could cause problems for other users.
Ending the Session
It is important that you have triggers in your game or app, like ‘End of Application’ or ‘User Closes Game’ to send a kill request for the authentication key.
If you don’t send a kill request, it could end up with your game or app generating too many authentication keys which could result in other users not being able to obtain one.
Return Responses
Please remember that returned responses are typically in JSON. If you are not a fan of JSON or want to use plain text, delimited, you can simply send this additional query as part of any of your POST$ to return a plain text, delimited response.
delimited=yes
So instead of getting the JSON return as above, you’ll get this instead
status:success|authentication_key:aaee4be6955cef07e50268b4d2117131
You can then delimit each key with the PIPE | and each key value with the colon :
For example, you can set a tokenizer up to take the full string inside of your application and set the delimiters as | and : and then you can run a loop over the keys and their values.