Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
//staq REST API documentation
branch: master
Failed to load latest commit information.
README.md small fix

README.md

//staq REST API documentation V1.0

//staq is a platforms to mange and operate service-based games.

Version 1 of the API is limited to event tracking and IAP purchase server verification.

The API is a REST API and uses an AppSecret specified in the http header for authenticating request.

You can signup at http://staq.io or login at https://dashboard.staq.io.

AppSecret and AppId are visible in the dashboard by clicking on User => Show Api Keys. Input and output format is JSON.


Endpoint

Base url: https://api.staq.io/v1

API methods

Device Authorization

POST /apps/{appId}/auth/device

Description

This resource allows you to authorize an anonymous user. You need to call this method before consuming any other resource from the staq API.

This method will log the following events:

Logged events:

  • server_INSTALL - New installation event
  • server_SESSION_START - New session event

Request parameters

Url parameters:

appId An application id

Json Parameters:

deviceId An arbitrary device id or UUID
deviceInfo An arbitray JSON object contains platform and/or other custom information that you want to associate with the user.

Response

appId Your application id
uid An id that staq assign to the current user. This is required as input parameter by other api resources.
sid An id associated with the current session.
token An authorization token associated with the current user. This is required as input parameter by other api resources.

Example

Request:
POST https://api.staq.io/v1/apps/app-000001/auth/device HTTP/1.1
Host: staq.io
Content-Type: application/json; charset=utf-8

{
    "deviceId": "my device ID",
    "deviceInfo":
    {
        "env-variable-1": "value1", 
        "other-env-variable": "value2"   
    }
}

Response:
200 (OK)
Content-Type: application/json

{
   "appId":"your-app-id",
   "uid":"staq-user-id",
   "sid":"session-id",
   "token":"auth-token"
}

iOS IAP Verification

POST /apps/{appId}/users/{uid}/iap/apple

Description

This resource allows you to verify an iOS in-app purchase.

This method will log the following events:

Logged events:

  • server_IAP_COMPLETED - Completed IAP event

Request parameters

HTTP Header parameters:

Auth-Token An authorization token associated with the current user

Url parameters:

appId Application id
uid User id provided by the authroization method of the staq API.

Json Parameters:

sid Session id provided by the authroization call of the staq API.
receipt An iOS receipt to validate
priceUsd Numeric value of the price of the item expressed in USD. ex: 9.99
status Status of the current IAP. Possible values are: processing and completed
comment A comment string to attach to the current transaction
metadata An arbitray JSON blob contains platform and/or other custom information that you want to associate with the user.

Response

isValid Boolean value. True if this is a valid receipt.
isDuplicate Boolean value. True if the receipt has been already validated.

Example

Request:

POST /apps/app-000001/users/uid-00001/iap/apple HTTP/1.1
Host: example.org
Content-Type: application/json; charset=utf-8
Auth-Token: your-auth-token

{ 
    "sid": "session-id",
    "receipt" : "ew0KCSJzaWduYXR1cmUiID0gIkFoRi94VkpCcmFIUWQ1RzNpSFlObFBQcFhwRUh4U2R0bEIvUW9oTGtLTlRWcUpjN3B6OWQ3UjZ6QUI4WXM2S0UzSUhCR3BxU1NuNTBVWnJrVEVLRFlkM1cxTHdzRTNiU1RJMHlobk9HRm84Sk56R0p6R0lDSDU2OFlKckg5V3NWR0hRdnJTTjg1bVVVeEROWGlnOVdRMmVCdVhpUnE5VWZVNS9YL3NxZ1hnbkJBQUFEVnpDQ0ExTXdnZ0k3b0FNQ0FRSUNDR1VVa1UzWldBUzFNQTBHQ1NxR1NJYjNEUUVCQlFVQU1IOHhDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFLREFwQmNIQnNaU0JKYm1NdU1TWXdKQVlEVlFRTERCMUJjSEJzWlNCRFpYSjBhV1pwWTJGMGFXOXVJRUYxZEdodmNtbDBlVEV6TURFR0ExVUVBd3dxUVhCd2JHVWdhVlIxYm1WeklGTjBiM0psSUVObGNuUnBabWxqWVhScGIyNGdRWFYwYUc5eWFYUjVNQjRYRFRBNU1EWXhOVEl5TURVMU5sb1hEVEUwTURZeE5ESXlNRFUxTmxvd1pERWpNQ0VHQTFVRUF3d2FVSFZ5WTJoaGMyVlNaV05sYVhCMFEyVnlkR2xtYVdOaGRHVXhHekFaQmdOVkJBc01Fa0Z3Y0d4bElHbFVkVzVsY3lCVGRHOXlaVEVUTUJFR0ExVUVDZ3dLUVhCd2JHVWdTVzVqTGpFTE1Ba0dBMVVFQmhNQ1ZWTXdnWjh3RFFZSktvWklodmNOQVFFQkJRQURnWTBBTUlHSkFvR0JBTXJSakYyY3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sNCn0=",
    "priceUsd" : 9.99,
    "status" : "completed",
    "comment" : "this is a comment",
    "metadata": {
        "env-variable-1": "value1", 
        "other-env-variable": "value2"   
    } 
}

