Skip to content

Instantly share code, notes, and snippets.

@mabasic
Created March 12, 2017 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mabasic/ededf40e476eb76b34bd8b489f380668 to your computer and use it in GitHub Desktop.
Save mabasic/ededf40e476eb76b34bd8b489f380668 to your computer and use it in GitHub Desktop.
Advanced API Blueprint for Bookstore
FORMAT: 1A
# Bookstore Advanced
Bookstore is a simple API which allows consumers to view all books and create new ones.
## Data Structures
### Book
+ title: The answer to everything (required)
+ author: Mario Bašić (required)
## Group Book
Resources related to books in the API.
### Book collection [/books]
This resource allows you to view a list of books and create a new book.
#### View all books [GET]
This actions returns all books in JSON format.
+ Response 200 (application/json)
{
"data": [
{
"id": 1,
"title": "A Collection of Laravel Tutorials",
"author": "Mario Bašić"
},
{
"id": 2,
"title": "12 Steps for a brighter tomorrow",
"author": "Mario Bašić"
}
]
}
#### Create a new book [POST]
You may create a new book using this action. It takes a JSON
object containing a title and an author.
+ title (string) - The title of the book.
+ author (string) - Name of the author.
+ Request (application/json)
{
"title": "The answer to everything",
"author": "Mario Bašić",
}
+ Response 201 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
#### Create a new book - JSON schema [POST]
You may create a new book using this action. It takes a JSON
object containing a title and an author.
+ title (string) - The title of the book.
+ author (string) - Name of the author.
+ Request (application/json)
+ Body
{
"title": "The answer to everything",
"author": "Mario Bašić",
}
+ Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Book",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"author": {
"type": "string"
}
},
"required": ["title", "author"]
}
+ Response 201 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
#### Create a new book - MSON [POST]
You may create a new book using this action. It takes a JSON
object containing a title and an author.
+ title (string) - The title of the book.
+ author (string) - Name of the author.
+ Request (application/json)
+ Attributes
+ title: The answer to everything (required)
+ author: Mario Bašić (required)
+ Response 201 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
#### Create a new book - MSON + data structure [POST]
You may create a new book using this action. It takes a JSON
object containing a title and an author.
+ title (string) - The title of the book.
+ author (string) - Name of the author.
+ Request (application/json)
+ Attributes (Book)
+ Response 201 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
### Book [/books/{book_id}]
This resource allows you to view a single book.
+ Parameters
+ book_id (number) - The ID of the book you want to view.
#### View a single book [GET]
This actions returns a book in JSON format.
+ Response 200 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
#### View a single book [GET]
This actions returns a book in JSON format.
+ Relation: self
+ Response 200 (application/json)
{
"id": 3,
"title": "The answer to everything",
"author": "Mario Bašić",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment