Dox Example
This api is implemented according to the JSON API spec.
Filter
If you want to filter your query, you can do so by setting the supported filter parameters in the following way:
?author_id=24
Books ¶
Book Collections ¶
Get book collectionsGET/api/v1/book_collections
Example URI
GET /api/v1/book_collections
Request
returns book collections
GET /api/v1/book_collections
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": [
{
"id": "1",
"type": "book_collections",
"attributes": {
"name": "Book_collection_1"
},
"relationships": {
"books": {
"meta": {
"included": false
}
}
}
}
]
}
Get a book collectionGET/api/v1/book_collections/{id}
Example URI
GET /api/v1/book_collections/1
URI Parameters
- id
number
(required) Example: 1
Request
returns a book collection
GET /api/v1/book_collections/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "1",
"type": "book_collections",
"attributes": {
"name": "Book_collection_2"
},
"relationships": {
"books": {
"data": []
}
}
}
}
Request
does not find a book collection
GET /api/v1/book_collections/invalid_id
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
404
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": []
}
Create a book collectionPOST/api/v1/book_collections
Example URI
POST /api/v1/book_collections
Request
creates a new book collection
POST /api/v1/book_collections
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book_collection",
"attributes": {
"name": "Book_collection_5"
}
}
}
Response
201
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "2",
"type": "book_collections",
"attributes": {
"name": "Book_collection_5"
},
"relationships": {
"books": {
"meta": {
"included": false
}
}
}
}
}
Request
returns unprocessable entity
POST /api/v1/book_collections
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book_collection",
"attributes": {
"name": ""
}
}
}
Response
422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": [
{
"title": "Unprocessable Entity",
"detail": "Name can't be blank",
"source": {
"parameter": "name",
"pointer": "data/attributes/name"
}
}
]
}
Update a book collectionPUT/api/v1/book_collections/{id}
Example URI
PUT /api/v1/book_collections/1
URI Parameters
- id
number
(required) Example: 1
Request
updates the requested book collection
PUT /api/v1/book_collections/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book_collection",
"id": 1,
"attributes": {
"name": "New Book Collection"
}
}
}
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "1",
"type": "book_collections",
"attributes": {
"name": "New Book Collection"
},
"relationships": {
"books": {
"meta": {
"included": false
}
}
}
}
}
Request
returns unprocessable entity
PUT /api/v1/book_collections/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book_collection",
"id": 1,
"attributes": {
"name": ""
}
}
}
Response
422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": [
{
"title": "Unprocessable Entity",
"detail": "Name can't be blank",
"source": {
"parameter": "name",
"pointer": "data/attributes/name"
}
}
]
}
Delete a book collectionDELETE/api/v1/book_collections/{id}
Example URI
DELETE /api/v1/book_collections/1
URI Parameters
- id
number
(required) Example: 1
Request
deletes the requested book collection
DELETE /api/v1/book_collections/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
204
Books ¶
Supported filter params
- author_id
Get booksGET/api/v1/books
Example URI
GET /api/v1/books
Request
returns books
GET /api/v1/books
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": [
{
"id": "1",
"type": "books",
"attributes": {
"name": "Book_1"
},
"relationships": {
"author": {
"meta": {
"included": false
}
},
"book_collection": {
"meta": {
"included": false
}
}
}
}
]
}
Get a bookGET/api/v1/books/{id}
Example URI
GET /api/v1/books/1
URI Parameters
- id
number
(required) Example: 1
Request
returns a book
GET /api/v1/books/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "1",
"type": "books",
"attributes": {
"name": "Book_2"
},
"relationships": {
"author": {
"data": {
"type": "authors",
"id": "1"
}
},
"book_collection": {
"data": {
"type": "book_collections",
"id": "1"
}
}
}
},
"included": [
{
"id": "1",
"type": "authors",
"attributes": {
"name": "Author_11"
},
"relationships": {
"books": {
"meta": {
"included": false
}
}
}
},
{
"id": "1",
"type": "book_collections",
"attributes": {
"name": "Book_collection_11"
},
"relationships": {
"books": {
"meta": {
"included": false
}
}
}
}
]
}
Request
does not return a book
GET /api/v1/books/invalid_id
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
404
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": []
}
Create a bookPOST/api/v1/books
Example URI
POST /api/v1/books
Request
creates a new book
POST /api/v1/books
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book",
"attributes": {
"name": "New Book",
"author_id": 1
}
}
}
Response
201
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "2",
"type": "books",
"attributes": {
"name": "New Book"
},
"relationships": {
"author": {
"meta": {
"included": false
}
},
"book_collection": {
"meta": {
"included": false
}
}
}
}
}
Request
returns unprocessable entity
POST /api/v1/books
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book",
"attributes": {
"name": ""
}
}
}
Response
422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": [
{
"title": "Unprocessable Entity",
"detail": "Author must exist",
"source": {
"parameter": "author",
"pointer": "data/attributes/author"
}
},
{
"title": "Unprocessable Entity",
"detail": "Name can't be blank",
"source": {
"parameter": "name",
"pointer": "data/attributes/name"
}
}
]
}
Request
doesn't create a new book
POST /api/v1/books
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book",
"attributes": {
"name": ""
}
}
}
Response
422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": [
{
"title": "Unprocessable Entity",
"detail": "Author must exist",
"source": {
"parameter": "author",
"pointer": "data/attributes/author"
}
},
{
"title": "Unprocessable Entity",
"detail": "Name can't be blank",
"source": {
"parameter": "name",
"pointer": "data/attributes/name"
}
}
]
}
Update a bookPUT/api/v1/books/{id}
Example URI
PUT /api/v1/books/1
URI Parameters
- id
number
(required) Example: 1
Request
updates the requested book
PUT /api/v1/books/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book",
"id": 1,
"attributes": {
"name": "New Book"
}
}
}
Response
200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"data": {
"id": "1",
"type": "books",
"attributes": {
"name": "New Book"
},
"relationships": {
"author": {
"meta": {
"included": false
}
},
"book_collection": {
"meta": {
"included": false
}
}
}
}
}
Request
returns unprocessable entity
PUT /api/v1/books/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Body
{
"data": {
"type": "book",
"id": 1,
"attributes": {
"name": ""
}
}
}
Response
422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
"errors": [
{
"title": "Unprocessable Entity",
"detail": "Name can't be blank",
"source": {
"parameter": "name",
"pointer": "data/attributes/name"
}
}
]
}
Delete a bookDELETE/api/v1/books/{id}
Example URI
DELETE /api/v1/books/1
URI Parameters
- id
number
(required) Example: 1
Request
deletes the requested book
DELETE /api/v1/books/1
Headers
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Response
204