uwcsc / codeybot

Discord CodeyBot used for mock interviewing, suggestions and other features.
19 stars 18 forks source link

[SPIKE]: Leetcode API Usage #513

Open probro27 opened 8 months ago

probro27 commented 8 months ago

We want to use Leetcode APIs to build an automated system for Weekly contests where if people solve certain questions they earn CodeyCoins.

This is a research task to figure out if Leetcode API has the features we need to actually build this, or if we need any separate third party API for this data.

The data we get from the user:

The data we want to access:

Currently we are using the leetcode api here https://github.com/uwcsc/codeybot/blob/main/src/components/leetcode.ts

KuroganeToyama commented 4 months ago

I digged through several different repos and only managed to find one thing that would work. https://github.com/alfaarghya/alfa-leetcode-api/blob/main/src/GQLQueries/contest.ts

I tested it on Postman. The query returns info on all past contests, but we can always filter out to grab the Weekly Contests ones. It doesn't give us info on specific questions, so my suggestion is that we can just simply reward CodeyCoin based on the number of questions they solved. Unfortunately, it doesn't give us info for the optional criteria you listed, but other than that, everything else looks promising.

Unfortunately again, I myself have never attempted a Weekly Contest (never really got the time) so it would be nice if you or someone else, who have attempted a Weekly Contest, to test out the query and check out the data. But I'm pretty confident about the query already.