{"id":198,"date":"2015-12-13T09:01:10","date_gmt":"2015-12-13T09:01:10","guid":{"rendered":"http:\/\/is.ieis.tue.nl\/research\/hc\/gamebus\/?page_id=198"},"modified":"2015-12-13T09:01:10","modified_gmt":"2015-12-13T09:01:10","slug":"open-api-for-pushing-gamesession","status":"publish","type":"page","link":"https:\/\/blog.gamebus.eu\/index.php\/open-api-for-pushing-gamesession\/","title":{"rendered":"API for pushing GameSessions"},"content":{"rendered":"<h3>What?<\/h3>\n<p>This page describes the API for external app developers who wish to save game\u00a0sessions in the personal data store of a GameBus user.<\/p>\n<h3>Why?<\/h3>\n<p>Integrating an external game with the GameBus Open API enables\u00a0GameBus sponsors to define challenges in terms of sessions of that external game.\u00a0Then, furthermore, end users can gain GameBus points by playing the external game. As the developer of mobile games, there are various\u00a0incentives for realizing this integration:<\/p>\n<ul>\n<li>apps integrated with GameBus are part of a more holisitic, social gaming experience;<\/li>\n<li>apps in the GameBus ecosystem will benefit from the large scale marketing efforts that will be performed in 2016 and beyond;<\/li>\n<li>developers without much expertise\u00a0in server-side development can use the GameBus personal data store as a convenient\u00a0&#8220;database as a service&#8221; (note: this page does not document how to read again the sessions that were saved by an app &#8212; please contact us if you are interested in this capability);<\/li>\n<li>similarly, developers can save operational\u00a0costs\u00a0since they no longer need to maintain their own database server for saving game states (the same note applies here).<\/li>\n<\/ul>\n<h3>How?<\/h3>\n<p>First, the external app needs access to a\u00a0<a title=\"GameBus OAuth Token Manual\" href=\"http:\/\/is.ieis.tue.nl\/research\/hc\/gamebus\/?page_id=286\">user-specific token for the GameBus API<\/a>.<\/p>\n<p>Second, the external app needs to describe its metadata on the GameBus platform. Specifically, you will have to provide a so-called &#8220;game descriptor&#8221; for the app, listing which properties are available for each game session. \u00a0For each property, a type needs to be specified. The currently -available types are:<\/p>\n<ul>\n<li>BOOL<\/li>\n<li>COORDINATE<\/li>\n<li>DATE<\/li>\n<li>DOUBLE<\/li>\n<li>INT<\/li>\n<li>PERCENTAGE<\/li>\n<li>STRING<\/li>\n<li>TIME<\/li>\n<\/ul>\n<p>In summary, for your external app, you should supply the following metadata:<\/p>\n<ul>\n<li>A name for the game descriptor (e.g., the name of the external app),<\/li>\n<li>A list of properties, with their\u00a0corresponding type.<\/li>\n<\/ul>\n<p>In order to\u00a0register your game descriptor, please contact <a href=\"mailto:info@gamebus.eu\">info@gamebus.eu<\/a>. Please also clarify\u00a0how you plan to\u00a0explain to end users what kind of data you are sending to GameBus. Specifically, please send us your (draft) policy description, so we can include it later in the GameBus terms of use \/ privacy policy. We will contact you soon after, clarifying:<\/p>\n<ul>\n<li>how you can obtain GameBus OAuth tokens specific to your app\/wearable\/website (general <a title=\"GameBus OAuth Token Manual\" href=\"http:\/\/is.ieis.tue.nl\/research\/hc\/gamebus\/?page_id=286\">GameBus token information<\/a> is already available <a title=\"GameBus OAuth Token Manual\" href=\"http:\/\/is.ieis.tue.nl\/research\/hc\/gamebus\/?page_id=286\">here<\/a>),<\/li>\n<li>what are the IDs for your game descriptor and its corresponding properties.<\/li>\n<\/ul>\n<p>Once you have your own game descriptor, you\u00a0can finalize\u00a0the actual integration code.\u00a0In the following, we assume that we have registered your game descriptor and we also assume that your external app has access to a <a title=\"GameBus OAuth Token Manual\" href=\"http:\/\/is.ieis.tue.nl\/research\/hc\/gamebus\/?page_id=286\">user-specific GameBus OAuth token<\/a>.<\/p>\n<p>To push a new session, you should make an HTTPS REST call with JSON payload and an <a href=\"https:\/\/tools.ietf.org\/html\/rfc6749\" target=\"_blank\" rel=\"noopener\">OAuth 2 token<\/a> in the <a href=\"https:\/\/tools.ietf.org\/html\/rfc7235#section-4.2\" target=\"_blank\" rel=\"noopener\">Authorization header<\/a>.<\/p>\n<ul>\n<li>API Base URL:\u00a0<a title=\"https:\/\/gamebus.synersec.eu\/\" href=\"https:\/\/api.gamebus.eu\/\" target=\"_blank\" rel=\"noopener\"><span class=\"il\">https<\/span>:\/\/APPID@api.gamebus.<span class=\"il\">eu<\/span>\/<\/a>\u00a0where APPID is an ID unique to your integration<\/li>\n<li>Path to the service for inserting new sessions: <strong><em>\/<span class=\"il\">activity<\/span>\/<span class=\"il\">new<\/span><\/em><\/strong><\/li>\n<li>Method: <a href=\"https:\/\/tools.ietf.org\/html\/rfc7231#section-4.3.3\" target=\"_blank\" rel=\"noopener\">POST\u00a0<\/a><\/li>\n<li>Payload example:<\/li>\n<\/ul>\n<pre><code>{\n  \"gameDescriptorId\": 101,\n  \"properties\": [\n    {\n      \"id\": 1001,\n      \"value\": \"2015-09-29\",\n     <em> \"name\": \"Started at date\",<\/em>\n    <em>  \"type\": \"DATE\"<\/em>\n    },\n    {\n      \"id\": 1002,\n      \"value\": \"01:30 AM\",\n<em>      \"name\": \"Started at time\",\n      \"type\": \"TIME\"<\/em>\n    },\n    {\n      \"id\": 1003,\n      \"value\": 72,\n<em>      \"name\": \"Seconds to Complete\",\n      \"type\": \"INT\"<\/em>\n    },\n    {\n      \"id\": 1004,\n      \"value\": 321,\n<em>      \"name\": \"Score\",\n      \"type\": \"INT\"<\/em>\n    },\n    {\n      \"id\": 1005,\n      \"value\": 123,\n<em>      \"name\": \"Level\",\n      \"type\": \"INT\"<\/em>\n    }\n  ]\n}<\/code><\/pre>\n<p>In this example, the &#8220;name&#8221; and &#8220;type&#8221; attributes are provided just for documentation purposes. They are fully ignored by our API since the actual property name and type information is already known inside GameBus. Put differently, only the attributes &#8220;id&#8221; and &#8220;value&#8221; matter in the array of property instance.<\/p>\n<p>That&#8217;s all!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What? This page describes the API for external app developers who wish to save game\u00a0sessions in the personal data store of a GameBus user. Why? Integrating an external game with the GameBus Open API enables\u00a0GameBus sponsors to define challenges in terms of sessions of that external game.\u00a0Then, furthermore, end users can gain GameBus points by &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.gamebus.eu\/index.php\/open-api-for-pushing-gamesession\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;API for pushing GameSessions&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-198","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/pages\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":0,"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/pages\/198\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gamebus.eu\/index.php\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}