API for the bookstore with user/admin functionality.
Each response has a status, error and data fields. If the code is 200, then everything is fine and the request was completed successfully, otherwise an error code will be returned. The error field contains a description of the error. Request and response both are sent in JSON format.
Prefix for all requests - /api
GET /books - get the list of books avaliable at the store
{
"status": 200,
"error": "",
"data": {
"books": [
{
"id": "27dbfc56ea8f9a107376faf2880333c9",
"title": "cool book",
"series": "cool series",
"price": 500,
"picture": "http://somedomain/pictures/books/27dbfc56ea8f9a107376faf2880333c9_.png",
"publisher": "cool pub",
"language": "eng",
"description": "cool desc",
"authors_id": [
"e1ddbfba9a5b6b3602eb284a33fa0d83"
]
}
]
}
}
GET /authors - get the list of authors of the books avaliable at the store
{
"status": 200,
"error": "",
"data": {
"authors": [
{
"id": "2c79b17fb3d2f2039c918b4ef7d85776",
"name": "aaaa",
"surname": "bbb",
"bio": "bio"
},
{
"id": "e1ddbfba9a5b6b3602eb284a33fa0d83",
"name": "a",
"surname": "b",
"bio": "biobio"
}
]
}
}
POST /register
{
"name": "name",
"surname": "suraname",
"email": "[email protected]",
"phone_number": "+1234",
"password": "password"
}
{
"status": 200,
"error": "",
"data": {
"token": "abcde"
}
}
POST /login
{
"email": "[email protected]",
"password": "1234"
}
{
"status": 200,
"error": "",
"data": {
"token": "abcde"
}
}
The token is used for all the below User and Admin requests. You need to add it in the header like this (without {}):
Authorization: Bearer {token from the register/login response}
POST /address/create - create the address for orders delivery
{
"country": "country",
"city": "city",
"street": "street",
"house_number": "house num"
}
{
"status": 200,
"error": "",
"data": {
"country": "country",
"city": "city",
"street": "street",
"house_number": "house num",
"apartment_number": "",
"floor": 0
}
}
POST /address/update
{
"apartment_number": "apt num",
"floor": 10
}
{
"status": 200,
"error": "",
"data": {
"country": "country",
"city": "city",
"street": "street",
"house_number": "house num",
"apartment_number": "apt num",
"floor": 10
}
}
GET /address - get current user delivery address
{
"status": 200,
"error": "",
"data": {
"country": "country",
"city": "city",
"street": "street",
"house_number": "house num",
"apartment_number": "apt num",
"floor": 10
}
}
DELETE /address
{
"status": 200,
"error": "",
"data": ""
}
POST /user/update
{
"email": "[email protected]",
"password": "new pass"
}
{
"status": 200,
"error": "",
"data": ""
}
POST /user/logout
{
"status": 200,
"error": "",
"data": ""
}
GET /user - get user info
{
"status": 200,
"error": "",
"data": {
"user_id": "5a28f8091967bcae95b1ca3c977032a0",
"name": "name",
"surname": "suraname",
"email": "[email protected]",
"phone_number": "+1234"
}
}
DELETE /user
{
"status": 200,
"error": "",
"data": ""
}
POST /order/create
{
"books_id": ["27dbfc56ea8f9a107376faf2880333c9"],
"delivery_date_time": "2023-05-01T20:00:00Z"
}
{
"status": 200,
"error": "",
"data": {
"id": "09fb2a3b52fa0a19c88c64d1fa919924",
"books_id": [
"27dbfc56ea8f9a107376faf2880333c9"
],
"delivery_date_time": "2023-05-01T20:00:00Z",
"created_at": 1678547286,
"delivered_at": 0
}
}
POST /order/update
{
"order_id": "09fb2a3b52fa0a19c88c64d1fa919924",
"delivered_at": 1682964000
}
{
"status": 200,
"error": "",
"data": {
"id": "09fb2a3b52fa0a19c88c64d1fa919924",
"books_id": [],
"delivery_date_time": "2023-05-01T20:00:00Z",
"created_at": 1678547286,
"delivered_at": 1682964000
}
}
GET /order/list
{
"status": 200,
"error": "",
"data": {
"orders": [
{
"id": "09fb2a3b52fa0a19c88c64d1fa919924",
"books_id": [
"27dbfc56ea8f9a107376faf2880333c9"
],
"delivery_date_time": "2023-05-01T20:00:00Z",
"created_at": 1678547286,
"delivered_at": 1682964000
}
]
}
}
DELETE /order
{
"status": 200,
"error": "",
"data": ""
}
POST /author/create
{
"name": "name",
"surname": "surname"
}
{
"status": 0,
"error": "",
"data": {
"author_id": "68444111a907302917f1abbcb867b6a7",
"name": "name",
"surname": "surname",
"bio": ""
}
}
POST /author/update
{
"author_id": "68444111a907302917f1abbcb867b6a7",
"bio": "bio"
}
{
"status": 0,
"error": "",
"data": {
"author_id": "68444111a907302917f1abbcb867b6a7",
"name": "name",
"surname": "surname",
"bio": "bio"
}
}
DELETE /author
{
"status": 200,
"error": "",
"data": ""
}
POST /book/create
{
"title": "title",
"language": "eng",
"description": "desc",
"price": 100
}
{
"status": 200,
"error": "",
"data": {
"book_id": "3c8838d2d7fc3bfa407084482d2f8c72",
"title": "title",
"series": "",
"price": 100,
"picture": "",
"publisher": "",
"language": "eng",
"description": "desc",
"count": 0,
"authors_id": []
}
}
POST /book/update
{
"book_id": "3c8838d2d7fc3bfa407084482d2f8c72",
"count": 1000,
"authors_id": ["68444111a907302917f1abbcb867b6a7"]
}
{
"status": 200,
"error": "",
"data": {
"book_id": "3c8838d2d7fc3bfa407084482d2f8c72",
"title": "title",
"series": "",
"price": 100,
"picture": "",
"publisher": "",
"language": "eng",
"description": "desc",
"count": 1000,
"authors_id": [
"68444111a907302917f1abbcb867b6a7"
]
}
}
POST /book/picture - add book cover picture
Form-data body in the request.
book_id (text): {book_id}
picture (file): {file path}
{
"status": 200,
"error": "",
"data": ""
}
DELETE /book
{
"status": 200,
"error": "",
"data": ""
}
GET /user/list - get the list of all users
{
"status": 200,
"error": "",
"data": {
"users": [
{
"user_id": "5a28f8091967bcae95b1ca3c977032a0",
"name": "name",
"surname": "suraname",
"email": "[email protected]",
"phone_number": "+1234"
}
]
}
}