Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Latest commit

 

History

History
475 lines (423 loc) · 9.17 KB

API_Endpoints.md

File metadata and controls

475 lines (423 loc) · 9.17 KB

API Endpoints

These are all the endpoints that will be included in this backend project.

The endpoints are divided into 5 categories:

  1. Auth Endpoints ('/')
  2. User Endpoints ('/user')
  3. Project Endpoints ('/project')
  4. Form Endpoints ('/form')
  5. Form Submission Endpoints ('/main')

A successful response from the server will look like this:

{
  "status": "Ok",
  "message": "Message for the developer",
  "data": {
    "All the data from server will be here"
  }
}

An error response from the server will look like this:

{
  "status": "error",
  "error": "Error Message for the developer",
}

The following properties of every endpoint will be descibed in this file:

  • Method: GET | POST | PATCH | DELETE
  • Authorized: (Authentication is required or not for this route) True | False
  • Verified: (Account with Email verified is required or not for this route) True | False
  • Request Parameters: (Requet-Body to be sent along with the request, for POST | PATCH | DELETE methods)
  • Query Parameters: (Query Parameters available in GET requests to manipulate the response from the server)
  • Success Status Code: (Status Code of a successful response) 2xx
  • Response Data: (The format of data which is expected from the server with a successful response)

Auth Endpoints

Base URI: /

