- Base URL: https://traidr.onrender.com/api/v1
- Author: Ben Essilfie
Request
URL - /users
Method - POST
Request Body
{
"user": {
"email": "string",
"password": "string"
}
}Response
Status: 201 - Created
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"email": "string"
},
"relationships": {
"products": {
"data": []
}
}
}
}Request
URL - /users/:id
Method - GET
Response
Status: 200 - OK
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"email": "string"
},
"relationships": {
"products": {
"data": []
}
}
},
"included": []
}Request
Url - /users/:id
Method - PUT
Headers - {Authorization: 'Bearer <token>'}
Request Body
{
"user": {
"email": "string",
"password": "string"
}
}Response
Status: 200 - OK
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"email": "string"
},
"relationships": {
"products": {
"data": []
}
}
}
}Request
Url - /users/:id
Method - DELETE
Headers - {Authorization: 'Bearer <token>'}
Response
Status: 204 - No Content
Request
Url - /auth/sessions
Method - POST
Request Body
{
"user": {
"email": "string",
"password": "string"
}
}Response
Status: 201 - Created
Response Body
{
"token": "tokenized_string",
"email": "string"
}Request
Url - /auth/sessions/:id
Method - DELETE
Headers - {Authorization: 'Bearer <token>'}
Response
Status: 200 - OK
body
{
"message": "Logout successful"
}Request
URL - /products
Method - GET
Response
Status: 200 - OK
Response Body
{
"data": [
{
"id": "integer",
"type": "string",
"attributes": {
"title": "string",
"price": "decimal",
"quantity": integer,
"published": boolean
},
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
}
}
},
{
"id": "integer",
"type": "string",
"attributes": {
"title": "string",
"price": "decimal",
"quantity": integer,
"published": boolean
},
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
}
}
}
],
"links": {
"first": "/v1/products?page=1",
"last": "/v1/products?page=1",
"prev": "/v1/products",
"next": "/v1/products"
}
}Request
URL - /products/:id
Method - GET
Response
Status: 200 - OK
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"title": "string",
"price": "decimal",
"quantity": integer,
"published": boolean
},
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
}
}
},
"included": [
{
"id": "integer",
"type": "string",
"attributes": {
"email": "string"
},
"relationships": {
"products": {
"data": [
{
"id": "integer",
"type": "string"
},
{
"id": "integer",
"type": "string"
},
{
"id": "integer",
"type": "string"
}
]
}
}
}
]
}Request
Url - /products
Method - POST
Headers - {Authorization: 'Bearer <token>'}
Request Body
{
"product": {
"title": "string",
"price": decimal,
"quantity": integer,
"published": boolean
}
}Response
Status: 201 - Created
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"title": "string",
"price": "decimal",
"quantity": integer,
"published": boolean
},
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
}
}
}
}Request
Url - /products/:id
Method - PUT
Headers - {Authorization: 'Bearer <token>'}
Request Body
{
"product": {
"title": "string",
"price": decimal,
"quantity": integer,
"published": boolean
}
}Response
Status: 200 - OK
Response Body
{
"data": {
"id": "integer",
"type": "string",
"attributes": {
"title": "string",
"price": "decimal",
"quantity": integer,
"published": boolean
},
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
}
}
}
}Request
Url - /products/:id
Method - DELETE
Headers - {Authorization: 'Bearer <token>'}
Response
Status: 204 - No Content
Request
URL - /orders
Method - GET
Headers - {Authorization: 'Bearer <token>'}
Response
Status: 200 - OK
Response Body
{
"data": [
{
"id": "integer",
"type": "string",
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
},
"products": {
"data": []
}
}
},
{
"id": "integer",
"type": "string",
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
},
"products": {
"data": [
{
"id": "integer",
"type": "string"
},
{
"id": "integer",
"type": "string"
}
]
}
}
}
],
"links": {
"first": "/v1/orders?page=1",
"last": "/v1/orders?page=1",
"prev": "/v1/orders",
"next": "/v1/orders"
}
}Request
URL - /orders/:id
Method - GET
Headers - {Authorization: 'Bearer <token>'}
Response
Status: 200 - OK
Response Body
{
"data": {
"id": "integer",
"type": "string",
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
},
"products": {
"data": []
}
}
},
"included": []
}Request
Url - /orders
Method - POST
Headers - {Authorization: 'Bearer <token>'}
Request Body
{
"order": {
"product_ids_and_quantities": [
{
"product_id": integer,
"quantity": integer
},
{
"product_id": integer,
"quantity": integer
}
]
}
}
Response
Status: 201 - Created
Response Body
{
"data": {
"id": "integer",
"type": "string",
"relationships": {
"user": {
"data": {
"id": "integer",
"type": "string"
}
},
"products": {
"data": [
{
"id": "integer",
"type": "string"
},
{
"id": "integer",
"type": "string"
}
]
}
}
}
}