It's been a long time since I used it in my Phaser game (which is basically just JavaScript) but my recollection is that I got the newgroundsio.js file from the old deprecated version of the API implementation in the /bin subdirectory and put it in a /bin directory of my game, then had code like so at the top of my index.html file before the JavaScript with my actual game:
<script src="bin/newgroundsio.js" type="text/javascript"></script>
Then came the script with my game, including the following lines
// Start NewGrounds.io
var ngio = new Newgrounds.io.core("my_app_id_went_here", "my_aes_encryption_key_went_here");
and later
if (ngio.session_id != null) {
if (wonZoom + wonNoZoom > 0) {
ngio.callComponent('Medal.unlock', {id: one_of_my_medal_ids_went_here});
}
if (wonZoom + wonNoZoom == buttonSprite.length) {
ngio.callComponent('Medal.unlock', {id: another_medal_id_went_here});
}
if (wonNoZoom == buttonSprite.length) {
ngio.callComponent('Medal.unlock', {id: the_last_medal_id_went_here});
}
}
TBH I didn't even know JavaScript when I started this for a month-long Phaser jam so I probably wasn't using good programming practices but it seemed to work. Using the newer version at the top of the list on the newgrounds.io page might be better, but I haven't used it myself.