Getting Started

            This document describes the resources that make up the an api that responds with books or genres or customers.
            If you have any problems or requests, please contact us.

                        Create an user account:

            [ To access most of the endpoints in the api you'll have to varify as an user and get the token to access the routes ]

            1. Make a POST request to https://something.com/api/register with the following parameters:

            2.  {
               "email": "your email",
               "password": "********",
               }
              
              Response: Created

                          Authorize User:

              1. Make a POST request to https://something.com/api/auth with the following

                [ Has to be same as the one that you used to create an user or it'll return an Unauthorized error:

              2.  {
                 "email": "your email",
                 "password": "********",
                 }
                
              3. If the user is found then it'll return the following:

              4. The response body will be a JSON representation of your user’s access token:

                 {
                   "access_token": "091343ce13c8ae780065ecb3b13dc903475dd22cb78a05503c2e0c69c5e98044",
                   "token_type": "jwt",
                   "created_at": 1436544465
                 }
                

                Access tokens do not expires after 15days.

                            Location

                The API is available at https://locahost:3000/api/books. Responses are sent as JSON format.

                The API is available at https://locahost:3000/api/genres. Responses are sent as JSON format.

                The API is available at https://locahost:3000/api/customers. Responses are sent as JSON format.

                            HTTP Verbs

                The Az's API uses HTTP verbs appropriate to each action.

                Verb Description
                GET Retrieving resources.
                POST Creating resources.
                PUT Updating resources.
                DELETE Deleting resources.

                            Error messages

                If an error occurs, whether on the server or client side, the error message(s) will be returned in an errors array. For example:

                Unauthorized!! please go Authenticate
                
                {
                  "errors": ["Not authorized", "token found"]
                }
                

                              Books


                GET all the books

                something.com/api/books

                Note: To access all the books you are required to authorized

                Note: Without a jwt token (i.e. using a Client-ID token) this request will return a 401 Unauthorized response.

                Response

                200 OK
                
                {
                  "id": "5c0f328a489a0399c00a4e0d",
                  "title": "Journey of Make School",
                  "genre": "story",
                  "description": "A story about how make school had gotten started and how far it has come today",
                  "author": "Aktar Zaman",
                  "publisher": "Make School Press",
                  "pages": 500,
                  "image_url": "https://aktarzaman.com/",
                  "buy_url": "https://aktarzaman.com/",
                
                
                  [MORE books...]
                    [MORE books...]
                      [MORE books...]
                        [MORE books...]
                          [MORE books...]
                

                GET one book using book id:

                something.com/api/books/:_id

                Response

                200 OK
                
                {
                  "id": "5c0f328a489a0399c00a4e0d",
                  "title": "Journey of Make School",
                  "genre": "story",
                  "description": "A story about how make school had gotten started and how far it has come today",
                  "author": "Aktar Zaman",
                  "publisher": "Make School Press",
                  "pages": 500,
                  "image_url": "https://aktarzaman.com/",
                  "buy_url": "https://aktarzaman.com/",
                

                POST a book in the books:

                something.com/api/books/:_id
                Following parameter are required to create a book:

                Response

                created
                
                {
                  "title": "required",
                  "genre": "required",
                  "description": "required",
                  "author": "required",
                  "publisher": "required ",
                  "pages": required,
                  "image_url": "required",
                  "buy_url": "required",
                

                PUT a book in the books:

                something.com/api/books/:_id
                Following parameter are required to replace a book:

                Response

                created
                
                {
                  "title": "required",
                  "genre": "required",
                  "description": "required",
                  "author": "required",
                  "publisher": "required ",
                  "pages": required,
                  "image_url": "required",
                  "buy_url": "required",
                

                DELETE a book in the books:

                something.com/api/books/:_id
                Following parameter are required to delete a book:

                Response

                null
                
                {
                  "id": "5c0f328a489a0399c00a4e0d",
                  "title": "required",
                  "genre": "required",
                  "description": "required",
                  "author": "required",
                  "publisher": "required ",
                  "pages": required,
                  "image_url": "required",
                  "buy_url": "required",
                

    To call other endpoints such as: something.com/api/customers or something.com/api/genres follow the same patterns as books endpoint!

      Look at the results first to see how the JSON is responded then provide the right parameter when doing POST, PUT or DELETE