Skip to content

Jedt3D/isbn_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ISBN API

A simple RESTful API built with Sinatra for validating ISBN-10 and ISBN-13 strings and retrieving the version of the isbn_field gem.

Setup

  1. Clone the repository
  2. Install dependencies:
    bundle install
    
  3. Run the application:
    rackup -p 4567 config.ru
    

API Endpoints

1. Validate ISBN

Endpoint: POST /validate

Request Body:

{
  "isbn": "978-0-596-52068-7"
}

Response:

  • For valid ISBN:
    {
      "valid": true,
      "message": "validation pass"
    }
  • For invalid ISBN:
    {
      "valid": false,
      "message": "validation failed"
    }
  • For incorrect format:
    {
      "valid": false,
      "message": "wrong format"
    }
  • If ISBN is not provided:
    {
      "valid": false,
      "message": "ISBN is required"
    }

2. Get ISBN Field Gem Version

Endpoint: GET /version

Response:

{
  "version": "0.1.2"
}

Example Usage

Using curl:

# Validate ISBN-10
curl -X POST http://localhost:4567/validate \
  -H "Content-Type: application/json" \
  -d '{"isbn": "0321765723"}'

# Validate ISBN-13
curl -X POST http://localhost:4567/validate \
  -H "Content-Type: application/json" \
  -d '{"isbn": "978-0321765723"}'

# Get version
curl -X GET http://localhost:4567/version

About

A Sinatra app to test `isbn_field` gem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages