Categories
Category merupakan tipe dari genre untuk mengklasifikasikan genre berdasarkan buku-buku. Category dapat di pilih berdasarkan genre yang akan dibuat nanti.
Get All Categories
Get All
GET https://openapi.omdo.site/api/categories
{
"success": true,
"message": "Categories retrieved successfully",
"data": [
{
"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/categories',
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/categories", 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/categories',
headers: { }
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});curl --location 'https://openapi.omdo.site/api/categories'Get Categories by ID
GET https://openapi.omdo.site/api/categories/{id}
Path Parameters
id*
integer
Category ID for get specify data books
{
"success": true,
"message": "Category retrieved successfully",
"data": {
"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"
}
}{
"success": false,
"message": "Failed to retrieve category",
"data": null,
"error": "No query results for model [App\\Models\\Category] 2"
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/categories/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/categories/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/categories/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/categories/2'Create Category
POST https://openapi.omdo.site/api/categories
application/json
Headers
Authorization*
String
Token JWT with Bearer type
Request Body
name*
String
Category name
description
String
Category description
{
"success": true,
"message": "Category created successfully",
"data": {
"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/categories',
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": "Category Name",
"description": "Category Description"
}',
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": "Category Name",
"description": "Category Description"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/categories", 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": "Category Name",
"description": "Category Description"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/categories',
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/categories' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6' \
--data '{
"name": "Category Name",
"description": "Category Description"
}'Update Category
PUT https://openapi.omdo.site/api/categories/{id}
application/json
Path Parameters
id*
Integer
Category id
Headers
Authorization*
String
Token JWT with Bearer type
Request Body
name*
String
Category name
description
String
category description
{
"success": true,
"message": "Category updated",
"data": {
"id": 1,
"name": "Category Name",
"description": "Category Description"
}
}{
"success": false,
"message": "Unprocessable Entity",
"data": {},
"errors": {}
}{
"success": false,
"message": "Category not found",
"errors": {}
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/categories',
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": "Category Name",
"description": "Category Description"
}',
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": "Category Name",
"description": "Category Description"
});
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://openapi.omdo.site/api/categories/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": "Category Name",
"description": "Category Description"
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'https://openapi.omdo.site/api/categories/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/categories/1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6' \
--data '{
"name": "Category Name",
"description": "Category Description"
}'Delete Category
DELETE https://openapi.omdo.site/api/categories/{id}
Path Parameters
id*
integer
Category ID for get specify data books
{
"success": true,
"message": "Category has been deleted",
"data": {}
}{
"success": false,
"message": "Internal server error",
"errors": {}
}{
"success": false,
"message": "Category Not Found",
"data": {}
}<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.omdo.site/api/categories/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/categories/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/categories/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/categories/2' \
--header 'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'Last updated