Newgrounds. NewgroundsPlugin

Newgrounds API object

Constructor

new NewgroundsPlugin(app_id, cipheropt, cryptoJSopt)

Create the global newgrounds object

Parameters:
NameTypeAttributesDescription
app_idstring

The newgrounds App ID

cipherstring<optional>

The encryption Key (AES-128/Base64)

cryptoJSObject<optional>

An instance of CryptoJS, if there is a cipher

Example
// create the newgrounds object, replace the app id with your own
 const app_id = 'your_app_id_here';
 new NewgroundsPlugin(app_id);

Members

app_id

Properties
TypeDescription
string

The newgrounds App ID

cipher

Properties
TypeDescription
string | undefined

AES-128/Base64 encryption key, if any

cryptoJS

Properties
TypeDescription
Object | undefined

CryptoJS instance used when cipher is set

host

Properties
TypeDescription
string

Hostname used when logging views

medals

Properties
TypeDescription
Array

Medals fetched from Newgrounds (empty until session is active)

scoreboards

Properties
TypeDescription
Array

Scoreboards fetched from Newgrounds

session_id

Properties
TypeDescription
string | null

Newgrounds session id from the URL (null when not logged in)

Methods

call(component, parametersopt, asyncopt) → {Object}

Send a message to call a component of the Newgrounds API

Parameters:
NameTypeAttributesDefaultDescription
componentstring

Name of the component

parametersObject<optional>

Parameters to use for call

asyncboolean<optional>
false

If true, don't wait for response before continuing

Returns:
  • The response JSON object
Type: 
Object

getScores(id, useropt, socialopt, skipopt, limitopt) → {Object}

Get scores from a scoreboard

Parameters:
NameTypeAttributesDefaultDescription
idnumber

The scoreboard id

userstring<optional>

A user's id or name

socialnumber<optional>
0

If true, only social scores will be loaded

skipnumber<optional>
0

Number of scores to skip over

limitnumber<optional>
10

Number of scores to include in the list

Returns:
  • The response JSON object
Type: 
Object

logView()

Send message to log a view

postScore(id, value)

Send message to post score

Parameters:
NameTypeDescription
idnumber

The scoreboard id

valuenumber

The score value

unlockMedal(id)

Send message to unlock a medal by id

Parameters:
NameTypeDescription
idnumber

The medal id