Skip to content

Commit

Permalink
Merge pull request #189 from MohanRamSridhar/master
Browse files Browse the repository at this point in the history
Google Books API
  • Loading branch information
dishamodi0910 authored Jun 2, 2024
2 parents cebc500 + 015ad40 commit 68c29b9
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Existing_API_Collection/Books_API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Google Books API Example

This is a simple web application that allows users to search for books using the Google Books API. The application is built with HTML, CSS, and JavaScript, and it fetches book data based on the user's query.

### Features

- Search for books by title or author.
- Display search results with book thumbnails, titles, authors, and descriptions.
- Responsive design with a modern and clean user interface.

### Installation

No special installation is required. Simply download the files and open index.html in a web browser.

### Usage

1. Open index.html in a web browser.
2. Enter a book title or author in the search input field.
3. Click the "Search" button to fetch and display the search results.

### Screenshot

![](https://github.com/MohanRamSridhar/APIVerse/blob/9213cc20e28e6753e8532273d4126fb78d89e441/Existing_API_Collection/Books_API/booksapi.png)
Binary file added Existing_API_Collection/Books_API/booksapi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions Existing_API_Collection/Books_API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Books API Example</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f4f4f9;
color: #333;
}
h1 {
color: #5D5C61;
}
#query {
width: 300px;
padding: 10px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 15px;
background-color: #6D9DC5;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #3A84A0;
}
#results {
margin-top: 20px;
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.book {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 20px;
width: calc(33% - 40px);
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.book:hover {
transform: translateY(-5px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.book img {
max-width: 120px;
margin-bottom: 15px;
border-radius: 4px;
}
.book h2 {
font-size: 18px;
margin: 10px 0;
color: #333;
text-align: center;
}
.book p {
margin: 5px 0;
color: #555;
text-align: center;
}
</style>
</head>
<body>
<h1>Search for Books</h1>
<input type="text" id="query" placeholder="Enter book title or author">
<button onclick="searchBooks()">Search</button>
<div id="results"></div>

<script>
function searchBooks() {
const query = document.getElementById('query').value;
fetch(`https://www.googleapis.com/books/v1/volumes?q=${query}`)
.then(response => response.json())
.then(data => {
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
data.items.forEach(item => {
const book = document.createElement('div');
book.className = 'book';

const title = document.createElement('h2');
title.textContent = item.volumeInfo.title;

const author = document.createElement('p');
author.textContent = `Author: ${item.volumeInfo.authors ? item.volumeInfo.authors.join(', ') : 'N/A'}`;

const description = document.createElement('p');
description.textContent = item.volumeInfo.description || 'No description available.';

const thumbnail = document.createElement('img');
if (item.volumeInfo.imageLinks && item.volumeInfo.imageLinks.thumbnail) {
thumbnail.src = item.volumeInfo.imageLinks.thumbnail;
} else {
thumbnail.src = 'https://via.placeholder.com/100';
}

book.appendChild(thumbnail);
book.appendChild(title);
book.appendChild(author);
book.appendChild(description);
resultsDiv.appendChild(book);
});
})
.catch(error => console.error('Error fetching data:', error));
}
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion Existing_API_Collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
|[JSON_Placeholder_API](./JSON_Plaeholder_API/)| this api is used to test basic crud operations on fake data posts |
|[Gold Silver Price](./Gold,silver_price_API/)|This API helps you check realtime price of gold and silver for each categories |
|[GeoAPI](./GeoAPI/)| GeoAPI is a simple RESTful API that allows you to convert addresses to geographic coordinates (latitude and longitude) and vice versa. This API is built using Node.js and Express.|
|[Currency Converter API](./Currency_Converter_API/)| Currency_Converter is a simple RESTful API that allows you to convert currency values to different currency|
|[Books API](./Books_API/)| The Google Books API allows developers to access a wealth of information about books, including their titles, authors, publishers, publication dates, and descriptions. |
|[Currency Converter API](./Currency_Converter_API/)| Currency_Converter is a simple RESTful API that allows you to convert currency values to different currency|

0 comments on commit 68c29b9

Please sign in to comment.