Newgrounds.io Object Models
Much of the data the Newgrounds.io server uses exists in structured objects. Below are details on how each of these objects are modelled.
Debug
Contains extra debugging information.
Properties:
exec_time
—
string
The time, in milliseconds, that it took to execute a request.
request
—
Request object
A copy of the request object that was posted to the server.
NOTES: This object is only used in debug mode.
Error
Properties:
code
—
int
A code indicating the error type.
message
—
string
Contains details about the error.
NOTES: You may see the following error codes
100 = Missing Input
101 = Invalid Input
102 = Missing Parameter
103 = Invalid Parameter
104 = Expired Session
105 = Duplicate Session
106 = Max Connections Exceeded
107 = Max Calls Exceeded
108 = Max Memory Exceeded
109 = Execution Timed Out
110 = Login Required
111 = Session Cancelled
200 = Invalid App ID
201 = Invalid Encryption
202 = Invalid Medal ID
203 = Invalid Scoreboard ID
403 = Forbidden
504 = Server Unavailable
Execute
Contains all the information needed to execute an API component.
Properties:
component*
—
string
The name of the component you want to call, ie 'App.connect'.
(Only required if 'secure' is not set.)
echo
—
mixed
An optional value that will be returned, verbatim, in the Result object.
parameters
—
object or array of
objects
An object of parameters you want to pass to the component.
(Only used if 'secure' is not set.)
secure*
—
string
A an encrypted Execute object or array of Execute objects.
(Only required if 'component' is not set.)
* Required property
NOTES: For secure calls using encryption, you only need to pass the 'secure' property. For all other calls, you only need to use the 'component' and 'parameters' properties.
Medal
Contains information about a medal.
Properties:
description
—
string
A short description of the medal.
difficulty
—
int
The difficulty id of the medal: 1 = easy, 2 = moderate, 3 = challenging, 4 = difficult, 5 = brutal.
icon
—
string
The URL for the medal's icon (typically a webp file).
id
—
int
The numeric ID of the medal.
name
—
string
The name of the medal.
secret
—
boolean
unlocked
—
boolean
This will only be set if a valid session_id exists in the request object.
value
—
int
The medal's point value.
Request
A top-level wrapper containing any information needed to authenticate the application/user and any component calls being made.
Properties:
app_id*
—
string
Your application's unique ID.
debug
—
boolean
If set to true, calls will be executed in debug mode.
echo
—
mixed
An optional value that will be returned, verbatim, in the Response object.
execute*
—
Execute object
or array of
Execute objects
A Execute object, or array of one-or-more Execute objects.
session_id
—
string
An optional login session id. Components that save and unlock things to a user account will require this.
* Required property
Response
Contains all return output from an API request.
Properties:
api_version
—
string
If there was an error, this will contain the current version number of the API gateway.
app_id
—
string
Your application's unique ID
debug
—
Debug object
Contains extra information you may need when debugging (debug mode only).
echo
—
mixed
If you passed an 'echo' value in your request object, it will be echoed here.
error
—
Error object
This will contain any error info if the success property is false.
result
—
Result object
or array of
Result objects
This will be a Result object, or an array containing one-or-more Result objects (this will match the structure of the execute property in your Request object).
success
—
boolean
If false, there was a problem with your 'request' object. Details will be in the error property.
Result
Contains information returned by an API component.
Properties:
component
—
string
The name of the component that was executed (ie 'Medal.unlock').
data
—
object or array of
objects
An object, or array of objects containing the result properties for the executed component.
echo
—
mixed
If you passed an 'echo' value in your execute object, it will be echoed here.
error
—
Error object
This will contain any error info if the success property is false.
success
—
boolean
If false, there was a problem with your 'request' object. Details will be in the error property.
NOTES: The success value is only associated with your request object. If your request was good, but your component(s) have errors, those will be found in the success/error properties of the data object.
SaveSlot
Contains information about a CloudSave slot.
Properties:
datetime
—
string
A date and time (in ISO 8601 format) representing when this slot was last saved.
id
—
int
The slot number.
size
—
int
The size of the save data in bytes.
timestamp
—
int
A unix timestamp representing when this slot was last saved.
url
—
string
The URL containing the actual save data for this slot, or null if this slot has no data.
Score
Contains information about a score posted to a scoreboard.
Properties:
formatted_value
—
string
The score value in the format selected in your scoreboard settings.
tag
—
string
The tag attached to this score (if any).
user
—
User object
The user who earned this score. If this property is absent, the score belongs to the active user.
value
—
int
The integer value of the score.
ScoreBoard
Contains information about a scoreboard.
Properties:
id
—
int
The numeric ID of the scoreboard.
name
—
string
The name of the scoreboard.
Session
Contains information about the current user session.
Properties:
expired
—
boolean
If true, the session_id is expired. Use App.startSession to get a new one.
id
—
string
A unique session identifier
passport_url
—
string
If the session has no associated user but is not expired, this property will provide a URL that can be used to sign the user in.
remember
—
boolean
If true, the user would like you to remember their session id.
user
—
User object
If the user has not signed in, or granted access to your app, this will be null
NOTES: Remembered sessions will expire after 30 days of inactivity. All other sessions will expire after one hour of inactivity.
Session expirations get renewed ay time a request object passes a session_id. You could use that, along with 'Gateway.ping', every 5 minutes to keep your user's session alive.
User
Contains information about a user.
Properties:
id
—
int
The user's numeric ID.
name
—
string
The user's textual name.
supporter
—
boolean
Returns true if the user currently has a Newgrounds Supporter upgrade.
url
—
string
The URL to the user's profile.