alfa-leetcode-api icon indicating copy to clipboard operation
alfa-leetcode-api copied to clipboard

scope of improvement in "*/submission" endpoint

Open Rudrajiii opened this issue 1 year ago • 11 comments

in https://alfa-leetcode-api.onrender.com/username/submission endpoint u r having only the question details , no of submissions and other things , but u r not fetching the last submitted code we can do this for better interpretation of this submission endpoint , thank you :)

Rudrajiii avatar Aug 10 '24 17:08 Rudrajiii

look i have found the response as well check out "code" key pair :

{ "data": { "submissionDetails": { "runtime": 519, "runtimeDisplay": "519 ms", "runtimePercentile": 64.62090000000013, "runtimeDistribution": "{"lang": "python3", "distribution": [["46", 0.004], ["53", 0.0202], ["61", 0.048499999999999995], ["68", 0.08099999999999999], ["75", 0.024200000000000006], ["83", 0.0061], ["90", 0.002], ["97", 0.002], ["105", 0.002], ["112", 0.004], ["119", 0.0121], ["126", 0.006], ["134", 0.004], ["141", 0.006], ["148", 0.022199999999999998], ["156", 0.04039999999999999], ["163", 0.028200000000000003], ["170", 0.012], ["178", 0.002], ["185", 0.002], ["192", 0.002], ["199", 0.002], ["207", 0.002], ["214", 0.002], ["221", 0.004], ["229", 0.002], ["236", 0.002], ["243", 0.002], ["251", 0.002], ["258", 0.002], ["265", 0.004], ["272", 0.004], ["280", 0.004], ["287", 0.002], ["294", 0.0081], ["302", 0.0081], ["309", 0.0182], ["316", 0.0101], ["324", 0.0101], ["331", 0.0121], ["338", 0.0081], ["345", 0.0242], ["353", 0.0202], ["360", 0.0202], ["367", 0.0283], ["375", 0.0323], ["382", 0.0465], ["389", 0.0344], ["397", 0.0364], ["404", 0.0404], ["411", 0.0445], ["418", 0.0384], ["426", 0.0485], ["433", 0.2365], ["440", 0.4668], ["448", 0.5659], ["455", 0.7981999999999999], ["462", 0.7094999999999999], ["470", 0.8205], ["477", 1.4448999999999999], ["484", 3.1260999999999997], ["491", 4.1406], ["499", 4.4052999999999995], ["506", 6.614], ["513", 11.1968], ["521", 17.7723], ["528", 20.607499999999998], ["535", 10.6513], ["543", 4.7082999999999995], ["550", 1.9801999999999997], ["557", 1.1115], ["564", 0.5253], ["572", 0.38789999999999997], ["579", 0.37179999999999996], ["586", 0.29719999999999996], ["594", 0.27299999999999996], ["601", 0.2829], ["608", 0.20809999999999998], ["616", 0.204], ["623", 0.2385]]}", "memory": 29476000, "memoryDisplay": "29.5 MB", "memoryPercentile": 66.42790000000002, "memoryDistribution": "{"lang": "python3", "distribution": [["20500", 0.002], ["20800", 0.002], ["21400", 0.002], ["24400", 0.002], ["24500", 0.0141], ["24600", 0.0283], ["24700", 0.0909], ["24800", 0.1253], ["24900", 0.0364], ["25000", 0.004], ["25100", 0.002], ["25500", 0.004], ["25600", 0.0283], ["25700", 0.0101], ["25800", 0.002], ["25900", 0.0061], ["26000", 0.002], ["26100", 0.002], ["26200", 0.002], ["26400", 0.0081], ["26500", 0.0061], ["26600", 0.0081], ["26700", 0.004], ["26800", 0.0081], ["26900", 0.0061], ["27000", 0.0061], ["27100", 0.0081], ["27300", 0.004], ["27400", 0.004], ["27500", 0.0061], ["27600", 0.0121], ["27700", 0.0101], ["27800", 0.0061], ["27900", 0.0101], ["28000", 0.0182], ["28100", 0.0182], ["28200", 0.0182], ["28300", 0.0707], ["28400", 0.1212], ["28500", 0.1899], ["28600", 0.1172], ["28700", 0.0727], ["28800", 0.1293], ["28900", 0.5294], ["29000", 4.8296], ["29100", 7.5575], ["29200", 3.2857], ["29300", 4.2193], ["29400", 11.9223], ["29500", 21.1429], ["29600", 10.8897], ["29700", 5.6075], ["29800", 6.8563], ["29900", 14.2017]]}", "code": "class Solution:\n def maxArea(self, height: List[int]) -> int:\n if len(height) < 2 : return 0\n max_area = 0\n i = 0\n j = len(height) - 1\n while(i < j):\n h = min(height[i] , height[j])\n b = j - i\n max_area = max(max_area , b*h)\n if height[i] < height[j] : i += 1\n else: j -= 1\n return max_area\n", "timestamp": 1723282092, "statusCode": 10, "user": { "username": "rudrasaha305", "profile": { "realName": "Rudra", "userAvatar": "https://assets.leetcode.com/users/avatars/avatar_1705087178.png" } }, "lang": { "name": "python3", "verboseName": "Python3" }, "question": { "questionId": "11", "titleSlug": "container-with-most-water", "hasFrontendPreview": false }, "notes": "", "flagType": "WHITE", "topicTags": [], "runtimeError": null, "compileError": null, "lastTestcase": "", "codeOutput": "", "expectedOutput": "", "totalCorrect": 62, "totalTestcases": 62, "fullCodeOutput": null, "testDescriptions": null, "testBodies": null, "testInfo": null, "stdOutput": "" } } }

