curl -X GET "http://127.0.0.1:7350/v2/tournament?category_start=<category_start>&category_end=<category_end>&start_time=<start_time>&end_time=<end_time>&limit=<limit>&cursor=<cursor>"\
-H 'Authorization: Bearer <session token>'
Client
1
2
3
4
5
6
7
varcategoryStart=1;varcategoryEnd=2;varstartTime=1538147711;varendTime=null;// all tournaments from the start time
varlimit=100;// number to list per page
varcursor=null;varresult=awaitclient.listTournaments(session,categoryStart,categoryEnd,startTime,endTime,limit,cursor);
Client
1
2
3
4
5
6
7
varcategoryStart=1;varcategoryEnd=2;varstartTime=1538147711;varendTime=null;// all tournaments from the start timevarlimit=100;// number to list per pagevarcursor=null;varresult=awaitclient.ListTournamentsAsync(session,categoryStart,categoryEnd,startTime,endTime,limit,cursor);
Client
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
autosuccessCallback=[](NTournamentListPtrlist){std::cout<<"Tournament count "<<list->tournaments.size()<<std::endl;for(auto&tournament:list->tournaments){std::cout<<"Tournament ID "<<tournament.id<<", title "<<tournament.title<<std::endl);}};uint32_tcategoryStart=1;uint32_tcategoryEnd=2;uint32_tstartTime=1538147711;uint32_tendTime=null;// all tournaments from the start time
int32_tlimit=100;// number to list per page
client->listTournaments(session,categoryStart,categoryEnd,startTime,endTime,limit,opt::nullopt,successCallback);
Client
1
2
3
4
5
6
7
intcategoryStart=1;intcategoryEnd=2;intstartTime=1538147711;intendTime=null;// all tournaments from the start timeintlimit=100;// number to list per pageStringcursor=null;TournamentListtournaments=client.listTournaments(session,categoryStart,categoryEnd,startTime,endTime,limit,cursor).get();
Client
1
2
3
4
5
6
7
8
9
10
11
varcategory_start=1varcategory_end=2varstart_time=1538147711varend_time=null# all tournaments from the start timevarlimit=100# number to list per pagevarcursor=nullvarresult:NakamaAPI.ApiTournamentList=yield(client.list_tournaments_async(session,category_start,category_end,start_time,end_time,limit,cursor),"completed")ifresult.is_exception():print("An error occurred: %s"%result)returnprint("Tournaments: %s"%[result])
autosuccessCallback=[](){std::cout<<"Successfully joined tournament"<<std::cout;};stringid="someid";client->joinTournament(session,id,successCallback);
varid="someid";varscore=100L;varsubscore=10L;// using Nakama.TinyJson;varmetadata=newDictionary<string,string>(){{"weather_conditions","sunny"},{"track_name","Silverstone"}}.ToJson();varnewRecord=awaitclient.WriteTournamentRecordAsync(session,id,score,subscore,metadata);Console.WriteLine(newRecord);
localid="4ec4f126-3f9d-11e7-84ef-b7c182b36521"localsort="desc"-- one of: "desc", "asc"localoperator="best"-- one of: "best", "set", "incr"localreset="0 12 * * *"-- noon UTC each daylocalmetadata={weather_conditions="rain"}title="Daily Dash"description="Dash past your opponents for high scores and big rewards!"category=1start_time=nk.time()/1000-- starts now in secondsend_time=0-- never end, repeat the tournament each day foreverduration=3600-- in secondsmax_size=10000-- first 10,000 players who joinmax_num_score=3-- each player can have 3 attempts to scorejoin_required=true-- must join to competenk.tournament_create(id,sort,operator,duration,reset,metadata,title,description,category,start_time,end_time,max_size,max_num_score,join_required)
// import "github.com/gofrs/uuid"
id:=uuid.Must(uuid.NewV4())sortOrder:="desc"// one of: "desc", "asc"
operator:="best"// one of: "best", "set", "incr"
resetSchedule:="0 12 * * *"// noon UTC each day
metadata:=map[string]interface{}{}title:="Daily Dash"description:="Dash past your opponents for high scores and big rewards!"category:=1startTime:=int(time.Now().UTC().Unix())// start now
endTime:=0// never end, repeat the tournament each day forever
duration:=3600// in seconds
maxSize:=10000// first 10,000 players who join
maxNumScore:=3// each player can have 3 attempts to score
joinRequired:=true// must join to compete
err:=nk.TournamentCreate(ctx,id.String(),sortOrder,operator,resetSchedule,metadata,title,description,category,startTime,endTime,duration,maxSize,maxNumScore,joinRequired)iferr!=nil{logger.Printf("unable to create tournament: %q",err.Error())return"",runtime.NewError("failed to create tournament",3)}
letid='4ec4f126-3f9d-11e7-84ef-b7c182b36521';letsortOrder=nkruntime.SortOrder.DESCENDING;letoperator=nkruntime.Operator.BEST;letduration=3600;// In seconds.
letresetSchedule='0 12 * * *';// Noon UTC each day.
letmetadata={weatherConditions:'rain',};lettitle='Daily Dash';letdescription="Dash past your opponents for high scores and big rewards!";letcategory=1;letstartTime=0;// Start now.
letendTime=0;// Never end, repeat the tournament each day forever.
letmaxSize=10000;// First 10,000 players who join.
letmaxNumScore=3;// Each player can have 3 attempts to score.
letjoinRequired=true;// Must join to compete.
try{nk.tournamentCreate(id,sortOrder,operator,duration,resetSchedule,metadata,title,description,category,startTime,endTime,maxSize,maxNumScore,joinRequired);}catch(error){// Handle error
}
err:=nk.TournamentDelete(ctx,id)iferr!=nil{logger.Printf("unable to delete tournament: %q",err.Error())return"",runtime.NewError("failed to delete tournament",3)}
id:="someid"userID:="someuserid"attempts:=10err:=nk.TournamentAddAttempt(ctx,id,userID,attempts)iferr!=nil{logger.Printf("unable to update user %v record attempts: %q",userID,err.Error())return"",runtime.NewError("failed to add tournament attempts",3)}