GithubHelp home page GithubHelp logo

g-vans / book-api-rails Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 30 KB

This is a REST API that calls an external API service to get information about books and also perform simple CRUD operations on it.

Ruby 99.29% HTML 0.71%
rails rspec-testing ruby

book-api-rails's Introduction

My Book API

This is a REST API that calls an external API service to get information about books and also perform simple CRUD(Create, Read, Update, Delete) operations on it.

Getting Started

To get started with the API, follow these instructions:

Prerequisites

You need to have the following installed on your system:

  • Ruby (version 3.0 or higher)
  • Rails (version 7.0.6 )

Installation

  1. Clone the repository:
git clone https://github.com/G-vans/book-api-rails.git
cd book-api-rails
  1. Install the required gems:
bundle install
  1. Create and migrate the database then start the server:
rails db:create
rails db:migrate
rails s

Now the API should be up and running at 'http://localhost:3000'.

API Endpoints

The following are the available API endpoints:

Fetch External Books

  • Endpoint: GET /external_books
  • Params: name (string, required)
  • Response: Returns a list of external books matching the given name.

Create a Book

  • Endpoint: POST /books
  • Params:
    • name (string, required)
    • isbn (string, required)
    • authors (array of strings, required)
    • number_of_pages (integer, required)
    • publisher (string)
    • country (string)
    • release_date (string in the format "YYYY-MM-DD")
    • Response: Returns the details of the newly created book.

Get All Books

  • Endpoint: GET /books
  • Response: Returns a list of all books in the bookstore.

Get a Specific Book

  • Endpoint: GET /books/:id
  • Params: id (integer, required)
  • Response: Returns the details of the specified book.

Update a Book

  • Endpoint: PATCH /books/:id
  • Params: Same as create endpoint
  • Response: Returns the updated details of the book.

Delete a Book

  • Endpoint: DELETE /books/:id
  • Params: id (integer, required)
  • Response: Returns a success message if the book was deleted successfully.

Error Handling

The API returns appropriate error responses with status codes and error messages in case of any issues with the requests.

Running Tests

To run the test suite and verify that the API endpoints are functioning as expected, use the following command:

bundle exec rspec

Contributing

Contributions are welcome! If you find any issues or want to add new features, feel free to create a pull request.

book-api-rails's People

Contributors

g-vans 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.