Rudrajiii avatar Aug 10 '24 17:08 Rudrajiii

also https://leetcode.com/problems/container-with-most-water/submissions/1350809914/ if u look at this leetcode official endpoint closely 1350809914 is a unique submission id and we can grab it via scraping the endpoint https://leetcode.com/problems/container-with-most-water/submissions/ and here it will be Screenshot 2024-08-10 231651 and under this whole huge json the code will be inside the "submissions" key pair look at this Screenshot 2024-08-10 231736 now after getting this id we are able to find the exact submission code url and from there we can scrap the exacpt code

Rudrajiii avatar Aug 10 '24 17:08 Rudrajiii

look i have found the response as well check out "code" key pair :

{ "data": { "submissionDetails": { "runtime": 519, "runtimeDisplay": "519 ms", "runtimePercentile": 64.62090000000013, "runtimeDistribution": "{"lang": "python3", "distribution": [["46", 0.004], ["53", 0.0202], ["61", 0.048499999999999995], ["68", 0.08099999999999999], ["75", 0.024200000000000006], ["83", 0.0061], ["90", 0.002], ["97", 0.002], ["105", 0.002], ["112", 0.004], ["119", 0.0121], ["126", 0.006], ["134", 0.004], ["141", 0.006], ["148", 0.022199999999999998], ["156", 0.04039999999999999], ["163", 0.028200000000000003], ["170", 0.012], ["178", 0.002], ["185", 0.002], ["192", 0.002], ["199", 0.002], ["207", 0.002], ["214", 0.002], ["221", 0.004], ["229", 0.002], ["236", 0.002], ["243", 0.002], ["251", 0.002], ["258", 0.002], ["265", 0.004], ["272", 0.004], ["280", 0.004], ["287", 0.002], ["294", 0.0081], ["302", 0.0081], ["309", 0.0182], ["316", 0.0101], ["324", 0.0101], ["331", 0.0121], ["338", 0.0081], ["345", 0.0242], ["353", 0.0202], ["360", 0.0202], ["367", 0.0283], ["375", 0.0323], ["382", 0.0465], ["389", 0.0344], ["397", 0.0364], ["404", 0.0404], ["411", 0.0445], ["418", 0.0384], ["426", 0.0485], ["433", 0.2365], ["440", 0.4668], ["448", 0.5659], ["455", 0.7981999999999999], ["462", 0.7094999999999999], ["470", 0.8205], ["477", 1.4448999999999999], ["484", 3.1260999999999997], ["491", 4.1406], ["499", 4.4052999999999995], ["506", 6.614], ["513", 11.1968], ["521", 17.7723], ["528", 20.607499999999998], ["535", 10.6513], ["543", 4.7082999999999995], ["550", 1.9801999999999997], ["557", 1.1115], ["564", 0.5253], ["572", 0.38789999999999997], ["579", 0.37179999999999996], ["586", 0.29719999999999996], ["594", 0.27299999999999996], ["601", 0.2829], ["608", 0.20809999999999998], ["616", 0.204], ["623", 0.2385]]}", "memory": 29476000, "memoryDisplay": "29.5 MB", "memoryPercentile": 66.42790000000002, "memoryDistribution": "{"lang": "python3", "distribution": [["20500", 0.002], ["20800", 0.002], ["21400", 0.002], ["24400", 0.002], ["24500", 0.0141], ["24600", 0.0283], ["24700", 0.0909], ["24800", 0.1253], ["24900", 0.0364], ["25000", 0.004], ["25100", 0.002], ["25500", 0.004], ["25600", 0.0283], ["25700", 0.0101], ["25800", 0.002], ["25900", 0.0061], ["26000", 0.002], ["26100", 0.002], ["26200", 0.002], ["26400", 0.0081], ["26500", 0.0061], ["26600", 0.0081], ["26700", 0.004], ["26800", 0.0081], ["26900", 0.0061], ["27000", 0.0061], ["27100", 0.0081], ["27300", 0.004], ["27400", 0.004], ["27500", 0.0061], ["27600", 0.0121], ["27700", 0.0101], ["27800", 0.0061], ["27900", 0.0101], ["28000", 0.0182], ["28100", 0.0182], ["28200", 0.0182], ["28300", 0.0707], ["28400", 0.1212], ["28500", 0.1899], ["28600", 0.1172], ["28700", 0.0727], ["28800", 0.1293], ["28900", 0.5294], ["29000", 4.8296], ["29100", 7.5575], ["29200", 3.2857], ["29300", 4.2193], ["29400", 11.9223], ["29500", 21.1429], ["29600", 10.8897], ["29700", 5.6075], ["29800", 6.8563], ["29900", 14.2017]]}", "code": "class Solution:\n def maxArea(self, height: List[int]) -> int:\n if len(height) < 2 : return 0\n max_area = 0\n i = 0\n j = len(height) - 1\n while(i < j):\n h = min(height[i] , height[j])\n b = j - i\n max_area = max(max_area , b*h)\n if height[i] < height[j] : i += 1\n else: j -= 1\n return max_area\n", "timestamp": 1723282092, "statusCode": 10, "user": { "username": "rudrasaha305", "profile": { "realName": "Rudra", "userAvatar": "https://assets.leetcode.com/users/avatars/avatar_1705087178.png" } }, "lang": { "name": "python3", "verboseName": "Python3" }, "question": { "questionId": "11", "titleSlug": "container-with-most-water", "hasFrontendPreview": false }, "notes": "", "flagType": "WHITE", "topicTags": [], "runtimeError": null, "compileError": null, "lastTestcase": "", "codeOutput": "", "expectedOutput": "", "totalCorrect": 62, "totalTestcases": 62, "fullCodeOutput": null, "testDescriptions": null, "testBodies": null, "testInfo": null, "stdOutput": "" } } }

