API
API endpoints
Launch a session
2 min
start a new game session in a specific region each session needs a unique id, which you'll need to create yourself each call to the api to launch a session must be a uuid to avoid any issues { "tab" "examples", "url" "https //api gameye io/session", "name" "launch a session", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "required", "name" "id", "type" "string", "description" "the unique id for the session (use a uuid )" }, { "kind" "required", "name" "location", "type" "string", "children" \[], "description" "the location or region that you'd prefer to host the game session in (check our regions and locations page )" }, { "kind" "required", "name" "image", "type" "string", "children" \[], "description" "the name of the image for your game, hosted inside a container " }, { "kind" "required", "name" "env", "type" "object", "children" \[], "description" "the list of environment variables you want to feed the container when it starts \[can be left blank]" }, { "kind" "required", "name" "args", "type" "string", "children" \[], "description" "the list of program console arguments to feed to the application that's hosted inside the container \[can be left blank]" }, { "kind" "required", "name" "restart", "type" "boolean", "children" \[], "description" "tells us whether we must automatically restart this session if it fails to launch (we won't restart if you manually shut it down ) " }, { "kind" "optional", "name" "labels", "type" "object", "children" \[], "description" "add your own metadata about the session that we'll store inside the configuration " }, { "kind" "optional", "name" "version", "type" "string", "children" \[], "description" "tag of the image that the session will run this tag needs to be available\nor it'll throw a 404 if you don't specify a priority, we'll run it with the highest priority " }, { "kind" "optional", "name" "enablemetrics", "type" "string", "children" \[], "description" "use this to collect details like cpu, memory and network information useful for debugging " } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "lk2gskb vicqqfyoxo77v", "code" "// a session has successfully been started on a machine in the provided location \n \n{\n \\"host\\" \\"\\",\n \\"ports\\" \[\n {\n \\"type\\" \\"\\",\n \\"container\\" 0,\n \\"host\\" 0\n }\n ]\n}", "language" "200", "customlabel" "" }, { "id" "bu8t44v4xs1q 4nl7zw i", "code" "// you are not authorized to start a session please make sure that the included bearer\ntoken is correct ", "language" "401", "customlabel" "" }, { "id" "9svqrc683amkfzz3hsdh ", "code" "// the request contains a location, image or organization that does not exist \n \n", "language" "404", "customlabel" "" }, { "id" "wvxbhe4mzfvnn hdqunqs", "code" "// cannot start a session with the provided id please use a unique identifier\nfor your session it is recommended to use a uuid ", "language" "409", "customlabel" "" }, { "id" "vki6rm av vuqhewmupm8", "code" "// bad request this may imply that the given request has invalid syntax ", "language" "422", "customlabel" "" } ], "selectedlanguageid" "vki6rm av vuqhewmupm8" }, "examples" { "languages" \[ { "id" "qt wn0jzgmvwm 8gwnf08", "code" "curl location request post 'https //api gameye io/session' \\\\\n header 'accept application/json' \\\\\n data raw '{\n \\"id\\" \\"f7965a22 e327 4541 a30e 8262890d3a29\\",\n \\"location\\" \\"europe\\",\n \\"image\\" \\"my very special game\\",\n \\"version\\" \\"buildversion\\",\n \\"env\\" {\n \\"my secret\\" \\"\<my secret value\\"\n },\n \\"args\\" \[\n \\" max players=8\\"\n ],\n \\"labels\\" {\n \\"my example tag\\" \\"1\\",\n \\"another example tag\\" \\"3\\"\n },\n \\"restart\\" false\n}'", "language" "curl", "customlabel" "" }, { "id" "a7zr7 lekvaccd1ptoqhw", "code" "var myheaders = new headers();\nmyheaders append(\\"accept\\", \\"application/json\\");\n\nvar raw = \\"{\\\n \\\\\\"id\\\\\\" \\\\\\"f7965a22 e327 4541 a30e 8262890d3a29\\\\\\",\\\n \\\\\\"location\\\\\\" \\\\\\"europe\\\\\\",\\\n \\\\\\"image\\\\\\" \\\\\\"nginx\\\\\\",\\\n \\\\\\"env\\\\\\" {},\\\n \\\\\\"args\\\\\\" \[\\\n \\\\\\"\\\\\\"\\\n ],\\\n \\\\\\"restart\\\\\\" false,\\\n \\\\\\"labels\\\\\\" {}\\\n}\\";\n\nvar requestoptions = {\n method 'post',\n headers myheaders,\n body raw,\n redirect 'follow'\n};\n\nfetch(\\"https //api gameye io/session\\", requestoptions)\n then(response => response text())\n then(result => console log(result))\n catch(error => console log('error', error));", "language" "javascript", "customlabel" "" }, { "id" "jlpdbqhhpia7wy095citi", "code" "import requests\n\nurl = \\"https //api gameye io/session\\"\n\npayload = \\"{\\\n \\\\\\"id\\\\\\" \\\\\\"f7965a22 e327 4541 a30e 8262890d3a29\\\\\\",\\\n \\\\\\"location\\\\\\" \\\\\\"europe\\\\\\",\\\n \\\\\\"image\\\\\\" \\\\\\"nginx\\\\\\",\\\n \\\\\\"env\\\\\\" {},\\\n \\\\\\"args\\\\\\" \[\\\n \\\\\\"\\\\\\"\\\n ],\\\n \\\\\\"restart\\\\\\" false,\\\n \\\\\\"labels\\\\\\" {}\\\n}\\"\nheaders = {\n 'accept' 'application/json'\n}\n\nresponse = requests request(\\"post\\", url, headers=headers, data=payload)\n\nprint(response text)", "language" "python", "customlabel" "" }, { "id" "ikjg1yfei5aikwd5xbhts", "code" "require \\"uri\\"\nrequire \\"net/http\"\n\nurl = uri(\\"https //api gameye io/session\\")\n\nhttps = net http new(url host, url port)\nhttps use ssl = true\n\nrequest = net http post new(url)\nrequest\[\\"accept\\"] = \\"application/json\\"\nrequest body = \\"{\\\n \\\\\\"id\\\\\\" \\\\\\"f7965a22 e327 4541 a30e 8262890d3a29\\\\\\",\\\n \\\\\\"location\\\\\\" \\\\\\"europe\\\\\\",\\\n \\\\\\"image\\\\\\" \\\\\\"nginx\\\\\\",\\\n \\\\\\"env\\\\\\" {},\\\n \\\\\\"args\\\\\\" \[\\\n \\\\\\"\\\\\\"\\\n ],\\\n \\\\\\"restart\\\\\\" false,\\\n \\\\\\"labels\\\\\\" {}\\\n}\\"\n\nresponse = https request(request)\nputs response read body", "language" "ruby", "customlabel" "" }, { "id" "vrd0grwaanudzyjawe2bb", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //api gameye io/session',\n 'headers' {\n 'accept' 'application/json'\n },\n body '{\\"id\\" \\"string\\",\\"location\\" \\"string\\",\\"image\\" \\"string\\",\\"env\\" \\"object\\",\\"args\\" \\"string\\",\\"restart\\" \\"boolean\\",\\"labels\\" \\"object\\"}'\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "language" "nodejs", "customlabel" "" } ], "selectedlanguageid" "qt wn0jzgmvwm 8gwnf08" }, "description" "", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } although not depicted in the api responses, 420 is still returned for sessions that failed to start