- Notifications
You must be signed in to change notification settings - Fork0
License
NotificationsYou must be signed in to change notification settings
codewithsathya/leetcode-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The API to get user profiles, submissions, and problems on LeetCode, with highly customizable GraphQL API and Rate Limiter.
- Get Public User Profile.
- Get User's Recent Submissions. (Public, Max: 20)
- Get User Contest Records. (thanks to@laporchen)
- Get All Problem List, or with filter of difficulty and tags.
- Get Problem Detail.
- Get Daily Challenge.
- Get All Submissions of The Authenticated User.
- Get Submission Details, including the code and percentiles.
- Customable GraphQL Query API.
- Customable Rate Limiter. (Default: 20 req / 10 sec)
- Customable Fetcher.
Includes recent submissions and posts.
import{LeetCode}from'leetcode-query';constleetcode=newLeetCode();constuser=awaitleetcode.user('username');
import{LeetCode,Credential}from'leetcode-query';constcredential=newCredential();awaitcredential.init('YOUR-LEETCODE-SESSION-COOKIE');constleetcode=newLeetCode(credential);console.log(awaitleetcode.submissions(100,0));
You can use your own fetcher, for example, fetch through a real browser.
import{LeetCode,fetcher}from'leetcode-query';import{chromium}from'playwright-extra';importstealthfrom'puppeteer-extra-plugin-stealth';// setup browserconst_browser=chromium.use(stealth()).launch();const_page=_browser.then((browser)=>browser.newPage()).then(async(page)=>{awaitpage.goto('https://leetcode.com');returnpage;});// use a custom fetcherfetcher.set(async(...args)=>{constpage=await_page;constres=awaitpage.evaluate(async(args)=>{constres=awaitfetch(...args);return{body:awaitres.text(),status:res.status,statusText:res.statusText,headers:Object.fromEntries(res.headers),};},args);returnnewResponse(res.body,res);});// use as normalconstlc=newLeetCode();constdaily=awaitlc.daily();console.log(daily);await_browser.then((browser)=>browser.close());
Documentation for this package is available onhttps://jacoblincool.github.io/LeetCode-Query/.
- NPM Package:https://www.npmjs.com/package/leetcode-query
- GitHub Repository:https://github.com/JacobLinCool/LeetCode-Query/
About
No description, website, or topics provided.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.