Kongregate API

How can I use Kongregate API with a GD game? I had a look at some tutorials I found on the internet today, but they were written from the perspective of Construct 2 or other game engines and didn’t seem to really work. Help much appreciated.

I’m working in an API implementation for gamejolt.com

I just take a look at the kongregate.com API and it’s more hard to manage in some aspects and easier in others

If i succeed in the gamejolt.com API implementation maybe my work will be useful as a template for others web-calls based APIs.

Erdo did you succeed to implement game achievements for gamejolt game ?

erdo hasn’t been active for a while, I hope he’s alright…

I made it: (it’s the same as in an another topic, but at least if someone see this first they get the answer faster :wink: )
It took me 4 hours to figure out and the joke is that I did it right at the first try, but I didn’t write an “S” to the “https” and it didn’t work lol…

So you probably know how to upload a game to kongregate, if not, that’s fine too. You can look it up in the tutorials, it is explained well.
When you “Export to web” your game (without minify, it won’t work on Kongregate), you get an “index.html” file. You need to open that up (with normal edit mode which is bad, or with sublime text editor or something similar program), than you need to write, or copy “” (without the “” at the start and end) this badboy after the first “”. This way you get acces to the api… And this is it lol. Nothing complicate, nothing hard work. (if it’s not working look at your addres bar and if it’s “http://kongregate.com” than remove the “s” from this code too like this: “” it has to have http/https like the site )

If you want to use the api, well that’s an another thing. I didn’t use it yet, I just figured out how to get it work and tested it out with this little code, what writes out the name of the user in a “text object” (I modyfied the text object to write out the variable tut don’t know why tut :laughing: and that variable holds the username ): prntscr.com/lghthd
And I’m sorry, you probably use this program for not doing any programming, like me (not because I couldn’t learn, it’s just easier to make flash games with), but you can’t use the api without codes. :frowning:
I hope I wrote it down in a way that even someone who knowes nothing about programming can use it, but even if you implent it, you can’t use it so… sorry. Maybe if I get used to the kongregateAPI I’ll write an article about how to use it:?:

Yup, almost the same code I used back then. Just want to note that it should be “tut.setString”, not “tut.setNumber” :slight_smile:

Also, the variable “kongregate” won’t be defined outside this JS event block, you may want to better set it as a scene or game property?

runtimeScene.kongregate = kongregateAPI.getAPI()

Great work btw :smiley:

Thank you. :slight_smile:
But I got a problem today yay! When I’m sending a variable to the kongregate statistics it gives me an error “Invalid stat name or value: High Score”, not the name is the problem, probably I defined the variable wrong, but I don’t know how to do it, if this is wrong: prntscr.com/lgp2zq
Oh and yeah I noticed I need to define kongregate everytime this way, but it’s just a line so not a big problem. Thanks for the advice though I’ll use that. :wink:
And even if I write that code in it I can only use it only for that scene, a global variable would be better. Is there a code like:
:question: runtimeGlobal.kongregate = kongregateAPI.getAPI() :question:

I got it, a guy from the kongregate dev forum send me the info how to repair it, I just ned to write a “._value” to the variable: before: “kongregate.stats.submit(“High Score”,Longest);”
after: kongregate.stats.submit(“High Score”,Longest._value);
It’s so simple and yet do so much XD I love programing.
Also this is one of the things why I prefer gDevelop over writing a flash game… XD

Well, the ._value is a bit hacky, and won’t work for strings, you should use:

MyVariable.getAsNumber()

or

MyVariable.getAsString()

Also note that your problem was not related with kongregate at all, just a miss use of the GDJS api. They helped you anyway, nice guys! :smiley:

And to set the “kongregate” as global, you can add it to gdjs:

gdjs.kongregate = ...

gdjs is a special object defined globally, we add new extensions info there too :slight_smile:

Thank you for the help.
I’ll use gdjs.kongregate = … than :smiley:
I don’t really need string, because the only thing those High Scores can read are values, but maybe there will be places where that is usefull. :smiley: