Hosted at: http://52.187.32.163:8000/
Admin Login http://52.187.32.163:8000/admin/
Registration
http://52.187.32.163:8000/api/register/
Send a post request in json format
{
"username": " ",
"email": " ",
"password": " "
}
username: 150 characters or fewer. Letters, digits and @/./+/-/_ only.
This will return data in format :
{
"user": {
"id": 6,
"username": "aman",
"email": "[email protected]"
},
"token": "c48872ae36972c5bbd59684c72788105b9c83f50b4f46b1cff6fa18e6e737091"
}
Error:
Existing Username
{
"username": [
"A user with that username already exists."
]
}
Incorrect Username Format
{
"username": [
"Enter a valid username. This value may contain only letters, numbers, and @/./+/-/_ characters."
]
}
Login
http://52.187.32.163:8000/api/login/
Send a post request in json format
{
"username":"",
"password":""
}
This will return data in format:
{
"expiry": "2020-12-05T04:32:49.391286Z",
"token": "faa91ac21cf639301c9b203925eec41cac0ccf48ba03399d96b86fd471d43e63"
}
Incorrect Credentials:
{
"non_field_errors": [
"Unable to log in with provided credentials."
]
}
Logout
http://52.187.32.163:8000/api/logout/
This will logout only the given token of user
Send a post request with header
Authorization: Token faa91ac21cf639301c9b203925eec41cac0ccf48ba03399d96b86fd471d43e63
If provided token is correct then nothing will be returned.
Otherwise if incorrect token is given (which include tokens which are logged out earlier):-
{"detail":"Invalid token."}
If no token is provided:-
{"detail":"Authentication credentials were not provided."}
LogoutAll
http://52.187.32.163:8000/api/logoutall/
This will logout all the tokens related to the user associated with given token
All other detail are same as Logout
Change Passowrd
http://52.187.32.163:8000/api/paschange/
send a post request with header containing authorization token and data (old_password, new_password)
Example (this example is for bash, find corresponding code for angular)
curl -X POST -H 'Authorization: Token 37746eaf3d28908b1997d32788f67e70677c57bf07eb063cd9a8c64878261b98' -d "old_password=test@12345&new_password=new@12345" http://52.187.32.163:8000/api/paschange/
Return data :
{
'status': 'success',
'code':status.HTTP_200_OK,
'message':'Password Updated Succesfully',
'data':[]
}
Errors
If old password is worng
{"old_password":["Wrong password"]}
Save a New File
http://52.187.32.163:8000/api/files/
Send a post request, it should also contain Authentication Token as a Header:-
{
name=""
lang=""
body=""
}
Example (in bash):-
curl -X POST -H 'Authorization: Token 3cdc5be20ba73d4dfdf9849b89f606e1b3fe5656a3726929b2adc7aee495f9eb' -d "name=qw3.cpp&lang=cpp&body=gsgbsgbsg" http://52.187.32.163:8000/api/upload/
Output (if file name is new):-
{"status":"success","message":"qw7.cpp uploaded succesfully"}
File Name already exists
{"status":"success","message":"qw4.cpp updated succesfully"}
Errors:-
Max Number of File Reached
{"error":"Max File Limit exceeded"}
Get Uploaded Files
http://52.187.32.163:8000/api/fileget/
send a post Request at above link
Input Format:-
all:true/false
name:<filename>
Example:-
curl -X GET -H 'Authorization: Token 3cdc5be20ba73d4dfdf9849b89f606e1b3fe5656a3726929b2adc7aee495f9eb' -d "all=false&name=qw.cpp" http://52.187.32.163:8000/api/files/
If all is true it will return list of all files. Otherwise it will return content of give file.
if all is false and give filename does not exist then error:-
{"error":"file does not exist"}
Delete a File
http://52.187.32.163:8000/api/filedelete/
Send a post request at above address
Input Format :-
all:true/false
name:<filename>
Example:-
curl -X DELETE -H 'Authorization: Token 3cdc5be20ba73d4dfdf9849b89f606e1b3fe5656a3726929b2adc7aee495f9eb' -d "all=true&name=qw.cpp" http://52.187.32.163:8000/api/files/
If all is true then all the files of given user will be deleted
If file name does not exist then it will not show any error.
Project Post
An empty project can't be posted
http://52.187.32.163:8000/api/projects/
send post request
Format
{
name=""
projectname=""
relpath=""
lang=""
body=""
}
For updating a file, use same link and same format
Return:-
//one of these will be returned if data sent is in correct format
{'status':'success', 'message':'file added to the new project'}
{'status':'success','message':'file is added in project'}
{'status':'success','message':'file is updated'}
{'status':'fail',"message":"Max Number of Projects Reached"}
{'status':'success','message':'file is added in project'}
{'status':'fail','message':'max number of files in project reached'}
Get uploaded projects
http://52.187.32.163:8000/api/projectget/
Send a post request
format
{
all="" //boolean vaue
projectname=""
}
If all is true:-
{"status":"success","projectlist":["abc","abc1","abc3","abc4","abc2"]}
// if project not exist:-
{'status': 'fail', 'data': 'project does not exist'}
If all is false:-
{"status":"success","data":[{"name":"qw17","body":"newbody","lang":"cpp","path":""},{"name":"qw18","body":"newbody","lang":"cpp","path":""},{"name":"qw19","body":"newbody","lang":"cpp","path":"jhagj/jhq"}]}
//if project not exits:-
{'status':'fail', 'data':'project does not exist'}
Delete a project or file
http://52.187.32.163:8000/api/projectdelete/
Send a post request
format
{
all="" //boolean
projectname=""
filename=""
}
If all is true, filename does not have any significance and all the files og given project will be deleted
otherwise the given file of given project will be deleted.
No error will be shown in this case if project or file name do not exist