Response:
200 (OK)
Content-Type: application/json

{
   "isValid":true,
   "isDuplicated":false
}

Google Play IAP Verification

POST /apps/{appId}/users/{uid}/iap/googleplay

Description

This resource allows you to verify a Google Play in-app purchase.

This method will log the following events:

Logged events:

  • server_IAP_COMPLETED - Completed IAP event

Request parameters

HTTP Header parameters:

Auth-Token An authorization token associated with the current user

Url parameters:

appId Application id
uid User id provided by the authroization method of the staq API.

Json Parameters:

sid Session id provided by the authroization call of the staq API.
receipt The Base 64 encoded data that is mapped to the INAPP_PURCHASE_DATA key in the response Intent from the Google Play In-App Billing API.
signature The Base 64 encoded data that is mapped to the INAPP_DATA_SIGNATURE key in the response Intent from the Google Play In-App Billing API.
status Status of the current IAP. Possible values are: processing and completed
priceUsd Numeric value of the price of the item expressed in USD. ex: 9.99
comment A comment string to attach to the current transaction
metadata An arbitray JSON blob contains platform and/or other custom information that you want to associate with the user.

Response

isValid Boolean value. True if this is a valid receipt.
isDuplicate Boolean value. True if the receipt has been already validated.

Example

Request:

POST /apps/app-000001/users/uid-00001/iap/googleplay HTTP/1.1
Host: example.org
Content-Type: application/json; charset=utf-8
Auth-Token: your-auth-token

{ 
    "sid": "session-id",
    "receipt" : "BASE64-OF-THE-PURCHASE-DATA",
    "signature" : "BASE64-OF-THE-SIGNATURE-DATA",
    "status" : "completed",
    "priceUsd" : 9.99,
    "comment" : "this is a comment",
    "metadata": {
        "env-variable-1": "value1", 
        "other-env-variable": "value2"   
    } 
}

Response:
200 (OK)
Content-Type: application/json

{
   "isValid":true,
   "isDuplicated":false
}

Custom Events

POST /apps/{appId}/users/{uid}/events

Description

This resource allows you to post an array of custom events.

Request parameters

HTTP Header parameters:

Auth-Token An authorization token associated with the current user.

Url parameters:

appId Application id
uid User id provided by the authroization call of the staq API.

Json Parameters:

sid Session id provided by the authroization method of the staq API.
events Array of:
timestamp A valid JSON timestamp
event Event name
value Event value
`metadata` An arbitray JSON blob contains platform and/or other custom information that you want to associate with the user.

Response

A string array of event id.

Example

Request:
POST /apps/app-000001/users/uid-00001/events HTTP/1.1
Host: example.org
Content-Type: application/json; charset=utf-8
Auth-Token: your-auth-token

{ 
    "sid": "session-id",
    "events": [{
    "timestamp" : "\/Date(1330848000000-0800)\/",
    "event" : "my-custom-event",
    "value" : "my-custom-value",
    "metadata" : {
        "env-variable-1": "value1", 
        "other-env-variable": "value2"
    }
    }]
}

Response:
200 (OK)
Content-Type: application/json

["eventid-000001"]
Something went wrong with that request. Please try again.