- Retrieves book details using ISBN10 / ISBN13 from 4 providers:
- Google Books
- Open Library
- Goodreads (requires env var GOODREAD_APIKEY to be set) free
- ISBNDB (requires env var ISBNDB_APIKEY to be set) 7-day trial
- Validates if a string is in valid ISBN10 / ISBN13 format
go-isbn will spawn equal number of go routines each querying a single provider with a max timeout of 3 seconds. First valid result will then be returned. Will return book not found only if all providers fail. Will default to all available providers if none is specified
go get github.com/abx123/go-isbn
Querying on all 4 providers:
package main
import (
"fmt"
"log"
goisbn "github.com/abx123/go-isbn"
)
func main() {
// go-isbn instance
gi := goisbn.NewGoISBN(goisbn.DEFAULT_PROVIDERS)
// Get book details
book, err := gi.Get("9780099588986")
if err != nil{
log.Fatalln(err)
}
fmt.Println(book)
Querying on selected providers:
package main
import (
"fmt"
"log"
goisbn "github.com/abx123/go-isbn"
)
func main() {
// go-isbn instance
gi := goisbn.NewGoISBN([]string{
goisbn.ProviderGoogle,
goisbn.ProviderGoodreads,
})
// Get book details
book, err := gi.Get("9780099588986")
if err != nil{
log.Fatalln(err)
}
fmt.Println(book)