Skip to content
Salman Shah edited this page Mar 20, 2018 · 2 revisions

API Endpoints

Android

1. Register User

Allows user to register to the app. Returns json with success = True or False based on the outcome of the result

URL
/register

Method: POST

URL Params None

Required: POST request only on this API Endpoint

Data Params username email password

Success Response: Code: 200 Content: {'success': True, 'message': 'Kindly contact administrator for Card to login'}

Failure Response: None

Error Response: Code: 401 UNAUTHORIZED Content: { error : "You are unauthorized to make this request." }

Sample Call:

  $.ajax({
    url: "/login",
    dataType: "json",
    data: JSON.stringify({ 'username':'salman', 'email': '[email protected]', 'password':'salman@123'}),
    type : "POST",
    success : function(r) {
      console.log(r);
    }
  });

2. Login User

Allows user to login to the app. Returns json with success = True or False based on the outcome of the result. User can login to the app only if he has a valid RFID Number.

URL
/login

Method: POST

URL Params email password

Required: POST request only on this API Endpoint

Data Params None

Success Response: Code: 200 Content: {'success': True}

Failure Response: Code: 200 Content: {'success': False, 'message': 'Get your Smart Cycle Card'} Reason: User hasn't been assigned a smart card yet!

OR

Code: 200 Content: {'success': False, 'message': 'Email doesn\'t exist'} Reason: User hasn't registered yet!

Error Response: Code: 401 UNAUTHORIZED
Content: { error : "You are unauthorized to make this request." }

Sample Call:

  $.ajax({
    url: "/login",
    dataType: "json",
    data: JSON.stringify({ 'email': '[email protected]', 'password':'salman@123'}),
    type : "POST",
    success : function(r) {
      console.log(r);
    }
  });

3. Recieve QR Code

User sends a QR Code after logging into the app. The QR Code scanning enables the user to start the ride

URL
/qr_code_receive

Method: POST

URL Params email cycle_id

Required: POST request only on this API Endpoint

Data Params None

Success Response: Code: 200 Content: {'success': True}

Failure Response: Code: 200 Content: {'success': False, 'message': 'Kill App Programmer'} Reason: User doesn't exist!

OR

Code: 200 Content: {'success': False, 'message': 'QR Code is wrong'} Reason: QR Code doesn't exist in database!

Error Response: Code: 401 UNAUTHORIZED
Content: { error : "You are unauthorized to make this request." }

Sample Call:

  $.ajax({
    url: "/login",
    dataType: "json",
    data: JSON.stringify({ 'email': '[email protected]', 'password':'salman@123'}),
    type : "POST",
    success : function(r) {
      console.log(r);
    }
  });
Clone this wiki locally