Giter Club home page Giter Club logo

simple-books-api.glitch.me's Introduction

Simple Books API

This API allows you to reserve a book.

The API is available at https://simple-books-api.glitch.me

Endpoints

Status

GET /status

Returns the status of the API.

List of books

GET /books

Returns a list of books.

Optional query parameters:

  • type: fiction or non-fiction
  • limit: a number between 1 and 20.

Get a single book

GET /books/:bookId

Retrieve detailed information about a book.

Submit an order

POST /orders

Allows you to submit a new order. Requires authentication.

The request body needs to be in JSON format and include the following properties:

  • bookId - Integer - Required
  • customerName - String - Required

Example

POST /orders/
Authorization: Bearer <YOUR TOKEN>

{
  "bookId": 1,
  "customerName": "John"
}

The response body will contain the order Id.

Get all orders

GET /orders

Allows you to view all orders. Requires authentication.

Get an order

GET /orders/:orderId

Allows you to view an existing order. Requires authentication.

Update an order

PATCH /orders/:orderId

Update an existing order. Requires authentication.

The request body needs to be in JSON format and allows you to update the following properties:

  • customerName - String

Example

PATCH /orders/PF6MflPDcuhWobZcgmJy5
Authorization: Bearer <YOUR TOKEN>

{
  "customerName": "John"
}

Delete an order

DELETE /orders/:orderId

Delete an existing order. Requires authentication.

The request body needs to be empty.

Example

DELETE /orders/PF6MflPDcuhWobZcgmJy5
Authorization: Bearer <YOUR TOKEN>

API Authentication

To submit or view an order, you need to register your API client.

POST /api-clients/

The request body needs to be in JSON format and include the following properties:

  • clientName - String
  • clientEmail - String

Example

{
   "clientName": "Postman",
   "clientEmail": "[email protected]"
}

The response body will contain the access token. The access token is valid for 7 days.

Possible errors

Status code 409 - "API client already registered." Try changing the values for clientEmail and clientName to something else.

simple-books-api.glitch.me's People

Contributors

pwalaszkowski avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.