This page lists the major RESTful APIs provided by Leetcode-parse.
Leetcode-parse default BASE_PATH is http://<your ip>:8080.
We follow general rules to design Leetcode-parse's REST APIs. In the HTTP response that is sent to a client, the status code, which is a three-digit number, is accompanied by a reason phrase (also known as status text) that simply describes the meaning of the code. The status codes are classified by number range, with each class of codes having the same basic meaning.
- The range 100-199 is classed as Informational.
- 200-299 is Successful.
- 300-399 is Redirection.
- 400-499 is Client error.
- 500-599 is Server error.
All API response results are designed as follows.
{
"code": 200,
"message": null,
"data": {
}
}
- code : response status code
- message : null when response code is like 2XX, otherwise it is an error message.
- data : response data
The valid HTTP response status is designed as follows:
| Action | HTTP Status | Response Body |
|---|---|---|
| POST | 201, "Created" | created item |
| POST | 200, "OK" | requested item |
| GET | 200, "OK" | requested items |
| PUT | 200, "OK" | created item |
| DELETE | 204, "No Content" | no content |
The invalid response is designed as follows.
| Action | HTTP Status | Response Body |
|---|---|---|
| ANY | 400, "Bad Request" | error detail |
| ANY | 500, "Internal Server Error" | error detail |
For example,
{
"code": 400,
"message": "Id is required.",
"data": null
}
}
GET /api/v1/accounts/login
- username :
required stringusername or email - pwd :
required stringpassword
curl -X GET 'http://localhost:8080/api/v1/accounts/login?pwd=pwd&username=username'POST /api/v1/accounts/signup
- username :
required stringusername - email :
required stringemail adress - password1 :
required stringpassword - password2 :
required stringconfirm password
curl -X POST 'http://localhost:8080/api/v1/accounts/signup?username=user&email=test@gmail.com&password1=qwertyuiop1&password2=qwertyuiop1' The response status is (201, "Created") if successful.
GET /api/v1/accounts/password/reset
- email :
required stringemail adress
curl -X GET 'http://localhost:8080/api/v1/accounts/password/reset?email=test@gmail.com'GET /api/v1/problems
curl -X GET 'http://localhost:8080/api/v1/problems'GET /api/v1/problems/detail
- titleSlug :
required stringtitle slug, such as two-sum
curl -X GET \
'http://localhost:8080/api/v1/problems/detail?titleSlug=two-sum' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' GET /api/v1/tags
curl -X GET 'http://localhost:8080/api/v1/tags'POST /api/v1/discussions/topics
- page :
required stringpage number - pageSize :
required intpage size - id :
required inttopic id - query :
optional stringquery key - orderBy :
optional stringorder type ,default value is most_votes
{
"page":"1",
"pageSize":15,
"id":3,
"query":"",
"orderBy":"most_votes"
}
curl -X POST \
http://localhost:8080/api/v1/discussions \
-H 'Content-Type: application/json' \
-d '{
"page":"1",
"pageSize":15,
"id":3,
"query":"",
"orderBy":"most_votes"
}'GET /api/v1/topics
- topicId :
required inttopic id - cookies :
optiaonal stringused to determine whether it is your own post
curl -X GET 'http://localhost:8080/api/v1/topics?problemUri=https://leetcode.com/problems/two-sum/&topicId=241133'POST /api/v1/topics
- title :
required stringtopic title - content :
required inttopic content - id :
required intquestion id - tags :
required listtopic tags - cookies :
required stringcookies to authentication
{
"title":"Java for test",
"content":"It looks great.",
"id":742,
"tags":[
"array"
],
"cookies":"cookie value"
}
curl -X POST \
http://localhost:8080/api/v1/topics \
-H 'Content-Type: application/json' \
-d '{
"title":"Java for test",
"content":"It looks great.",
"id":742,
"tags":[
"array"
],
"cookies":"cookie value"
}'The response status is (201, "Created") if successful.
PUT /api/v1/topics
- title :
required stringtopic title - content :
required inttopic content - id :
required inttopic id - tags :
required listtopic tags - cookies :
required stringcookies to authentication
{
"title":"Java for test",
"content":"It looks pretty.",
"id":742,
"tags":[
"array"
],
"cookies":"cookie value"
}
curl -X PUT http://localhost:8080/api/v1/topics \
-H 'Content-Type: application/json' \
-d '{
"id" :241868,
"content":"It is test.",
"title" : "Java algrithm",
"tags" :[
"list"
],
"cookies":"cookie value"
}'DELETE /api/v1/topics
- id :
required inttopic id - cookies :
required stringcookies to authentication
{
"id":241306,
"cookies":"cookie value"
}
curl -X DELETE http://localhost:8080/api/v1/topics \
-H 'Content-Type: application/json' \
-d '{
"id":241306,
"cookies":"cookie value"
}'
curl -X POST \
'http://localhost:8080/api/v1/images?cookies=cookies_value' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F 'file=@/root/upload.jpg'
POST /api/v1/topics/comments
- page :
required intpage number - pageSize :
required intpage size - id :
required inttopic id - orderBy :
optional stringorder type ,default value is most_votes - cookies :
optiaonal stringused to determine whether it is your own post
{
"page":1,
"pageSize":15,
"id":148993,
"orderBy":"most_votes",
"cookies":"cookie value"
}
curl -X POST http://localhost:8080/api/v1/topics/comments \
-H 'Content-Type: application/json' \
-d '{
"page":1,
"pageSize":15,
"id":148993,
"orderBy":"most_votes",
"cookies":"cookie value"
}'
POST /api/v1/comments
- topicId :
required inttopic id - content :
required Stringcomment content - cookies :
required stringcookies to authentication
{
"topicId":148993,
"content":"That's cool.",
"cookies":"cookie value"
}
curl -X POST http://localhost:8080/api/v1/comments \
-H 'Content-Type: application/json' \
-d '{
"topicId":148993,
"content":"That is cool.",
"cookies":"cookie value"
}'
PUT /api/v1/comments
- topicId :
required inttopic id - content :
required Stringcomment content - cookies :
required stringcookies to authentication
{
"topicId":148993,
"content":"That's cool.",
"cookies":"cookie value"
}
curl -X PUT http://localhost:8080/api/v1/comments \
-H 'Content-Type: application/json' \
-d '{
"topicId":148993,
"content":"That looks cool.",
"cookies":"cookie value"
}'
DELETE /api/v1/comments
- commentId :
required intcomment id - cookies :
required stringcookies to authentication
{
"commentId":241306,
"cookies":"cookie value"
}
curl -X DELETE http://localhost:8080/api/v1/topics \
-H 'Content-Type: application/json' \
-d '{
"commentId":241306,
"cookies":"cookie value"
}'
The response status is (204, "No Content") if successful.
GET /api/v1/problems/top100
curl -X GET http://localhost:8080/api/v1/problems/top100
GET /api/v1/problems/interview
curl -X GET http://localhost:8080/api/v1/problems/interview