/login

  • Method: POST
  • Authorized: False
  • Verified: False
  • Request Parameters:
{
  "email": "[email protected]",
  "password": "mY-pAsSwOrD",
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 200
  • Response Data:
{
  "name": "User Name",
  "email": "[email protected]",
  "verfied": true,
  "secret": "JWT Token"
}

/signup

  • Method: POST
  • Authorized: False
  • Verified: False
  • Request Parameters:
{
  "name": "User Name"
  "email": "[email protected]",
  "password": "mY-pAsSwOrD",
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 201
  • Response Data:
{
  "name": "User Name",
  "email": "[email protected]",
  "verfied": false,
  "secret": "JWT Token"
}

/auth/google

  • Method: GET
  • Authorized: False
  • Verified: False
  • Success Status Code: 200
  • Response Data:
{
  "url": "Google OAuth URL"
}

/auth/google

  • Method: POST
  • Authorized: False
  • Verified: False
  • Request Parameters:
{
  "token": "Google Auth Token recieved from Google"
}
  • Success Status Code: 200/201
  • Response Data:
{
  "name": "User Name",
  "email": "[email protected]",
  "verfied": true,
  "secret": "JWT Token"
}

User Endpoints

Base URI: /user

/raiseverification

  • Method: GET
  • Authorized: True
  • Verified: False
  • Success Status Code: 200
  • Response Data: Null

/verify/<secret>

  • Method: GET
  • Authorized: False
  • Verified: False
  • Success Status Code: 200
  • Response Data: Null

/update

  • Method: PATCH
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "name": "User Name",
  "email": "[email protected]",
  "password": "older One",
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 200
  • Response Data:
{
  "name": "User Name",
  "email": "[email protected]"
}

/updatepassword

  • Method: PATCH
  • Authorized: True
  • Verified: False
  • Request Parameters:
{
  "oldPassword": "older One",
  "newPassword": "newer One",
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 200
  • Response Data: Null

/dashboard

  • Method: GET
  • Authorized: True
  • Verified: True
  • Success Status Code: 200
  • Response Data:
{
  "name": "User's name",
  "email": "[email protected]",
  "verified": true,
  "project_count": 2,
  "projects":[
    {
      "id": "Project Id"
      "name": "Project Name",
      "form_count": 5,
      "allowed_origins": ["http://localhost", "https://savemyform.in.net"],
      "date_created": "date-of-creation"
    }
  ]
}

/self

  • Method: GET
  • Authorized: True
  • Verified: False
  • Success Status Code: 200
  • Response Data:
{
  "name": "User's name",
  "email": "[email protected]",
  "verified": true
}

Project Endpoints

Base URI: /project

/new

  • Method: POST
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "name": "Project Name",
  "hasRecaptcha": true,
  "recaptchaKey": "User's project Recaptcha Key",
  "recaptchaSecret": "User's project Recaptcha Secret",
  "allowedOrigins": ["http://localhost", "https://savemyform.in.net"],
  "collaborators": ["[email protected]", "[email protected]"],
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 201
  • Response Data:
{
    "id": "project's id",
    "name": "project's name"
}

/dashboard/<id>

  • Method: GET
  • Authorized: True
  • Verified: True
  • Success Status Code: 200
  • Response Data:
{
  "id": "Project ID",
  "name": "Project's name",
  "is_owner": true,
  "owner":{
    "name": "Owner Name",
    "email": "[email protected]"
  },
  "collaborators": [
    {
      "name": "Collab 1",
      "email": "[email protected]"
    }
  ],
  "hasRecaptcha": true,
  "recaptchaKey": "User's project Recaptcha Key",
  "recaptchaSecret": "User's project Recaptcha Secret",
  "allowedOrigins": ["http://localhost", "https://savemyform.in.net"],
  "form_count": 2,
  "forms":[
    {
      "name": "Form Name",
      "submission_count": 5,
      "last_updated": "date-of-last-submission",
      "date_created": "date-of-creation"
    }
  ]
}

/update/<id>

  • Method: PATCH
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "name": "Project Name",
  "hasRecaptcha": true,
  "recaptchaKey": "User's project Recaptcha Key",
  "recaptchaSecret": "User's project Recaptcha Secret",
  "allowedOrigins": ["http://localhost", "https://savemyform.in.net"],
  "collaborators": ["[email protected]", "[email protected]"],
  "recaptcha_token": "Google Recaptcha Token recieved from Google",
  "password": "user's password"
}
  • Success Status Code: 200
  • Response Data:
{
  "id": "Project ID"
  "name": "Project's name",
  "is_owner": true,
  "owner":{
    "name": "Owner Name",
    "email": "[email protected]"
  },
  "collaborators": [
    {
      "name": "Collab 1",
      "email": "[email protected]"
    }
  ],
  "hasRecaptcha": true,
  "recaptchaKey": "User's project Recaptcha Key",
  "recaptchaSecret": "User's project Recaptcha Secret",
  "allowedOrigins": ["http://localhost", "https://savemyform.in.net"],
}

/delete/<id>

  • Method: DELETE
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "recaptcha_token": "Google Recaptcha Token recieved from Google",
  "password": "user's password"
}
  • Success Status Code: 200
  • Response Data: Null

Form Endpoints

Base URI: /form

/new/<projectId>

  • Method: POST
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "name": "Form Name",
  "hasRecaptcha": true,
  "hasFileField": false,
  "schema": {"schema": "object"}
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 201
  • Response Data:
{
    "id": "form's id",
    "name": "form's name"
}

/dashboard/<id>

  • Method: GET
  • Authorized: True
  • Verified: True
  • Query Parameters:
{
  "sort": "ascending/descending",
  "page": 5,
  "perpage": 10
}
  • Success Status Code: 200
  • Response Data:
{
  "id": "Form's ID"
  "name": "Form's name",
  "is_owner": true,
  "owner":{
    "name": "Owner Name",
    "email": "[email protected]"
  },
  "hasRecaptcha": true,
  "submissions":{
    "total": 999,
    "page": 2,
    "per_page": 10,
    "has_next_page": true,
    "has_prev_page": true,
    "total_pages": 100,
    "data":[
      {
        "id": "Submission ID",
        "data": {"submitted": "data"},
        "file": "link to file",
        "date_created": "date-of-creation"
      }
    ]
  }
}

/update/<id>

  • Method: PATCH
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "name": "Form Name",
  "hasRecaptcha": true,
  "hasFileField": false,
  "schema": {"schema": "object"}
  "password": "user's password",
  "recaptcha_token": "Google Recaptcha Token recieved from Google"
}
  • Success Status Code: 200
  • Response Data:
{
  "id": "Form's Id"
  "name": "Form's name",
  "is_owner": true,
  "owner":{
    "name": "Owner Name",
    "email": "[email protected]"
  },
  "hasRecaptcha": true
}

/delete/<id>

  • Method: DELETE
  • Authorized: True
  • Verified: True
  • Request Parameters:
{
  "recaptcha_token": "Google Recaptcha Token recieved from Google",
  "password": "user's password"
}
  • Success Status Code: 200
  • Response Data: Null