Public API for statistics or other useful things

Hi dear CG staff,
It’s been a while since anybody talks about it so I’m asking the question here in a more specific way:

Is there any plan for a public API to get players stats, ranks, etc to allow the community to create cool tools that can be shared with everyone?

I know there is an exposed private API but well it’s private, so it’s awkward to work with, and I’m sure you guys don’t want everyone messing with it.

I, myself will like it to build stats-inclined tools like an achievement ranking (which achievement is the rarer for example), or a stat tool for sorting in detail all of your CG points and indicate where you could improve.

Anyway, is it planned? That would be a great addition to develop the community :grinning:

P.S: Since it’s addressed directly to the staff, I’ll take the liberty on calling @MaximeC here, please tell me if I should not.

3 Likes

I have some tools messing with the private API. Mostly some statistics for multiplayer puzzles (statistics for 1v1 games, 1v2 games, etc …). I have also a tool to know how many points i have in code golfing puzzles. A public API should be far better of course :smiley:

1 Like

A documented API would be nice for sure. However, we are currently busy working on new features that we think are more important for now. Plus, a public API would require to keep it stable and documented which is more work and less flexibility for us.

I can’t tell you when but be reassured that we will do it. Meanwhile, if you need to collect data for your tool, you can analyze the data (json) sent by our web services.

1 Like

So is it okay if we use the private api for now? Can we have details on which address we should execute our GET/POST request?

@Magus since you’ve already a tool running, if you could provide details here, it’d be awesome.

Hi @CvxFous,

I can send you a postman collection export if you want.

Request for a multiplayer game learderboard

POST https://www.codingame.com/services/LeaderboardsRemoteService/getChallengeLeaderboard
body : [gameId, id, "global"]
  • gameId: The unique id of a multiplayer game. Possible values are ["59","55","49","42","30","26","back-to-the-code","the-great-escape","platinum-rift-2","platinum-rift","winamax","parrot","20","82"]
  • id: This a id generated when your session is opened on the site. You can have it by copy/pasting an id when you are looking at a leaderboard. But sometime you can also give whatever you want and it works.
  • "global": This the value to filter the leaderboard. Give global for the main leaderboard and ranks. I don’t know the others values i don’t need them.

Get the last games of a player

POST https://www.codingame.com/services/gamesPlayersRankingRemoteService/findAllByTestSessionHandle
body : [id]
  • id: The id of a player. You can know it by using the leaderboard API.

Request for an optimization game (code golf) game leaderboard

This is the same as a multiplayer game, but possible id are just differents (and the returned JSON structure is different too)

POST https://www.codingame.com/services/LeaderboardsRemoteService/getChallengeLeaderboard
body : [gameId, id, "global"]
  • gameId: The unique id of a game. Possible values are ["thor-codesize","paranoid-codesize"] (i need to check the id of the new temperature puzzle)
  • id: This a id generated when your session is opened on the site. You can have it by copy/pasting an id when you are looking at a leaderboard. But sometime you can also give whatever you want and it works.
  • "global": This the value to filter the leaderboard. Give global for the main leaderboard and ranks. I don’t know the others values i don’t need them.
6 Likes

Thanks a lot @Magus and @momopouccino I’ll look into that.

EDIT: @Magus this works great but how do I get those url? I mean this isn’t the complete API, so how did you get the rest?

Reverse engineering skills :smiley:
When you browse a website, you can open the developper console (F12 by default). You have a tool to see all AJAX requests. So you can know how data are fetched and you do the same.

@Magus thanks I feel dumb not to have think about it earlier :slight_smile: @momopouccino gave me the same answer not long ago :grinning:

Can u send me the Posstman collection?

Is there a way to get the test cases inputs via API?