Skip to content

URL Endpoints

Vibhor Gupta edited this page Aug 21, 2019 · 2 revisions

URL endpoints

/api/login

Form data: user_name, password Returns a auth token in response header for a successful login

/api/user

POST

Headers: Content-type : Application/JSON, token: JSON: {"user_name":"<username>", "password":"<password>", "auth":<authleval>, "email":"<email>"}

Auth levels

  • 0:ADMIN
  • 1:STUDENT
  • 2:ACADEMIC
  • 3:NONACADEMIC
GET

Headers: token: Returns a JSON of all the users

DELETE

/api/user/<username> Deletes the user from system. Adviced not to use.

PUT

/api/user/<username> Headers: Content-type : Application/JSON, token: JSON: {"user_name":"<username>", "password":"<password>", "auth":<authleval>, "email":"<email>"} Update the given user

/api/regularuser

POST

Headers: Content-type : Application/JSON JSON: {"user_name":"<username>", "password":"<password>", "email":"<email>"}

/api/user/blocked

GET

Headers: token: Returns a JSON of all the blocked users

POST

/api/user/blocked/<username> Headers: token: Blocks the given user

/api/download

POST

Headers: Content-type : Application/JSON, token: JSON: {"link":"<download link>"}

GET

/api/download/<page> Headers: token: Returns JSON of all the completed downloads. Page contains 15 records ordered by added time. Page number is a int.

Status

  • 0:DEFAULT- not started
  • 1:STARTED - started ot finished yet
  • 2:DELETED - download completed but deleted from disk
  • 3:COMPLETED - download completed
  • 4:ERROR - download error
DELETE

/api/download/<id> Deletes the download only if it is not started.

/api/download/rate/

POST

Headers: Content-type : Application/JSON, token: JSON: {"rate":"<rating between 0-5>"} Adds the rating to download. If exists, update.

/api/user/downloads/

GET

Headers: token: Returns a JSON of all the downloads of current user. Page contains 15 records ordered by added time. Page number is a int.

/api/download/

GET

Headers: token: Returns file as multipart form data. Does not return a new auth token header

/api/user/requests

GET

Headers: token: Returns a JSON of all the users who has signed up and not been approved yet

/api/user/approve/

POST

Headers: Content-type : Application/JSON, token: Approve the user with given username


Storage Entity Endpoints:

There are two types of storage entities, folders and files. The endpoint structure is similar for both, distinguished only by the type query parameter. It takes two values:

  • fr for Folders
  • fl for Files

/api/user/:user_id/drive/:id/children
Returns a list of two objects, for file and folder children respectively. Each object contains a list of names of the corresponding entity.

GET /api/user/1/drive/1/children HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

/api/user/:user_id/drive/:id/children
Returns a list containing a single object with entity details (id, name, type)

GET /api/user/1/drive/1?type=fr HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

/api/user/:user_id/drive/:parent_id/add
Adds entity with <parent_id> as the parent. Returns a success status object

POST /api/user/1/drive/1/add?type=fr HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Content-Type: application/x-www-form-urlencoded

name=<entity_name>

/api/user/:user_id/drive/:id/move
Moves entity with id to a different folder having name=parent_name

POST /api/user/1/drive/5/move?type=fr HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Content-Type: application/x-www-form-urlencoded

parent_name=<name of new parent>

/api/user/:user_id/drive/:id/edit
Edit entity name by id. Returns a success status object.

PUT /api/user/1/drive/5/edit?type=fr HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Content-Type: application/x-www-form-urlencoded

new_name=<new_name>

/api/user/:user_id/drive/:id/remove
Remove entity by id.

DELETE /api/user/1/drive/2/remove?type=fl HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

ACL Endpoints:

There are 3 types of permissions, owner, read and write. Read and Write are granted by owners to other users for certain entities.

/api/user/:user_id/drive/:id/check
Check read/write access to an entity for a user

GET /api/user/2/drive/1/check?type=fr HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

/api/user/:user_id/drive/shared
Fetch all the shared entities of the user

GET /api/user/1/drive/shared HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

/api/user/drive/:id>/grant
Grant access to a user to an entity

POST /api/user/drive/1/grant?type=fl HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

user_name=<username>&access=<access_level>

Upload Endpoint:

/api/user/:user_id/drive/:parent_id/upload
A file object comes in the request object as multipart form data and is uploaded to the server, according to the config specs.


Notification Endpoints:

/api/user/:user_id/notifications Poll for notifications of a user

GET /api/user/1/notifications HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Cache-Control: no-cache

/api/user/:user_name/notification/add
Save notification for actions for a user

POST /api/user/rand/notification/add HTTP/1.1
Host: 0.0.0.0:5000
token: <auth_token>
Content-Type: application/x-www-form-urlencoded

notif=<sample_notification_string>