menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

WarriorJS

An exciting game of programming and Artificial Intelligence

Channels
Team

Hey, is there a public API for getting the leaderboard data, and game…

August 21, 2018 at 8:49am

Hey, is there a public API for getting the leaderboard data, and game statistics? I need to get the top 10 players off https://warriorjs.com/leaderboard for a project I'm working on, but I can't find anything.. :(

August 21, 2018 at 8:49am (Edited 3 years ago)

October 3, 2018 at 3:38pm
Hey! The API is a GraphQL API, and although it is not exactly public, the leaderboard query in particular is. You can see how it is being called by using the browser inspector's Network tab on the home page.
Just out of curiosity, what project are you working on?

October 8, 2018 at 11:39pm
Hey, thanks for the reply - I'll check it out later!And, for your curiosity, I was working on a Warrior.js Discord bot for players, like me.
Adding onto it, I've never used GraphQL, is it like REST?
No, it's different, you can learn more about it here: https://graphql.org
You'll still use HTTP and JSON though
This is the HTTP request (in cURL) you need to make to get the Top 10 scores:
curl 'https://api.warriorjs.com/graphql' -H 'content-type: application/json' --data-binary '{"operationName":"Leaderboard","variables":{"limit":10},"query":"query Leaderboard($limit: Int) {\n leaderboard(limit: $limit) {\n username\n country\n rank\n score\n __typename\n }\n}\n"}'

October 9, 2018 at 11:39pm
Hm, alright. Definitely more confusing than I thought it would be, thanks though.

October 11, 2018 at 1:35pm
I've got some experience writing discord bots, DM me if you'd like any help getting this stuff going