Books
Endpoint untuk menampilkan data buku-buku, menambahkan buku dalam rak kami(database), mengubah data buku yang sudah ada atau menghapus daftar buku didalamnya.
Get All Books
Get All
GET https://openapi.omdo.site/api/books
{
"success": true,
"message": "Books retrieved successfully",
"data": [
{
"id": 2,
"name": "Naruto Sirippuden",
"description": "Naruto Shippuden adalah sebuah seri anime yang diadaptasi dari bagian II manga Naruto. Serial ini disutradarai oleh Hayato Date dan diproduksi oleh Studio Pierrot dan TV Tokyo. Pada bagian ini, pergerakan organisasi Akatsuki semakin terlihat.",
"pages": 200,
"published_at": "2022-01-01",
"author": "Masashi Kishimoto",
"price": "300.00",
"genre_id": 1,
"created_at": "2023-07-05T03:37:51.000000Z",
"updated_at": "2023-07-05T03:37:51.000000Z",
"genre": {
"id": 1,
"name": "Horor",
"description": "Pikasieenen Intinya mah Gess",
"category_id": 1,
"created_at": "2023-07-05T03:34:46.000000Z",
"updated_at": "2023-07-05T03:34:46.000000Z",
"category": {
"id": 1,
"name": "Dewasa",
"description": "Category Kedewasaan yang haqiqi",
"created_at": "2023-07-04T05:45:39.000000Z",
"updated_at": "2023-07-04T05:45:39.000000Z"
}
}
}
]
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site0/api/books',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/books", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/books',
headers: { }
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});curl --location 'https://openapi.omdo.site/api/books'Get Books by ID
GET https://openapi.omdo.site/api/books/{id}
Path Parameters
id*
integer
Book ID for get specify data books
{
"success": true,
"message": "Books retrieved successfully",
"data": {
"id": 2,
"name": "Naruto Sirippuden",
"description": "Naruto Shippuden adalah sebuah seri anime yang diadaptasi dari bagian II manga Naruto. Serial ini disutradarai oleh Hayato Date dan diproduksi oleh Studio Pierrot dan TV Tokyo. Pada bagian ini, pergerakan organisasi Akatsuki semakin terlihat.",
"pages": 200,
"published_at": "2022-01-01",
"author": "Masashi Kishimoto",
"price": "300.00",
"genre_id": 1,
"created_at": "2023-07-05T03:37:51.000000Z",
"updated_at": "2023-07-05T03:37:51.000000Z"
}
}{
"success": false,
"message": "Failed to retrieve book",
"data": null,
"error": "No query results for model [App\\Models\\Book] 5"
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/books/2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/books/2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/books/2',
headers: { }
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location 'https://openapi.omdo.site/api/books/2'Create Book
POST https://openapi.omdo.site/api/books
application/json
Headers
Authorization*
String
Token JWT with Bearer type
Request Body
name*
String
Book name
description
String
Description book
pages*
Integer
Total page book
published_at*
Date
Date published book
author*
String
Author name
price*
Float
Price book
genre_id*
Integer
Genre ID (reference: Genre)
{
"success": true,
"message": "Book created successfully",
"data": {
"id": 1,
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1,
"genre": {
"id": 1,
"name": "Genre Name",
"description": "Genre Description",
"genre_id": 1,
"category": {
"id": 1,
"name": "Category Name",
"description": "Category Description"
},
}
}
}{
"success": false,
"message": "Unprocessable Entity",
"data": {},
"errors": {}
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/books',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6");
var raw = JSON.stringify({
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/books", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));const axios = require('axios');
let data = JSON.stringify({
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/books',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location 'https://openapi.omdo.site/api/books' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6' \
--data '{
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
}'Update Book
PUT https://openapi.omdo.site/api/books/{id}
application/json
Path Parameters
id*
Integer
Books id
Headers
Authorization*
String
Token JWT with Bearer type
Request Body
name*
String
Book name
description
String
Description book
pages*
Integer
Total page book
published_at*
Date
Date published book
author*
String
Author name
price*
Float
Price book
genre_id*
Integer
Genre ID (reference: Genre)
{
"success": true,
"message": "Book updated successfully",
"data": {
"id": 1,
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1,
"genre": {
"id": 1,
"name": "Genre Name",
"description": "Genre Description",
"genre_id": 1,
"category": {
"id": 1,
"name": "Category Name",
"description": "Category Description"
},
}
}
}{
"success": false,
"message": "Unprocessable Entity",
"data": {},
"errors": {}
}{
"success": false,
"message": "Book not found",
"errors": {}
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/books',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6");
var raw = JSON.stringify({
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
});
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/books/1", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));const axios = require('axios');
let data = JSON.stringify({
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/books/1',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location --request PUT 'https://openapi.omdo.site/api/books/1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6' \
--data '{
"name": "Book Name",
"description": "Book Description",
"pages": 200,
"published_at": "2022-01-01",
"author": "Book Author",
"price": 19.99,
"genre_id": 1
}'Delete Book
DELETE https://openapi.omdo.site/api/books/{id}
Path Parameters
id*
integer
Book ID for get specify data books
{
"success": true,
"message": "Book has been deleted",
"data": {}
}{
"success": false,
"message": "Internal server error",
"errors": {}
}{
"success": false,
"message": "Book Not Found",
"data": {}
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/books/2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6");
var requestOptions = {
method: 'DELETE',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/books/2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));const axios = require('axios');
let config = {
method: 'delete',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/books/2',
headers: {
'Authorization': 'Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
curl --location --request DELETE 'https://openapi.omdo.site/api/books/2' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'Last updated