BETA

Newgrounds.io Component List

Below is a comprehensive list of available components.


App

Used to get and validate information associated with your app, including user sessions.

App.checkSession

Checks the validity of a session id and returns the results in a session object.

  • Requires a session ID.

Parameters:

This component does not take any parameters

App.endSession

Ends the current session, if any.

  • Requires a session ID.

Parameters:

This component does not take any parameters

App.getCurrentVersion

Gets the version number of the app as defined in your "Version Control" settings.

Parameters:

version — string
The version number (in "X.Y.Z" format) of the client-side app. (default = "0.0.0")

App.getHostLicense

Checks a client-side host domain against domains defined in your "Game Protection" settings.

Parameters:

host — string
The host domain to check (ei, somesite.com).

App.logView

Increments "Total Views" statistic.

Parameters:

host* — string
The domain hosting your app. Examples: "www.somesite.com", "localHost"

* Required parameter

App.startSession

Starts a new session for the application.

Parameters:

force — boolean
If true, will create a new session even if the user already has an existing one.

Note: Any previous session ids will no longer be valid if this is used.


Event

Handles logging of custom events.

Event.logEvent

Logs a custom event to your API stats.

Parameters:

event_name* — string
The name of your custom event as defined in your Referrals & Events settings.

host* — string
The domain hosting your app. Example: "newgrounds.com", "localHost"

* Required parameter


Gateway

Provides information about the gateway server.

Gateway.getDatetime

Loads the current date and time from the Newgrounds.io server.

Parameters:

This component does not take any parameters

Gateway.getVersion

Returns the current version of the Newgrounds.io gateway.

Parameters:

This component does not take any parameters

Gateway.ping

Pings the Newgrounds.io server.

Parameters:

This component does not take any parameters


Loader

This class handles loading various URLs and tracking referral stats.

Note: These calls do not return any JSON packets. Instead, they redirect to the appropriate URL. These calls should be executed in a browser window vs using AJAX or any other internal loaders.

Loader.loadAuthorUrl

Loads the official URL of the app's author (as defined in your "Official URLs" settings), and logs a referral to your API stats.

For apps with multiple author URLs, use Loader.loadReferral.

Parameters:

host* — string
The domain hosting your app. Example: "www.somesite.com", "localHost"

redirect — boolean
Set this to false to get a JSON response containing the URL instead of doing an actual redirect.

* Required parameter

Loader.loadMoreGames

Loads the Newgrounds game portal, and logs the referral to your API stats.

Parameters:

host* — string
The domain hosting your app. Example: "www.somesite.com", "localHost"

redirect — boolean
Set this to false to get a JSON response containing the URL instead of doing an actual redirect.

* Required parameter

Loader.loadNewgrounds

Loads Newgrounds, and logs the referral to your API stats.

Parameters:

host* — string
The domain hosting your app. Example: "www.somesite.com", "localHost"

redirect — boolean
Set this to false to get a JSON response containing the URL instead of doing an actual redirect.

* Required parameter

Loader.loadOfficialUrl

Loads the official URL where the latest version of your app can be found (as defined in your "Official URLs" settings), and logs a referral to your API stats.

Parameters:

host* — string
The domain hosting your app. Example: "www.somesite.com", "localHost"

redirect — boolean
Set this to false to get a JSON response containing the URL instead of doing an actual redirect.

* Required parameter

Loader.loadReferral

Loads a custom referral URL (as defined in your "Referrals & Events" settings), and logs the referral to your API stats.

Parameters:

host* — string
The domain hosting your app. Example: "www.somesite.com", "localHost"

redirect — boolean
Set this to false to get a JSON response containing the URL instead of doing an actual redirect.

referral_name* — string
The name of the referral (as defined in your "Referrals & Events" settings).

* Required parameter


Medal

Handles loading and unlocking of medals.

Medal.getList

Loads a list of medal objects.

Parameters:

This component does not take any parameters

Medal.unlock

Unlocks a medal.

  • Requires a session ID.
  • User must be logged in.
  • If encryption is enabled, must be sent in a secure call.

Parameters:

id* — int
The numeric ID of the medal to unlock.

* Required parameter


ScoreBoard

Handles loading and posting of high scores and scoreboards.

ScoreBoard.getBoards

Returns a list of available scoreboards.

Parameters:

This component does not take any parameters

ScoreBoard.getScores

Loads a list of score objects from a scoreboard. Use 'skip' and 'limit' for getting different pages.

Parameters:

id* — int
The numeric ID of the scoreboard.

limit — int
An integer indicating the number of scores to include in the list. Default = 10.

period — string
The time-frame to pull scores from (see notes for acceptable values).

skip — int
An integer indicating the number of scores to skip before starting the list. Default = 0.

social — boolean
If set to true, only social scores will be loaded (scores by the user and their friends). This param will be ignored if there is no valid session id and the 'user' param is absent.

tag — string
A tag to filter results by.

user — mixed
A user's ID or name. If 'social' is true, this user and their friends will be included. Otherwise, only scores for this user will be loaded. If this param is missing and there is a valid session id, that user will be used by default.

* Required parameter

ScoreBoard.postScore

Posts a score to the specified scoreboard.

  • Requires a session ID.
  • User must be logged in.
  • If encryption is enabled, must be sent in a secure call.

Parameters:

id* — int
The numeric ID of the scoreboard.

tag — string
An optional tag that can be used to filter scores via ScoreBoard.getScores

value* — int
The int value of the score.

* Required parameter