Shared Content

Kongregate Shared Content API

Kongregate's Content Sharing API makes it easy for developers to add features like custom level sharing to your games. The API gives your players the ability to:

  • Save in-game content like levels, characters and game customizations to Kongregate's servers for easy retrieval any time and from any computer.
  • Browse publicly shared, user-generated content through a Kongregate hosted UI
  • Share in-game content easily via direct links, email or by posting to top social media sites. (No more copying and pasting of long, ugly text strings!)

We urge you all to check out the first integration of level sharing in Hexiom: Connect and view the following API documents for more information:

Saving shared content on sites other than Kongregate

You may submit shared content created in versions of your game hosted on sites other than Kongregate. The API simply consists of a set of URL parameters you pass along with a GET request to your game's URL on Kongregate.

The relevant query parameters are type, content, and optionally, label. Note that this method is more limited in terms of the size of the content due to browser limitations with passing through a URL - they need to be limited to under 2,000 characters after encoding in order to ensure that it will work.

Additionally, a trailing &z must be appended to the URL to indicate the content was not truncated.

Example

This snippet is a simple function that accepts the relevant arguments and forwards them to Kongregate:

function toQueryString(params:Object):String {
  var q:Array = [];
  for (var p:String in params) {
    q.push(encodeURIComponent(p) + '=' + encodeURIComponent(params[p]));
  }
  return q.join('&');
}

function saveRemote(kongregateGameUrl:String, type:String,  			  
                    content:String, label:String=null):void {
  var loc:String = kongregateGameUrl + '?' + toQueryString({
    'type': contentType,
    'content': content,
    'label': label
  }) + '&z';

  // Make sure your URL isn't going to be too long to send through a browser
  if (loc.length < 2000) {
    navigateToURL(new URLRequest(loc), '_blank');
  } else {
  	trace('shared content too large');
  }
}
function toQueryString(params) {
  var q = [];
  for (var p in params) {
    q.push(encodeURIComponent(p) + '=' + encodeURIComponent(params[p]));
  }
  return q.join('&');
}

function saveRemote(kongregateGameUrl, type, content, label) {     
  var loc = kongregateGameUrl + '?' + toQueryString({
    'type': contentType,
    'content': content,
    'label': label
  }) + '&z';

  // Make sure your URL isn't going to be too long to send through a browser
  if (loc.length < 2000) {
    window.open(loc);
  } else {
  	alert('shared content too large');
  }
}

Shared Content


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.