Kongregate Developers

Kongregate General Services API

The Kongregate Services API allows access to some common functions that you may find useful while developing your game. It can be used to get information about the player, including username, guest status, authentication token, etc.

API Functions

Connecting

The connect function should be used as soon as you have access to the Kongregate API object in order to initialize the connection to our servers:

connect():void
kongregate.services.connect();

Checking if the user is a guest

The isGuest function can be called to determine if the player is currently signed into Kongregate or not:

isGuest():Boolean
var isGuest:Boolean = kongregate.services.isGuest();

Getting the player's Kongregate username

You can use the getUsername() function to retrieve the username of the current player. It will begin with Guest if the user is not signed in.

getUsername():String
var username:String = kongregate.services.getUsername();

Getting the player's Kongregate user id

You can use the getUserId() function to retrieve the unique user id of the current player. It will return 0 if the user is not signed in.

getUserId():String
var user_id:Number = kongregate.services.getUserId();

Getting the player's game authentication token

If you are using the Authentication API you can use the getGameAuthToken function to get the player's game authentication token:

getGameAuthToken():String
var token:String = kongregate.services.getGameAuthToken();

Showing the sign-in box

If the player is a guest, and you want to display the sign-in/registration UI to them (for example, if you want to upsell them to buy an item or you want to use the authentication API), you can use the showSignInBox function:

showSignInBox():void
if(kongregate.services.isGuest()){
  kongregate.services.showSignInBox();
}

You can read the section on handling guests for more information on how to tell when a user completes registration or signing in.

Comments