Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Newgrounds API

An initial implementation of the Newgrounds RESTful API in C# for Unity with no JavaScript bridges. It tries to mimic the syntax of the AS3 version of the API, although only a handful of methods are available.

This is currently used in my Escape Drill game for Ludum Dare #29, but missing a lot of features.


  1. Copy the contents of the newgrounds folder to your Unity project's "Scripts" folder
  2. Anywhere in your code (e.g. your Main game class), connect to the API:
Newgrounds.API.Connect(apiId, encryptionKey);
  1. Whenever you need to submit statistics, do:
Newgrounds.API.PostScore(name, value);

For example:

Newgrounds.API.PostScore("High Score (level 1)", 1000);
Newgrounds.API.PostScore("Tanks Destroyed", 10);

Full Interface

  • Newgrounds.API.Connect(string apiId, string encriptionKey) (Static): Connects to the API. You need to do this before anything is posted. You can find the API id and encryption key values in the API Tools section of your project.
  • Newgrounds.API.PostScore(string name, int value) (Static): submit a score to the Newgrounds API. The name is not an id, but rather how the score is represented in the website.
  • string connectionUserName: current user name. Read-only.
  • int connectionUserId: id of the current user. Read-only.
  • string connectionSessionId: a long hash with the id of the current session. Read-only.


The API will not work inside the editor by default. This is because it needs some kind of session ID that is passed by the website when the game is ran. However, the API does detect when you're running inside the editor and attempt to use a placeholder URL. To replace this placeholder URL with a real URL, go to your game's page, find the URL of the iframe used to host it, and replace the setContainerURLStatic() call in line 45 of API.cs with this url. It will look like this:


  • A lot is missing. Actually it only posts high scores right now.

More information

You can’t perform that action at this time.