Get the teams that the player is in. Can be filtered on team type and also on those teams that the player owns.

View interactive version here

Request Parameters

Parameter Required Type Description
ownedOnly No boolean Set to true to only get teams owned by the player
teamTypes No string[] The type of teams to get

Response Parameters

A response containing team data for teams that a player belong to

Parameter Type Description
scriptData ScriptData A JSON Map of any data added either to the Request or the Response by your Cloud Code
teams Team[] The team data

Nested types


A collection of arbitrary data that can be added to a message via a Cloud Code script.

Parameter Type Description
myKey string An arbitrary data key
myValue JSON An arbitrary data value.


A nested object that represents a player.

Parameter Type Description
achievements string[] The achievements of the Player
displayName string The display name of the Player
externalIds JSON The external Id's of the Player
id string The Id of the Player
online boolean The online status of the Player
scriptData JSON The script data of the Player
virtualGoods string[] The virtual goods of the Player


A nested object that represents the team.

Parameter Type Description
members Player[] The team members
owner Player A summary of the owner
teamId string The Id of the team
teamName string The team name
teamType string The team type

Error Codes

Key Value Description
authentication NOTAUTHORIZED The player is not authorized to perform the request

Code Samples


    using GameSparks.Api;
    using GameSparks.Api.Requests;
    using GameSparks.Api.Responses;
    new GetMyTeamsRequest()
        .Send((response) => {
        GSData scriptData = response.ScriptData;
        GSEnumerable<GetMyTeamsResponse._Team> teams = response.Teams;

ActionScript 3

    import com.gamesparks.*;
    import com.gamesparks.api.requests.*;
    import com.gamesparks.api.responses.*;
    import com.gamesparks.api.types.*;

        .send(function(response:com.gamesparks.api.responses.GetMyTeamsResponse):void {
        var scriptData:ScriptData = response.getScriptData(); 
        var teams:Vector.<Team> = response.getTeams(); 


    #import "GS.h"
    #import "GSAPI.h"
    GSGetMyTeamsRequest* request = [[GSGetMyTeamsRequest alloc] init];
    [request setOwnedOnly:ownedOnly;
    [request setTeamTypes:teamTypes;
    [request setCallback:^ (GSGetMyTeamsResponse* response) {
    NSDictionary* scriptData = [response getScriptData]; 
    NSArray* teams = [response getTeams]; 
    [gs send:request];


    #include <GameSparks/generated/GSRequests.h>
    using namespace GameSparks::Core;
    using namespace GameSparks::Api::Responses;
    using namespace GameSparks::Api::Requests;

    void GetMyTeamsRequest_Response(GS& gsInstance, const GetMyTeamsResponse& response) {
    GSData scriptData = response.getScriptData(); 
    gsstl:vector<Types::Team*> teams = response.getTeams(); 

    GetMyTeamsRequest request(gsInstance);


import com.gamesparks.sdk.api.autogen.GSRequestBuilder.GetMyTeamsRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.GetMyTeamsResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;

    .send(new GSEventListener<GetMyTeamsResponse>() {
        public void onEvent(GetMyTeamsResponse response) {
            List<Team> teams = response.getTeams(); 

Cloud Code

    var request = new SparkRequests.GetMyTeamsRequest();
    request.ownedOnly = ...;
    request.teamTypes = ...;
    var response = request.Send();

var scriptData = response.scriptData; 
var teams = response.teams;