Skip to content
Russel Mahmud edited this page Dec 19, 2015 · 17 revisions

/api/auth/

  • Login (POST)
    • Permission Public
    • Headers
      • Authorization - "Basic base64-user-pass(user:pass)"
  • LogOut (DELETE)
  • /api/v1/customers/

    • Collection (GET)
      • Permission Authenticated User
      • Example Request : curl -H "Authorization: Basic cnVzc2VsOmFkbWluYWRtaW4=" localhost:8000/api/v1/customers/
      • Example Response :
      {
         "count": 1,
         "next": null,
         "previous": null,
         "results": 
          [
             {
                  "id": 2,
                  "username": "russel",
                  "first_name": "Russel",
                  "last_name": "Mahmud",
                  "email": "[email protected]"
             }
         ]
      }
      
      • Permission Staff
      • Example Response :
      {
         "count": 2,
         "next": null,
         "previous": null,
         "results": 
          [
              {
                  "id": 1,
                  "username": "admin",
                  "first_name": "Admin",
                  "last_name": "User",
                  "email": "[email protected]"
             },{
                  "id": 2,
                  "username": "russel",
                  "first_name": "Russel",
                  "last_name": "Mahmud",
                  "email": "[email protected]"
             }
         ]
      }
      
  • Create (POST)

    • Permission Public
    • Fields :
      • username
      • email
      • first_name (optional)
      • last_name (optional)
      • password
    • Example Request : curl -X POST -H "Content-Type: application/json" -d '{"username":"test1","password":"test1test1","email":"[email protected]"}' localhost:8000/api/v1/customers/
    • Example Response :
    status_code : 201
    {
        "id": 9,
        "username": "russel",
        "first_name": "Russel",
        "last_name": "Mahmud",
        "email": "[email protected]"
    }
    
  • /api/v1/customers/:id/

    • Read (GET)

      • Permission Authenticated User
      • Example Request : curl -H "Authorization: Basic dGVzdDE6dGVzdDF0ZXN0MQ==" localhost:8000/api/v1/customers/11/
      • Example Response :
      {
          "id": 9,
          "username": "russel",
          "first_name": "Russel",
          "last_name": "Mahmud",
          "email": "[email protected]"
      }
      
    • Partial Update (PATCH)

      • Permission Authenticated User
  • /api/v1/products/

    • Collection (GET)
      • Permission Public
      • Example Request : curl localhost:8000/api/v1/products/
      • Example Response :
       {
         "count": 2,
         "next": null,
         "previous": null,
         "results": 
          [
              {
                  "id": 1,
                  "name": "iPad",
                  "quantity": 5,
                  "unit_price": "350.00"
             },{
                  "id": 1,
                  "name": "iPad",
                  "quantity": 5,
                  "unit_price": "350.00"
             }
         ]
       }
      
  • /api/v1/products/:id/

    • Read (GET)
      • Permission Public
      • Example Request : curl localhost:8000/api/v1/products/2/
      • Example Response :
       {
           "id": 1,
           "name": "iPad",
           "quantity": 5,
           "unit_price": "350.00"
       }
      

/api/v1/cart/

It will work only browser based session authentication.

  • Read (GET)

    • Permission Authenticated User
    • Example Response :
     {
        "checked_out": false,
        "total_price": "1800.00",
        "items": [
            {
                "product": 4,
                "quantity": 1,
                "unit_price": "300.00",
                "total_price": "300.00"
             },
            {
                "product": 2,
                "quantity": 2,
                "unit_price": "750.00",
                "total_price": "1500.00"
             }
         ]
     }
    
  • Add (POST)

    • Permission Authenticated User
    • Fields :
      • product
      • quantity (optional)
  • Update (PUT)

    • Permission Authenticated User
    • Fields :
      • product
      • quantity (optional)
  • Remove (DELETE)

    • Permission Authenticated User
    • Body Fields:
      • product
Clone this wiki locally