what are the queries for this?

alfaarghya avatar Aug 15 '24 01:08 alfaarghya

in https://alfa-leetcode-api.onrender.com/username/submission endpoint u r having only the question details , no of submissions and other things , but u r not fetching the last submitted code we can do this for better interpretation of this submission endpoint , thank you :)

Yea! We can definitely do things better than before. So can you able to identify what query do we need to add in codebase?

alfaarghya avatar Aug 15 '24 01:08 alfaarghya

also https://leetcode.com/problems/container-with-most-water/submissions/1350809914/ if u look at this leetcode official endpoint closely 1350809914 is a unique submission id and we can grab it via scraping the endpoint https://leetcode.com/problems/container-with-most-water/submissions/ and here it will be Screenshot 2024-08-10 231651 and under this whole huge json the code will be inside the "submissions" key pair look at this Screenshot 2024-08-10 231736 now after getting this id we are able to find the exact submission code url and from there we can scrap the exacpt code

A little info, we are not scraping the leetcode website, we are just using leetcode.com/graphql api to fetch the data

alfaarghya avatar Aug 15 '24 01:08 alfaarghya

in https://alfa-leetcode-api.onrender.com/username/submission endpoint u r having only the question details , no of submissions and other things , but u r not fetching the last submitted code we can do this for better interpretation of this submission endpoint , thank you :)

Yea! We can definitely do things better than before. So can you able to identify what query do we need to add in codebase?

yep!! i am working on it soon will make a PR!!

Rudrajiii avatar Aug 15 '24 05:08 Rudrajiii

also https://leetcode.com/problems/container-with-most-water/submissions/1350809914/ if u look at this leetcode official endpoint closely 1350809914 is a unique submission id and we can grab it via scraping the endpoint https://leetcode.com/problems/container-with-most-water/submissions/ and here it will be Screenshot 2024-08-10 231651 and under this whole huge json the code will be inside the "submissions" key pair look at this Screenshot 2024-08-10 231736 now after getting this id we are able to find the exact submission code url and from there we can scrap the exacpt code

A little info, we are not scraping the leetcode website, we are just using leetcode.com/graphql api to fetch the data

Ok No Issue!!

Rudrajiii avatar Aug 15 '24 05:08 Rudrajiii

Hi, any updates on this? I want to use this kind of endpoint for a project @Rudrajiii @alfaarghya

Amitrochates avatar Sep 19 '24 08:09 Amitrochates

Hi, any updates on this? I want to use this kind of endpoint for a project @Rudrajiii @alfaarghya

Nope not yet 😞

alfaarghya avatar Sep 19 '24 08:09 alfaarghya

@alfaarghya @Amitrochates

Getting the submission id's but i think we can't do that due security issues i have tried in diff diff way neither of them works properly here is some pics->

image

Rudrajiii avatar Sep 19 '24 10:09 Rudrajiii

@alfaarghya @Amitrochates

Getting the submission id's but i think we can't do that due security issues i have tried in diff diff way neither of them works properly here is some pics->

image

Yeah it's the matter of LeetCode security 🥶

alfaarghya avatar Sep 19 '24 11:09 alfaarghya