These APIs are for the backend for Leetcode Timer - an app that helps you keep a track of how much time you took to attempt each question.
Before we begin, there's something I'd like to share.
Since Amazon charges me to keep my services running, I've turned them off. So, if you try running these requests again, they're going to fail. So please don't invest your time in trying something that you know will fail. The same thing goes for the tokens. By the time you're reading this, the instance will cease to exist. So don't worry.Great! We can begin!
If you'd like to know how this project came into being, read on, my curious friend, I like you.
With the interview season coming up, I did what every software engineer does to prepare for interviews - Leetcode.
I enjoyed solving the questions there. I took my sweet time to try every approach, make sure my syntax was right, dry-run the algorithms with as many test cases I could, and enjoy.
Then one day, I took a mock interview. While solving the question, everything was moving fast. By the time I could properly read the question I was already 7 minutes into a 20-minute problem. Although I could finish the question on time, I could not dry run all the edge cases and directly had to compile my solution.
And that's when it hit me. We need to practice problems but in a timed environment.
Do you know why I absolutely love this project? You're reading on! You rock!
I set up a repo (currently private, but request access if you'd like!) on May 1, 2020. 11 days later, we saw the same feature request on Leetcode with over 850+ votes.
So every time I'm working on this project, I feel like I'm making at least 849 lives easier, yay!
As always, I love suggestions ( or appreciation ). Reach me out on twitter @nachiketsd or connect with me on LinkedIn @nachiketdhamankar
PS: I'll be publishing my design choices on my blog soon!
- DELETE User
- GET Attempted Questions
- GET Attempts
- GET Dashboard
- GET User
- POST Attempt Question
- POST User
Deletes the user account.
The user has to have a valid token (equivalent of signing in) to delete their account. Also, this token should be valid for the same email account that's attempting to be deleted.
Endpoint:
Method: DELETE
Type:
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users/[email protected]
Headers:
Key | Value |
---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJuc2QxQGdvb2dsZS5jb20iLCJpYXQiOjE1OTM0NDE3NTgsImV4cCI6MTU5MzQ0MTg3OH0.cr52MKhBBuVaz5d4KRCEJGsBarOFmxwNbV8lm-UooPjtlHA81IZPYwWHsFlbnUdFjT5ASd_XBavhMN_t8MjuQA |
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiMjZkOGRkZWUtYWNjMC00OTBjLTlmOWQtMjg4MzZhNmExZDNmXCIsXCJlbWFpbFwiOlwibmFjaGlAZmIuY29tXCJ9IiwiaWF0IjoxNjAxMTg4MDA5LCJleHAiOjE2MDExODgxMjl9.2ZmYm_uPcWP85is5UMH6juZTiIl8pNz7pTBawbGEeZbdMI8I2lQjr18teJTHrcctR1s5AffLmkDWkmsMpbgqqA |
{
"message": "Tch, tch. Don't delete someone else's account."
}
Status Code: 401
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiMjZkOGRkZWUtYWNjMC00OTBjLTlmOWQtMjg4MzZhNmExZDNmXCIsXCJlbWFpbFwiOlwibmFjaGlAZmIuY29tXCJ9IiwiaWF0IjoxNjAxMTg4MDA5LCJleHAiOjE2MDExODgxMjl9.2ZmYm_uPcWP85is5UMH6juZTiIl8pNz7pTBawbGEeZbdMI8I2lQjr18teJTHrcctR1s5AffLmkDWkmsMpbgqqA |
{
"message": "User has been successfully deleted."
}
Status Code: 200
Returns the list of questions attempted by the user.
The user has to have a valid token (equivalent of signing in) to return list of attempted questions. Also, this token should be valid for the same email account that's attempting to get the info.
Endpoint:
Method: GET
Type:
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users/[email protected]/questions
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNmViMDUzMGEtMWZkNC00ZDFmLTk5MjEtY2Q2ZjFkN2NjMmUxXCIsXCJlbWFpbFwiOlwibmFjaGlAZmIuY29tXCJ9IiwiaWF0IjoxNTk0MDA2MTYyLCJleHAiOjE1OTQwMDYyODJ9.ZrbSsrc26RE9PT62UQxnizZqGPVYtrfII6tLzLVmj3d-GXlXwwPDmHYiT8iK6PuNcsJZkINhs1EZBhUgCgCh4g |
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODA5OSwiZXhwIjoxNjAxMTg4MjE5fQ.J797aYMK96IuRWmpYcu6GLR2AX9ZNm4l07vdBBfEUpk7nzeJ2HZ4OYPRPA0LwmSbwEuU1fhq3vIttbVokEux5A |
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODMyOCwiZXhwIjoxNjAxMTg4NDQ4fQ.J22SN7chi9_K2AFQLplUVcq95SyUn9FZjuX6PTKZq1RFeYTSPKoYY0LdE6TMkw1igM3piLyLBFtIw0WEdjgbWg",
"result": [
{
"questionId": "1"
},
{
"questionId": "12"
},
{
"questionId": "125"
}
]
}
Status Code: 200
Returns the summary of the questions attempted by the user.
The user has to have a valid token (equivalent of signing in) to return the information about their summary. Also, this token should be valid for the same email account that's attempting to get the info.
Endpoint:
Method: GET
Type:
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users/[email protected]/questions/12
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNmViMDUzMGEtMWZkNC00ZDFmLTk5MjEtY2Q2ZjFkN2NjMmUxXCIsXCJlbWFpbFwiOlwibmFjaGlAZmIuY29tXCJ9IiwiaWF0IjoxNTk0MDA2MTYyLCJleHAiOjE1OTQwMDYyODJ9.ZrbSsrc26RE9PT62UQxnizZqGPVYtrfII6tLzLVmj3d-GXlXwwPDmHYiT8iK6PuNcsJZkINhs1EZBhUgCgCh4g |
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODA5OSwiZXhwIjoxNjAxMTg4MjE5fQ.J797aYMK96IuRWmpYcu6GLR2AX9ZNm4l07vdBBfEUpk7nzeJ2HZ4OYPRPA0LwmSbwEuU1fhq3vIttbVokEux5A |
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODM2NiwiZXhwIjoxNjAxMTg4NDg2fQ.vKFt0crqayJ3RHuwhxe5k6zcVNC2HIGvRgzl9pt7ODKQJw_ClT-j3gM-ACOMfqui2qBuCUmLbqYYw_Z3ocAcHQ",
"result": {
"attempts": [
{
"tackledAt": 1593706699,
"duration": 5,
"outcome": "FAILURE"
},
{
"tackledAt": 1593706593,
"duration": 14,
"outcome": "SUCCESS"
}
]
}
}
Status Code: 200
Soon to be deprecated: Placeholder request.
Endpoint:
Method: GET
Type:
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/dashboard
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJuc2QxQGdvb2dsZS5jb20iLCJpYXQiOjE1OTM0MDQ1OTgsImV4cCI6MTU5MzQwNDcxOH0.2sPDz6U40wm0P63MGWMu9etA3InQfR5odovKxNTXe48USw1ta3kTJJo1Nj2rVYhzUN-54HkDoakseWwwjSF0qw |
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJuc2QxQGdvb2dsZS5jb20iLCJpYXQiOjE1OTM0MDQ1OTgsImV4cCI6MTU5MzQwNDcxOH0.2sPDz6U40wm0P63MGWMu9etA3InQfR5odovKxNTXe48USw1ta3kTJJo1Nj2rVYhzUN-54HkDoakseWwwjSF0qw |
{
"message": "Welcome to leetcode timer! An app that will help you with your prep on Leetcode.",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJuc2QxQGdvb2dsZS5jb20iLCJpYXQiOjE2MDExODg3NjAsImV4cCI6MTYwMTE4ODg4MH0.H6ynhZi-p1ET6gGvLPUbj6evyWxq6h_3hqizysxSOBc6p3GrT3rV2Jt2CUXptiXnJwhv54G_uBd-ZOA1TCdUJQ"
}
Status Code: 200
Returns the information of the user.
Endpoint:
Method: GET
Type:
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users/[email protected]
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiODlkMGM3ZDEtNTEzNi00YjRlLWJkZDktMTQ1NmVlYTcwMzZmXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTU5MzcwNzEzOSwiZXhwIjoxNTkzNzA3MjU5fQ.jqW9oIqCtZxsbtfESCP_oysalfrSmIkgGWgPiNocbZ-hDM4YpwQ15juXof3gOIxmSNpEgArko-5m24lmFcd_UA |
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4NzgxNiwiZXhwIjoxNjAxMTg3OTM2fQ.NhSUw2eep29fPQuXaqXX4gSrr8xp12mcId0hkuYJcKHDJVOJ5yHJDigpllDYXFRBr696SCoq1cRJE1cmrSc3iw |
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4NzgxNiwiZXhwIjoxNjAxMTg3OTM2fQ.NhSUw2eep29fPQuXaqXX4gSrr8xp12mcId0hkuYJcKHDJVOJ5yHJDigpllDYXFRBr696SCoq1cRJE1cmrSc3iw",
"result": {
"password": "thisIsMyPassword",
"joinedAt": "1601186775",
"id": "5fa4f603-e82a-404a-8ad0-d73f3d48d83c",
"email": "[email protected]",
"name": "Nachiket Dhamankar"
}
}
Status Code: 200
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiODlkMGM3ZDEtNTEzNi00YjRlLWJkZDktMTQ1NmVlYTcwMzZmXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTU5MzcwNzEzOSwiZXhwIjoxNTkzNzA3MjU5fQ.jqW9oIqCtZxsbtfESCP_oysalfrSmIkgGWgPiNocbZ-hDM4YpwQ15juXof3gOIxmSNpEgArko-5m24lmFcd_UA |
{
"message": "User is not authorized to access this resource with an explicit deny"
}
Status Code: 403
Posts an attempt to a question by the user.
Whenever the user attempts a question, this request must be sent. The body must have fields for 'tackledAt' (in epoch), 'duration' (in minutes) and 'outcome' (Values can be 'SUCCESS' or 'FAILURE').
The body is validated by the server. Hence, if any field is missing, the POST request will be unsuccessful.
The user has to have a valid token (equivalent of signing in) to post their attempt. Also, this token should be valid for the same email account that's attempting to send the request.
Endpoint:
Method: POST
Type: RAW
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users/[email protected]/question/1
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNmViMDUzMGEtMWZkNC00ZDFmLTk5MjEtY2Q2ZjFkN2NjMmUxXCIsXCJlbWFpbFwiOlwibmFjaGlAZmIuY29tXCJ9IiwiaWF0IjoxNTk0MDA2MTYyLCJleHAiOjE1OTQwMDYyODJ9.ZrbSsrc26RE9PT62UQxnizZqGPVYtrfII6tLzLVmj3d-GXlXwwPDmHYiT8iK6PuNcsJZkINhs1EZBhUgCgCh4g |
Body:
{
"tackledAt": "1593706593",
"duration": "14",
"outcome": "SUCCESS"
}
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODA5OSwiZXhwIjoxNjAxMTg4MjE5fQ.J797aYMK96IuRWmpYcu6GLR2AX9ZNm4l07vdBBfEUpk7nzeJ2HZ4OYPRPA0LwmSbwEuU1fhq3vIttbVokEux5A |
Body:
{
"tackledAt": "1593706593",
"duration": "14",
"outcome": "SUCCESS"
}
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODA5OSwiZXhwIjoxNjAxMTg4MjE5fQ.J797aYMK96IuRWmpYcu6GLR2AX9ZNm4l07vdBBfEUpk7nzeJ2HZ4OYPRPA0LwmSbwEuU1fhq3vIttbVokEux5A",
"result": {
"message": "Attempt Successfully recorded: {\"tackledAt\":1593706593,\"duration\":14,\"outcome\":\"SUCCESS\"}"
}
}
Status Code: 200
II. Example Request: POST Attempt Question: Succesfully record an attempt to solve question with outcome of failure
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODA5OSwiZXhwIjoxNjAxMTg4MjE5fQ.J797aYMK96IuRWmpYcu6GLR2AX9ZNm4l07vdBBfEUpk7nzeJ2HZ4OYPRPA0LwmSbwEuU1fhq3vIttbVokEux5A |
Body:
{
"tackledAt": "1593706599",
"duration": "25",
"outcome": "FAILURE"
}
II. Example Response: POST Attempt Question: Succesfully record an attempt to solve question with outcome of failure
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODI1MiwiZXhwIjoxNjAxMTg4MzcyfQ.VeU0fAxOGnc9hapWD7q3gy7h-HwprWuYG2mcwbLSpDRYBtMEAVFpwmOc27oVeD1K9LyLNqzDmGF27ztmRgTQgg",
"result": {
"message": "Attempt Successfully recorded: {\"tackledAt\":1593706599,\"duration\":25,\"outcome\":\"FAILURE\"}"
}
}
Status Code: 200
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4ODgzNCwiZXhwIjoxNjAxMTg4OTU0fQ.DhYV9LEXJqGS9zd1XYzMKLG3UsrTN6fFj-HVYWtEWqezEDtu_1Dmgu4BIN97bVeHm3G9UurltIpwzzEu02jmAA |
Body:
{
"tackledAt": "1593706593",
"duration": "14"
}
{
"message": "Event object failed validation",
"details": [
{
"keyword": "required",
"dataPath": ".body",
"message": "should have required property outcome"
}
]
}
Status Code: 400
This endpoint is for sign up as well as log in. This choice was made for 2 reasons -
- We would be returning a token back to the client in both situations.
- The body for logging in is a subset of the body for signing up.
Hence, the backend checks if the user already has an account. If the user does have an account, the backend signs the user in and returns a valid token. If the user does not have an account, the backend creates an account and returns a token to the client.
The backend intelligently returns error codes if the body does not have all the required information.
Endpoint:
Method: POST
Type: RAW
URL: https://7tfop0xwsg.execute-api.us-east-1.amazonaws.com/v1/users
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer 123 |
Body:
{
"email": "[email protected]",
"password": "thisIsMyPassword",
"name": "Nachiket Dhamankar",
"joinedAt": "1601186775"
}
More example Requests/Responses:
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer 123 |
Body:
{
"email": "[email protected]",
"password": "thisIsMyPassword"
}
{
"message": "User logged in successfully.",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4NzczNiwiZXhwIjoxNjAxMTg3ODU2fQ.12qNSCuerKtcAutnJVlsHHIz6F8w0U7V09__FanRoRmqV6MtyuRn0IRVoBlC_HhccsKGyan2OJAIQm4vrMCV6A"
}
Status Code: 201
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer 123 |
Body:
{
"email": "[email protected]"
}
{
"message": "Event object failed validation",
"details": [
{
"keyword": "required",
"dataPath": ".body",
"message": "should have required property password"
}
]
}
Status Code: 400
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer 123 |
Body:
{
"email": "[email protected]",
"password": "thisIsMyPasswordWrong"
}
{
"message": "Incorrect password"
}
Status Code: 401
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer 123 |
Body:
{
"email": "[email protected]",
"password": "thisIsMyPassword",
"name": "Nachiket Dhamankar",
"joinedAt": "1601186775"
}
{
"message": "User created successfully.",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOlwiNWZhNGY2MDMtZTgyYS00MDRhLThhZDAtZDczZjNkNDhkODNjXCIsXCJlbWFpbFwiOlwibmFjaGlAZ29vZ2xlLmNvbVwifSIsImlhdCI6MTYwMTE4NzYwMiwiZXhwIjoxNjAxMTg3NzIyfQ.ogep2rzJuHbS2Aj7JEXinI91yNERVLuZUQ-yFHOFr2H_P7L7yT2Zdo22BYuFl0TLPiBrXj_RCFXbGnV5sDk07g"
}
Status Code: 201
Made with ♥ by thedevsaddam | Generated at: 2020-12-08 19:23:38 by docgen