This API can be used to perform all types of operations related to an e-commerce website
- Authentication
- Admin
- User
https://e-comm-proto.herokuapp.com/
Method : POST
URL : https://e-comm-proto.herokuapp.com/auth/login
Auth Required : false
Key | Description | Optional | Type |
---|---|---|---|
email |
User email | No | String |
password |
User password | No | String |
{
// User data
"user" : [Object]
}
{
// Authorization Token
"auth-token" : [String]
}
- Unregistered user tries to login.
{
"error" : "User doesnt exist"
}
- Incorrect password.
{
"error" : "Invalid Password"
}
Method : POST
URL : https://e-comm-proto.herokuapp.com/auth/signup
Auth Required : false
Key | Description | Optional | Type |
---|---|---|---|
email |
User email | No | String |
password |
User password | No | String |
name |
User's name | No | String |
{
// On successful signup
"msg" : [String]
// On signup failure
"error": [String]
}
Note : A welcome mail will be sent to the user on successful signup.
- Existing user signs up.
{
"error" : "Email already exists"
}
- Other errors
{
// Error generated by NodeJS/MongoDB
"error" : [Object]
}
Method : GET
URL : https://e-comm-proto.herokuapp.com/admin/auth-history
Auth Required : true
User Role : Admin
Key | Description | Optional | Type |
---|---|---|---|
x-access-token |
Auth Token | No | String |
{
// Authentication history
"data" : {
"date" : [Date],
"history" : [Array]
}
}
- When user has not logged in or is not an admin.
{
"message" : "Unauthorized"
}
- Other errors
{
// Error generated by NodeJS/MongoDB
"message" : [Object]
}
Method : GET
URL : https://e-comm-proto.herokuapp.com/admin/transaction-history
Auth Required : true
User Role : Admin
Key | Description | Optional | Type |
---|---|---|---|
x-access-token |
Auth Token | No | String |
{
// Buy & Sell transaction history
"data" : [Object]
}
- When user has not logged in or is not an admin.
{
"message" : "Unauthorized"
}
- Other errors
{
// Error generated by NodeJS/MongoDB
"message" : [Object]
}
Method : POST
URL : https://e-comm-proto.herokuapp.com/user/buy
Auth Required : true
Key | Description | Optional | Type |
---|---|---|---|
x-access-token |
Auth Token | No | String |
Key | Description | Optional | Type |
---|---|---|---|
productId |
Product ID | No | ObjectID |
coupon |
Coupon Code | Yes | String |
sender.id |
Buyer's ID | No | ObjectID |
sender.name |
Buyer's name | No | String |
sender.email |
Buyer's email | No | String |
sender.location |
Buyer's Location | Yes | Co-ordinates |
recipient.id |
Seller's ID | No | ObjectID |
recipient.name |
Seller's name | No | String |
recipient.email |
Seller's email | No | String |
recipient.location |
Seller's Location | Yes | Co-ordinates |
{
// Transaction Date
"date" : [Date],
// Coupon code
"coupon" : [String],
// Transaction status
"success" : [Boolean],
// Product ID
"productId" : [ObjectID],
// Buyer's Info
"sender": {
"id": [ObjectID],
"name": [String],
"email": [String]
},
// Seller's Info
"recipient": {
"id": [ObjectID],
"name": [String],
"email": [String]
},
// Transaction ID
"id": [ObjectID],
// Trnasaction Type
"transactionType": [String],
}
- If auth token is not provided in header.
{
"message" : "No token provided!"
}
- If user has not logged in.
{
"message" : "Unauthorized"
}
- Other errors
{
// Error generated by NodeJS/MongoDB
"message" : [Object]
}
Code : 400 Bad Request
Content : Mongoose error is shown, with suggestions to fix the query.