Google Books is our effort to make book content more discoverable on the Web. Using the Google Books API, your application can perform full-text searches and retrieve book information, viewability and eBook availability.
https://developers.google.com/books/
Install package Google.Apis.Books.v1.1 from nuget
Install package Google.Apis.Books.v1.1 from nuget
Install-Package Google.Apis.Books.v1
Create a C# project, MVC application will do;
Create a class in the project, let’s call it BookApi class,
Create a C# project, MVC application will do;
Create a class in the project, let’s call it BookApi class,
public class BookModel
{
public string Id {
get;
set;
}
public string Title {
get;
set;
}
public string Subtitle {
get;
set;
}
public string Description {
get;
set;
}
public int ? PageCount {
get;
set;
}
}
public class BookApi {
private readonly BooksService _booksService;
public BookApi(string apiKey) {
_booksService = new BooksService(new BaseClientService.Initializer() {
ApiKey = apiKey,
ApplicationName = this.GetType().ToString()
});
}
public Tuple < int ? , List < BookModel >> Search(string query, int offset, int count) {
var listquery = _booksService.Volumes.List(query);
listquery.MaxResults = count;
listquery.StartIndex = offset;
var res = listquery.Execute();
var books = res.Items.Select(b => new BookModel {
Id = b.Id,
Title = b.VolumeInfo.Title,
Subtitle = b.VolumeInfo.Subtitle,
Description = b.VolumeInfo.Description,
PageCount = b.VolumeInfo.PageCount,
}).ToList();
return new Tuple < int ? , List < BookModel >> (res.TotalItems, books);
}
}